Skip to main content
Module

x/ahh/mod.ts>I.take

Idiomatic type-safety functions.
Go to Latest
method I.take
import { I } from "https://deno.land/x/ahh@v0.10.1/mod.ts";

Creates an Iterator that returns the first n items.

Examples

import { I } from "./mod.ts";

const iter = I.take(I.iter([1, 2, 3]), 2);

console.log(iter.next()); // 1
console.log(iter.next()); // 2
console.log(iter.next()); // undefined

Parameters

iter: Iterator<T>
n: number