drop
drop() function
Returns all but the first length
elements of the given iterable.
declare function drop<A>(length: number, iterable: Iterable<A>): IterableIterator<A>;
declare function drop<A>(length: number, iterable: AsyncIterable<A>): AsyncIterableIterator<A>;
declare function drop<A extends Iterable<unknown> | AsyncIterable<unknown>>(length: number): (iterable: A) => ReturnIterableIteratorType<A>;
Example
const iter = drop(2, [1, 2, 3, 4]);
iter.next() // {done:false, value: 3}
iter.next() // {done:false, value: 4}
iter.next() // {done:true, value: undefined}
// with pipe
pipe(
[1, 2, 3, 4],
drop(2),
toArray,
); // [3, 4]
await pipe(
Promise.resolve([1, 2, 3, 4]),
drop(2),
toArray,
); // [3, 4]
// with toAsync
await pipe(
[Promise.resolve(1), Promise.resolve(2), Promise.resolve(3), Promise.resolve(4)],
toAsync,
drop(2),
toArray,
); // [3, 4]