123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- declare module "stream" {
- import * as events from "events";
-
- class internal extends events.EventEmitter {
- pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
- }
-
- namespace internal {
- class Stream extends internal { }
-
- interface ReadableOptions {
- highWaterMark?: number;
- encoding?: string;
- objectMode?: boolean;
- read?(this: Readable, size: number): void;
- destroy?(this: Readable, error: Error | null, callback: (error: Error | null) => void): void;
- autoDestroy?: boolean;
- }
-
- class Readable extends Stream implements NodeJS.ReadableStream {
- readable: boolean;
- readonly readableHighWaterMark: number;
- readonly readableLength: number;
- constructor(opts?: ReadableOptions);
- _read(size: number): void;
- read(size?: number): any;
- setEncoding(encoding: string): this;
- pause(): this;
- resume(): this;
- isPaused(): boolean;
- unpipe(destination?: NodeJS.WritableStream): this;
- unshift(chunk: any): void;
- wrap(oldStream: NodeJS.ReadableStream): this;
- push(chunk: any, encoding?: string): boolean;
- _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
- destroy(error?: Error): void;
-
- /**
- * Event emitter
- * The defined events on documents including:
- * 1. close
- * 2. data
- * 3. end
- * 4. readable
- * 5. error
- */
- addListener(event: "close", listener: () => void): this;
- addListener(event: "data", listener: (chunk: any) => void): this;
- addListener(event: "end", listener: () => void): this;
- addListener(event: "readable", listener: () => void): this;
- addListener(event: "error", listener: (err: Error) => void): this;
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
-
- emit(event: "close"): boolean;
- emit(event: "data", chunk: any): boolean;
- emit(event: "end"): boolean;
- emit(event: "readable"): boolean;
- emit(event: "error", err: Error): boolean;
- emit(event: string | symbol, ...args: any[]): boolean;
-
- on(event: "close", listener: () => void): this;
- on(event: "data", listener: (chunk: any) => void): this;
- on(event: "end", listener: () => void): this;
- on(event: "readable", listener: () => void): this;
- on(event: "error", listener: (err: Error) => void): this;
- on(event: string | symbol, listener: (...args: any[]) => void): this;
-
- once(event: "close", listener: () => void): this;
- once(event: "data", listener: (chunk: any) => void): this;
- once(event: "end", listener: () => void): this;
- once(event: "readable", listener: () => void): this;
- once(event: "error", listener: (err: Error) => void): this;
- once(event: string | symbol, listener: (...args: any[]) => void): this;
-
- prependListener(event: "close", listener: () => void): this;
- prependListener(event: "data", listener: (chunk: any) => void): this;
- prependListener(event: "end", listener: () => void): this;
- prependListener(event: "readable", listener: () => void): this;
- prependListener(event: "error", listener: (err: Error) => void): this;
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
-
- prependOnceListener(event: "close", listener: () => void): this;
- prependOnceListener(event: "data", listener: (chunk: any) => void): this;
- prependOnceListener(event: "end", listener: () => void): this;
- prependOnceListener(event: "readable", listener: () => void): this;
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
-
- removeListener(event: "close", listener: () => void): this;
- removeListener(event: "data", listener: (chunk: any) => void): this;
- removeListener(event: "end", listener: () => void): this;
- removeListener(event: "readable", listener: () => void): this;
- removeListener(event: "error", listener: (err: Error) => void): this;
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
-
- [Symbol.asyncIterator](): AsyncIterableIterator<any>;
- }
-
- interface WritableOptions {
- highWaterMark?: number;
- decodeStrings?: boolean;
- defaultEncoding?: string;
- objectMode?: boolean;
- emitClose?: boolean;
- write?(this: Writable, chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
- writev?(this: Writable, chunks: Array<{ chunk: any, encoding: string }>, callback: (error?: Error | null) => void): void;
- destroy?(this: Writable, error: Error | null, callback: (error: Error | null) => void): void;
- final?(this: Writable, callback: (error?: Error | null) => void): void;
- autoDestroy?: boolean;
- }
-
- class Writable extends Stream implements NodeJS.WritableStream {
- writable: boolean;
- readonly writableHighWaterMark: number;
- readonly writableLength: number;
- constructor(opts?: WritableOptions);
- _write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
- _writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (error?: Error | null) => void): void;
- _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
- _final(callback: (error?: Error | null) => void): void;
- write(chunk: any, cb?: (error: Error | null | undefined) => void): boolean;
- write(chunk: any, encoding: string, cb?: (error: Error | null | undefined) => void): boolean;
- setDefaultEncoding(encoding: string): this;
- end(cb?: () => void): void;
- end(chunk: any, cb?: () => void): void;
- end(chunk: any, encoding: string, cb?: () => void): void;
- cork(): void;
- uncork(): void;
- destroy(error?: Error): void;
-
- /**
- * Event emitter
- * The defined events on documents including:
- * 1. close
- * 2. drain
- * 3. error
- * 4. finish
- * 5. pipe
- * 6. unpipe
- */
- addListener(event: "close", listener: () => void): this;
- addListener(event: "drain", listener: () => void): this;
- addListener(event: "error", listener: (err: Error) => void): this;
- addListener(event: "finish", listener: () => void): this;
- addListener(event: "pipe", listener: (src: Readable) => void): this;
- addListener(event: "unpipe", listener: (src: Readable) => void): this;
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
-
- emit(event: "close"): boolean;
- emit(event: "drain"): boolean;
- emit(event: "error", err: Error): boolean;
- emit(event: "finish"): boolean;
- emit(event: "pipe", src: Readable): boolean;
- emit(event: "unpipe", src: Readable): boolean;
- emit(event: string | symbol, ...args: any[]): boolean;
-
- on(event: "close", listener: () => void): this;
- on(event: "drain", listener: () => void): this;
- on(event: "error", listener: (err: Error) => void): this;
- on(event: "finish", listener: () => void): this;
- on(event: "pipe", listener: (src: Readable) => void): this;
- on(event: "unpipe", listener: (src: Readable) => void): this;
- on(event: string | symbol, listener: (...args: any[]) => void): this;
-
- once(event: "close", listener: () => void): this;
- once(event: "drain", listener: () => void): this;
- once(event: "error", listener: (err: Error) => void): this;
- once(event: "finish", listener: () => void): this;
- once(event: "pipe", listener: (src: Readable) => void): this;
- once(event: "unpipe", listener: (src: Readable) => void): this;
- once(event: string | symbol, listener: (...args: any[]) => void): this;
-
- prependListener(event: "close", listener: () => void): this;
- prependListener(event: "drain", listener: () => void): this;
- prependListener(event: "error", listener: (err: Error) => void): this;
- prependListener(event: "finish", listener: () => void): this;
- prependListener(event: "pipe", listener: (src: Readable) => void): this;
- prependListener(event: "unpipe", listener: (src: Readable) => void): this;
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
-
- prependOnceListener(event: "close", listener: () => void): this;
- prependOnceListener(event: "drain", listener: () => void): this;
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
- prependOnceListener(event: "finish", listener: () => void): this;
- prependOnceListener(event: "pipe", listener: (src: Readable) => void): this;
- prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this;
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
-
- removeListener(event: "close", listener: () => void): this;
- removeListener(event: "drain", listener: () => void): this;
- removeListener(event: "error", listener: (err: Error) => void): this;
- removeListener(event: "finish", listener: () => void): this;
- removeListener(event: "pipe", listener: (src: Readable) => void): this;
- removeListener(event: "unpipe", listener: (src: Readable) => void): this;
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
- }
-
- interface DuplexOptions extends ReadableOptions, WritableOptions {
- allowHalfOpen?: boolean;
- readableObjectMode?: boolean;
- writableObjectMode?: boolean;
- read?(this: Duplex, size: number): void;
- write?(this: Duplex, chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
- writev?(this: Duplex, chunks: Array<{ chunk: any, encoding: string }>, callback: (error?: Error | null) => void): void;
- final?(this: Duplex, callback: (error?: Error | null) => void): void;
- destroy?(this: Duplex, error: Error | null, callback: (error: Error | null) => void): void;
- }
-
- // Note: Duplex extends both Readable and Writable.
- class Duplex extends Readable implements Writable {
- writable: boolean;
- readonly writableHighWaterMark: number;
- readonly writableLength: number;
- constructor(opts?: DuplexOptions);
- _write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
- _writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (error?: Error | null) => void): void;
- _destroy(error: Error | null, callback: (error: Error | null) => void): void;
- _final(callback: (error?: Error | null) => void): void;
- write(chunk: any, encoding?: string, cb?: (error: Error | null | undefined) => void): boolean;
- write(chunk: any, cb?: (error: Error | null | undefined) => void): boolean;
- setDefaultEncoding(encoding: string): this;
- end(cb?: () => void): void;
- end(chunk: any, cb?: () => void): void;
- end(chunk: any, encoding?: string, cb?: () => void): void;
- cork(): void;
- uncork(): void;
- }
-
- type TransformCallback = (error?: Error | null, data?: any) => void;
-
- interface TransformOptions extends DuplexOptions {
- read?(this: Transform, size: number): void;
- write?(this: Transform, chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
- writev?(this: Transform, chunks: Array<{ chunk: any, encoding: string }>, callback: (error?: Error | null) => void): void;
- final?(this: Transform, callback: (error?: Error | null) => void): void;
- destroy?(this: Transform, error: Error | null, callback: (error: Error | null) => void): void;
- transform?(this: Transform, chunk: any, encoding: string, callback: TransformCallback): void;
- flush?(this: Transform, callback: TransformCallback): void;
- }
-
- class Transform extends Duplex {
- constructor(opts?: TransformOptions);
- _transform(chunk: any, encoding: string, callback: TransformCallback): void;
- _flush(callback: TransformCallback): void;
- }
-
- class PassThrough extends Transform { }
-
- function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, callback: (err?: NodeJS.ErrnoException | null) => void): () => void;
- namespace finished {
- function __promisify__(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream): Promise<void>;
- }
-
- function pipeline<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: T, callback?: (err: NodeJS.ErrnoException | null) => void): T;
- function pipeline<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: T, callback?: (err: NodeJS.ErrnoException | null) => void): T;
- function pipeline<T extends NodeJS.WritableStream>(
- stream1: NodeJS.ReadableStream,
- stream2: NodeJS.ReadWriteStream,
- stream3: NodeJS.ReadWriteStream,
- stream4: T,
- callback?: (err: NodeJS.ErrnoException | null) => void,
- ): T;
- function pipeline<T extends NodeJS.WritableStream>(
- stream1: NodeJS.ReadableStream,
- stream2: NodeJS.ReadWriteStream,
- stream3: NodeJS.ReadWriteStream,
- stream4: NodeJS.ReadWriteStream,
- stream5: T,
- callback?: (err: NodeJS.ErrnoException | null) => void,
- ): T;
- function pipeline(streams: Array<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>, callback?: (err: NodeJS.ErrnoException | null) => void): NodeJS.WritableStream;
- function pipeline(
- stream1: NodeJS.ReadableStream,
- stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
- ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | ((err: NodeJS.ErrnoException | null) => void)>,
- ): NodeJS.WritableStream;
- namespace pipeline {
- function __promisify__(stream1: NodeJS.ReadableStream, stream2: NodeJS.WritableStream): Promise<void>;
- function __promisify__(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: NodeJS.WritableStream): Promise<void>;
- function __promisify__(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: NodeJS.ReadWriteStream, stream4: NodeJS.WritableStream): Promise<void>;
- function __promisify__(
- stream1: NodeJS.ReadableStream,
- stream2: NodeJS.ReadWriteStream,
- stream3: NodeJS.ReadWriteStream,
- stream4: NodeJS.ReadWriteStream,
- stream5: NodeJS.WritableStream,
- ): Promise<void>;
- function __promisify__(streams: Array<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>): Promise<void>;
- function __promisify__(
- stream1: NodeJS.ReadableStream,
- stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
- ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream>,
- ): Promise<void>;
- }
-
- interface Pipe { }
- }
-
- export = internal;
- }
|