Takes only the prefix of length count. If count >= length(list), the list itself will be returned.
count
count >= length(list)
The length to take.
The taken list.
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 }); Copy
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 });
Takes only the prefix of length
count. Ifcount >= length(list), the list itself will be returned.