/** * A lazy, single-pass async pipeline over the items produced by `Cursor.iter`. * The transforms (`map`/`filter`/`take`/`drop`) build a new pipeline without * pulling anything; work happens only when a terminal step (`for await`, * `toArray`, `reduce`, etc.) drains it. Every callback may be async. The stream * is single-use: consuming it (or any chained terminal) exhausts the source, so * iterate or collect it once. */ export interface IterStream extends AsyncIterable { /** * Yield the underlying fetch batches (arrays of items) instead of individual * items, exposing the batch boundary set by {@link IterOptions.maxBatchCount} * (and {@link IterOptions.maxBatchBytes}). Used * for more advanced use cases or if you simply don't like all the sugar. */ raw(): AsyncIterable; /** Like `Array.prototype.map`, but lazy and streaming; `fn` may be async. */ map(fn: (item: T, index: number) => U | Promise): IterStream; /** Like `Array.prototype.filter`, but lazy and streaming; narrows `T` to `U` via the type guard. */ filter(fn: (item: T, index: number) => item is U): IterStream; /** Like `Array.prototype.filter`, but lazy and streaming; `fn` may be async. */ filter(fn: (item: T, index: number) => boolean | Promise): IterStream; /** Keep at most the first `limit` items, then stop pulling from the source. Like `Array.prototype.slice(0, limit)`. */ take(limit: number): IterStream; /** Skip the first `limit` items, then yield the rest. Like `Array.prototype.slice(limit)`. */ drop(limit: number): IterStream; /** Drain the stream into an array. Like `Array.prototype` spreading, but buffers every item - avoid on unbounded sources. */ toArray(): Promise; /** Like `Array.prototype.forEach`, but awaits the stream and each (possibly async) `fn`. */ forEach(fn: (item: T, index: number) => void | Promise): Promise; /** Like `Array.prototype.reduce` with a required `init`, but streaming; `fn` may be async. */ reduce(fn: (acc: A, item: T, index: number) => A | Promise, init: A): Promise; /** Like `Array.prototype.find`, but streaming and short-circuiting; stops pulling once `fn` matches. */ find(fn: (item: T, index: number) => boolean | Promise): Promise; /** Like `Array.prototype.some`, but streaming and short-circuiting; stops at the first match. */ some(fn: (item: T, index: number) => boolean | Promise): Promise; /** Like `Array.prototype.every`, but streaming and short-circuiting; stops at the first failure. */ every(fn: (item: T, index: number) => boolean | Promise): Promise; } export declare function makeStream(batches: () => AsyncIterable, batchSize: number, regroup?: boolean): IterStream;