@mikuroxina/mini-fn
    Preparing search index...

    Function take

    • Takes only the prefix of length count. If count >= length(list), the list itself will be returned.

      Parameters

      • count: number

        The length to take.

      Returns <T>(list: List.List<T>) => List.List<T>

      The taken list.

      Examples

      const taken = take(2)(range(1, 6));
      const iter = toIterator(taken);
      expect(iter.next()).toStrictEqual({ value: 1, done: false });
      expect(iter.next()).toStrictEqual({ value: 2, done: false });
      expect(iter.next()).toStrictEqual({ value: undefined, done: true });