drop<T>(source: Iterable<T> | AsyncIterable<T>,count: number,): AsyncIterableIterator<T>
Drops a specified number of elements from the beginning of an async iterable, and yields the remaining elements.
import { drop } from "./drop.ts"; async function* gen() { yield "foo"; yield "bar"; yield "baz"; yield "qux" } const iterable = drop(gen(), 2); for await (const value of iterable) { console.log(value); }
The above example will print the following 2 lines:
baz qux
If the iterable is shorter than or equal to the specified number, no elements are yielded.
import { drop } from "./drop.ts"; async function* gen() { yield "foo"; yield "bar"; yield "baz"; yield "qux" } const iterable = drop(gen(), 4); for await (const value of iterable) { console.log(value); }
The above example will print nothing.
AsyncIterableIterator<T>
An async iterable that yields the remaining elements after dropping
the first count elements from the source iterable.