Skip to main content
Module

x/better_iterators/mod.ts>LazyShared

Chainable iterators (sync and async) for TypeScript, with support for opt-in, bounded parallelism
Go to Latest
interface LazyShared
import { type LazyShared } from "https://deno.land/x/better_iterators@v1.0.2/mod.ts";

Shared interface for Lazy and LazyAsync. (Note: LazyAsync implements some methods that are not shared.)

You shouldn't need to interact with these classes or this interface directly, though. You can convert to the appropriate one with lazy().

Operations on lazy iterators consume the underlying iterator. You should not use them again.

Methods

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

Apply transform to each element.

Works like Array.map.

filter(f: Filter<T>): LazyShared<T>

Keeps only items for which f is true.

limit(count: number): LazyShared<T>

Limit the iterator to returning at most count items.

toArray(): Awaitable<Array<T>>

Collect all items into an array.

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

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