/// import {WritableOptions} from 'node:stream'; import {TypedWritable} from '../typed-streams'; export = reduceStream; /** A reducer function prototype */ type Reducer = (this: ReduceStreamOutput, acc: A, value: T) => A; /** An asynchronous reducer function prototype */ type ReducerPromise = (this: ReduceStreamOutput, acc: A, value: T) => Promise; /** * Options for the `reduceStream` function based on `WritableOptions` with some additional properties. */ interface ReduceStreamOptions extends WritableOptions { /** A reducer function. */ reducer?: Reducer | ReducerPromise; /** An initial accumulator. */ initial?: A; } /** * A writable stream that contains an accumulator as a property. */ interface ReduceStreamOutput extends TypedWritable { accumulator: A; } /** * Creates a writable stream that contains an accumulator as a property. * @param options options for the reduceStream (see {@link ReduceStreamOptions}) * @returns a writable stream * @remarks It is modelled on the [reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) method. */ declare function reduceStream(options: ReduceStreamOptions): ReduceStreamOutput; /** * Creates a writable stream that contains an accumulator as a property. * @param reducer a reducer function * @param initial an initial accumulator * @returns a writable stream * @remarks It is modelled on the [reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) method. */ declare function reduceStream( reducer: Reducer | ReducerPromise, initial: A ): ReduceStreamOutput;