| | |
| | | * |
| | | * The `stream` module is useful for creating new types of stream instances. It is |
| | | * usually not necessary to use the `stream` module to consume streams. |
| | | * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/stream.js) |
| | | * @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/stream.js) |
| | | */ |
| | | declare module 'stream' { |
| | | import { EventEmitter, Abortable } from 'node:events'; |
| | |
| | | readable: boolean; |
| | | /** |
| | | * Returns whether `'data'` has been emitted. |
| | | * @since v16.7.0 |
| | | * @since v16.7.0, v14.18.0 |
| | | * @experimental |
| | | */ |
| | | readonly readableDidRead: boolean; |
| | |
| | | * @since v8.0.0 |
| | | * @param error Error which will be passed as payload in `'error'` event |
| | | */ |
| | | destroy(error?: Error): void; |
| | | destroy(error?: Error): this; |
| | | /** |
| | | * Event emitter |
| | | * The defined events on documents including: |
| | |
| | | * @param encoding The encoding if `chunk` is a string |
| | | * @param callback Callback for when the stream is finished. |
| | | */ |
| | | end(cb?: () => void): void; |
| | | end(chunk: any, cb?: () => void): void; |
| | | end(chunk: any, encoding: BufferEncoding, cb?: () => void): void; |
| | | end(cb?: () => void): this; |
| | | end(chunk: any, cb?: () => void): this; |
| | | end(chunk: any, encoding: BufferEncoding, cb?: () => void): this; |
| | | /** |
| | | * The `writable.cork()` method forces all written data to be buffered in memory. |
| | | * The buffered data will be flushed when either the {@link uncork} or {@link end} methods are called. |
| | |
| | | * @since v8.0.0 |
| | | * @param error Optional, an error to emit with `'error'` event. |
| | | */ |
| | | destroy(error?: Error): void; |
| | | destroy(error?: Error): this; |
| | | /** |
| | | * Event emitter |
| | | * The defined events on documents including: |
| | |
| | | write(chunk: any, encoding?: BufferEncoding, cb?: (error: Error | null | undefined) => void): boolean; |
| | | write(chunk: any, cb?: (error: Error | null | undefined) => void): boolean; |
| | | setDefaultEncoding(encoding: BufferEncoding): this; |
| | | end(cb?: () => void): void; |
| | | end(chunk: any, cb?: () => void): void; |
| | | end(chunk: any, encoding?: BufferEncoding, cb?: () => void): void; |
| | | end(cb?: () => void): this; |
| | | end(chunk: any, cb?: () => void): this; |
| | | end(chunk: any, encoding?: BufferEncoding, cb?: () => void): this; |
| | | cork(): void; |
| | | uncork(): void; |
| | | } |
| | |
| | | ref(): void; |
| | | unref(): void; |
| | | } |
| | | |
| | | /** |
| | | * Returns whether the stream has encountered an error. |
| | | * @since v17.3.0 |
| | | */ |
| | | function isErrored(stream: Readable | Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean; |
| | | |
| | | /** |
| | | * Returns whether the stream is readable. |
| | | * @since v17.4.0 |
| | | */ |
| | | function isReadable(stream: Readable | NodeJS.ReadableStream): boolean; |
| | | |
| | | const promises: typeof streamPromises; |
| | | const consumers: typeof streamConsumers; |
| | | } |