Skip to main content
Module

x/better_iterators/mod.ts>Lazy

Chainable iterators (sync and async) for TypeScript, with support for opt-in, bounded parallelism
Go to Latest
class Lazy
implements Iterable<T>, LazyShared<T>
import { Lazy } from "https://deno.land/x/better_iterators@v1.0.3/mod.ts";

Constructors

new
private
Lazy(iter: Iterable<T>)

Methods

also(fn: (t: T) => void): Lazy<T>

Injects a function to run on each T as it is being iterated.

Keeps only items for which f is true.

limit(count: number): Lazy<T>

Limit the iterator to returning at most count items.

map<Out>(transform: Transform<T, Out>): Lazy<Out>

Apply transform to each element.

Works like Array#map.

toArray(): Array<T>

Collect all items into an array.

Convert to a LazyAsync, which better handles chains of Promises.

[Symbol.iterator](): Iterator<T>

Static Methods

from<T>(iter: Iterable<T>): Lazy<T>