, "done">;
/**
* Pipes a Highland Stream to a [Node Writable
* Stream](https://nodejs.org/api/stream.html#stream_class_stream_writable).
* This will pull all the data from the source Highland Stream and write it to
* the destination, automatically managing flow so that the destination is not
* overwhelmed by a fast source.
*
* Users may optionally pass an object that may contain any of these fields:
*
* - `end` - Ends the destination when this stream ends. Default: `true`. This
* option has no effect if the destination is either `process.stdout` or
* `process.stderr`. Those two streams are never ended.
*
* Like [Readable#pipe](https://nodejs.org/api/stream.html#stream_readable_pipe_destination_options),
* this function will throw errors if there is no `error` handler installed on
* the stream.
*
* This function returns the destination so you can chain together `pipe` calls.
*
* **NOTE**: While Highland streams created via `_()` and [pipeline](#pipeline)
* support being piped to, it is almost never appropriate to `pipe` from a
* Highland stream to another Highland stream. Those two cases are meant for
* use when piping from *Node* streams. You might be tempted to use `pipe` to
* construct reusable transforms. Do not do it. See [through](#through) for a
* better way.
*
* @id pipe
* @section Consumption
* @name Stream.pipe(dest, options)
* @param {Writable Stream} dest - the destination to write all data to
* @param {Object} options - (optional) pipe options.
* @api public
*/
pipe(dest: Stream): Stream;
pipe(dest: U, options?: { end?: boolean | undefined }): U;
/**
* Consumes a single item from the Stream. Unlike consume, this function will
* not provide a new stream for you to push values onto, and it will unsubscribe
* as soon as it has a single error, value or nil from the source.
*
* You probably won't need to use this directly, but it is used internally by
* some functions in the Highland library.
*
* @id pull
* @section Streams
* @name Stream.pull(f)
* @param {Function} f - the function to handle data
* @api public
*/
pull(f: (err: Error, x: R | Highland.Nil) => void): void;
/**
* Collects all values from a Stream into an Array and calls a function with
* once with the result. This function causes a **thunk**.
*
* If an error from the Stream reaches the `toArray` call, it will emit an
* error event (which will cause it to throw if unhandled).
*
* @id toArray
* @section Streams
* @name Stream.toArray(f)
* @param {Function} f - the callback to provide the completed Array to
* @api public
*/
toArray(f: (arr: R[]) => void): void;
/**
* Returns the result of a stream to a nodejs-style callback function.
*
* If the stream contains a single value, it will call `cb`
* with the single item emitted by the stream (if present).
* If the stream is empty, `cb` will be called without any arguments.
* If an error is encountered in the stream, this function will stop
* consumption and call `cb` with the error.
* If the stream contains more than one item, it will stop consumption
* and call `cb` with an error.
*
* @id toCallback
* @section Consumption
* @name Stream.toCallback(cb)
* @param {Function} cb - the callback to provide the error/result to
* @api public
*
* _([1, 2, 3, 4]).collect().toCallback(function (err, result) {
* // parameter result will be [1,2,3,4]
* // parameter err will be null
* });
*/
toCallback(cb: (err?: Error, x?: R) => void): void;
/**
* Converts the stream to a node Readable Stream for use in methods
* or pipes that depend on the native stream type.
*
* The options parameter can be an object passed into the [`Readable`
* constructor](https://nodejs.org/api/stream.html#stream_class_stream_readable).
*
* @id toNodeStream
* @section Consumption
* @name Stream.toNodeStream(options)
* @param {Object} options - (optional) [`Readable` constructor](https://nodejs.org/api/stream.html#stream_class_stream_readable) options
* @api public
*
* _(fs.createReadStream('./abc')).toNodeStream()
* _(fs.createReadStream('./abc')).toNodeStream({objectMode: false})
* _([{a: 1}]).toNodeStream({objectMode: true})
*/
toNodeStream(options?: object): NodeJS.ReadableStream;
/**
* Converts the result of a stream to Promise.
*
* If the stream contains a single value, it will return
* with the single item emitted by the stream (if present).
* If the stream is empty, `undefined` will be returned.
* If an error is encountered in the stream, this function will stop
* consumption and call `cb` with the error.
* If the stream contains more than one item, it will stop consumption
* and reject with an error.
*
* @id toPromise
* @section Consumption
* @name Stream.toPromise(PromiseCtor)
* @param {Function} PromiseCtor - Promises/A+ compliant constructor
* @api public
*
* _([1, 2, 3, 4]).collect().toPromise(Promise).then(function (result) {
* // parameter result will be [1,2,3,4]
* });
*/
toPromise>(PromiseCtor: PConstructor): P;
}
interface PipeableStream extends Stream {}
interface PipeOptions {
end: boolean;
}
type MappingHint = number | string[] | Function;
interface CleanupObject {
onDestroy?: Function | undefined;
continueOnError?: boolean | undefined;
}
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
type OnFinished = (r: NodeJS.ReadableStream, cb: (...args: any[]) => void) => void | Function | CleanupObject;
}
declare var highland: HighlandStatic;
declare module "highland" {
export = highland;
}