import { take } from "https://deno.land/x/iter@v3.2.3/mod.ts";
Returns a new iterable containing the first n
items of it
.
Examples
Example 1
Example 1
import * as iter from "https://deno.land/x/iter/mod.ts";
const naturals = iter.create.increments(1);
const first6 = iter.take(naturals, 6);
for (const num of first6) {
console.log(num);
}
// -> 1
// -> 2
// -> 3
// -> 4
// -> 5
// -> 6
Parameters
it: Iterable<T>
- The iterable being taken from.
Returns
A new iterable of it
which terminates after n
items.