import { Duplex, Writable, Transform, Readable } from 'stronger-typed-streams'; export { Duplex, Writable, Transform, Readable } from 'stronger-typed-streams'; /** * Given stream (which outputs chunks of tyoe `O`) it will return a Promise that * resolves to an array of O[]. */ export declare function streamDataCollector(r: Readable | Transform, cb?: Callback): Promise; /** * Super basic re-implementation of @caolan's `async.map` using Node streams and * other functions / classes within this library. */ export declare function asyncMap(worker: (x: X, cb: Callback) => void, xs: X[], next: Callback): void; /** * Given an array of type `T`, convert it into a stream of type `T`. */ export declare class ArrayReadable extends Readable { private a; private delay; private i; constructor(a: T[], delay?: number); _read(): void; } /** * The function that you pass to `ScanTransform` to do the processing. */ export interface ScanFunc { (acc: O, a: I, next: (e: null | undefined | Error, b?: O) => void): void; } /** * Scan is like Reduce, except that it outputs every intermediate value, not * just the final result. If you want reduce combine this with `FinalDuplex`. */ export declare class ScanTransform extends Transform { protected f: ScanFunc; private acc; constructor(scanFunc: ScanFunc, acc: O, opts?: {}); _transform(a: I, encoding: any, cb: any): void; } /** * Collects all results until the stream is closed, at which point it outputs * all results as an single array */ export declare class CollectorTransform extends Transform { private results; constructor(opts: any); _flush(cb: any): void; _transform(a: T, encoding: any, cb: any): void; } /** * When a stream is piped into `FirstDuplex` it will only ever pass through the * very first item outputted by that stream. */ export declare class FirstDuplex extends Duplex { private done; constructor(opts?: {}); _write(chunk: I, encoding: any, cb: any): void; _read(n: any): void; } /** * When a stream is piped into `FinalDuplex` it will only ever pass through the * very last item outputted by that stream. */ export declare class FinalDuplex extends Duplex { private buffer; constructor(opts?: {}); _write(chunk: I, encoding: any, cb: any): void; _read(n: any): void; } /** * Comparator function for `SortDuplex` */ export interface SortDuplexCompareFunc { (a: I, b: I): number; } /** * Will sort the data piped into it using a supplied `SortDuplexCompareFunc` */ export declare class SortDuplex extends Duplex { private buffer; private readCount; private writeFinished; private started; constructor(sortFunc: SortDuplexCompareFunc, opts?: {}); _write(chunk: I, encoding: any, cb: any): void; _read(n: any): void; } /** * Worker for `MapTransform` */ export interface MapFunc { (a: I, next: (e: null | undefined | Error, b?: O) => void): void; } /** * Given a stream of type `T[]` is broken up into a stream of T. */ export declare class FlattenTransform extends Transform { _transform(ts: T[], encoding: any, cb: any): void; } /** * Given a stream of type `I` is piped in and a function that maps `I` to `O`. This * will output a stream of type `O`. */ export declare class MapTransform extends Transform { private f; constructor(mapFunc: MapFunc, opts?: {}); _transform(a: I, encoding: any, cb: any): void; } /** * When you `add()` (which is not pipe) streams into this then any errors * emitted by that stream will be outputted in the stream coming from this. */ export declare class ErrorStream extends Readable { private pipeCount; constructor(opts?: {}); add(s: Readable | Transform | Writable | Duplex): void; _read(size?: number): void; } /** * Used by FilterTransform to output items which were filtered out. See * `FilterTransform.getRejectedReader()`. */ export declare class RejectedFilterTransformStream extends Readable { private vals; _read(size: number): void; } /** * The worker used in `FilterTransform`. */ export interface FilterFunc { (a: T, next: (e: null | undefined | Error, b?: boolean) => void): void; } /** * A `Transform` which will filter out items for which the `FilterFunc` returns * non truthy values. */ export declare class FilterTransform extends Transform { private f; private rejectedReader; constructor(opts: {} | undefined, filterFunc: FilterFunc, performNegative?: boolean); getRejectedReader(): RejectedFilterTransformStream; _flush(cb: any): void; _transform(a: T, encoding: any, cb: any): void; } /** * Joins multiple steams into one. It is expected that all input streams will be * of the same type. */ export declare class ParallelJoin extends Readable { inputs: Writable[]; constructor(opts?: { [k: string]: any; }); _read(n: any): void; add(opts?: { [k: string]: any; }): Writable; } /** * Given a left stream outputting `L` and right stream outputting `R`, as well * as some logic to combine them (in `onData()`) this class will produce output * of type `O`. */ export declare abstract class AbstractLeftRightJoiner extends Readable { private leftBuffer; private rightBuffer; private done; private started; left: Writable; right: Writable; constructor(opts?: { [k: string]: any; }); private handleFireCallback(buffer, v, add, toPush); private fire(); private remove(buffer, indices); /** * The method for joining together the left and right datasets. * * @param L[] leftValues All the left values recieved so far which have not * been cleared. * @param R[] rightValues All the right values recieved so far which have * not been cleared. * @return O[] An object including deadIndices of leftValues and rightValues * which will be removed from the data so far and the items * `toPush` which will be piped out of this instance. */ abstract onData(leftValues: (L | null)[], rightValues: (R | null)[]): Error | { deadIndicesLeft: number[]; deadIndicesRight: number[]; toPush: (O | null)[]; }; _read(n: any): void; } /** * Map function for `RightAfterLeft` wich can be called multiple times receives * all left values (of type `L`) as well as some values from the right (of type * `R`). It should return `O[]` which are the result of joining `L`'s to `R`'s. */ export interface RightAfterLeftMapFunc { (ls: L[], rs: R, done?: boolean): O[]; } /** * An simpler implementation of `Joiner` which will keep all items from the left * until that stream is finished and then (using `RightAfterLeftMapFunc`) allow * mapping/joining of all right values with all left values. */ export declare class RightAfterLeft extends AbstractLeftRightJoiner { private mapper; private buffer; private hasLength; constructor(mapper: RightAfterLeftMapFunc, opts?: {}); onData(leftValues: (L | null)[], rightValues: (R | null)[]): { deadIndicesLeft: number[]; deadIndicesRight: number[]; toPush: (O | null)[]; }; } export declare function _bufferArrayToLastMarkerArray(): (ii: (I | null)[]) => [I, boolean][]; /** * Definition for standard callback */ export interface Callback { (e: Error | null | undefined, r?: R): void; } export declare class NewSource extends Readable { constructor(opts: any); _read(count: any): void; _push(d: A): void; _emit(m: any, e: any): void; } export declare function split(count: number, src: Readable, opts?: {}): Readable[];