/** * An async iterator that can't be cancelled. * * To keep data flow simple, we always pass an explicit cancellation token when subscribing to async streams. Once the * {@link AbortSignal} aborts, iterators are supposed to clean up and then emit a final `{done: true}` event. This means * that there's no way to distinguish between streams that have completed normally and streams that have been cancelled, * but that is acceptable for our uses of this. */ export type SimpleAsyncIterator = Pick, 'next'>; export declare const doneResult: IteratorReturnResult; export declare function valueResult(value: T): { done: boolean; value: T; }; /** * A variant of {@link Array.map} for async iterators. */ export declare function map(source: SimpleAsyncIterator, map: (source: T1) => T2): SimpleAsyncIterator; export interface InjectableIterator extends SimpleAsyncIterator { inject(event: T): void; } /** * Expands a source async iterator by allowing to inject events asynchronously. * * The resulting iterator will emit all events from its source. Additionally though, events can be injected. These * events are dropped once the main iterator completes, but are otherwise forwarded. * * The iterator completes when its source completes, and it supports backpressure by only calling `next()` on the source * in response to a `next()` call from downstream if no pending injected events can be dispatched. */ export declare function injectable(source: SimpleAsyncIterator): InjectableIterator; /** * Splits a byte stream at line endings, emitting each line as a string. */ export declare function extractJsonLines(source: SimpleAsyncIterator, decoder: TextDecoder): SimpleAsyncIterator; /** * Splits a concatenated stream of BSON objects by emitting individual objects. */ export declare function extractBsonObjects(source: SimpleAsyncIterator): SimpleAsyncIterator;