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