import { dropEnd } from "https://deno.land/x/aitertools@0.6.0/src/drop.ts";
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.