1 |
|
2 | import * as stream from "stream";
|
3 |
|
4 | export = from2;
|
5 |
|
6 | declare function from2(read: from2.ReadInput): from2.Stream;
|
7 | declare function from2(opts: from2.ObjectModeOptions, read: from2.ReadObjectInput): from2.Stream;
|
8 | declare function from2(opts: from2.Options, read: from2.ReadInput): from2.Stream;
|
9 |
|
10 | declare namespace from2 {
|
11 | interface Stream extends NodeJS.ReadableStream {
|
12 | readonly destroyed: boolean;
|
13 | destroy: (err?: Error) => void;
|
14 | }
|
15 | function obj(read: ReadObjectInput): Stream;
|
16 | function obj(opts: { objectMode?: true | undefined } & stream.ReadableOptions, read: ReadObjectInput): Stream;
|
17 |
|
18 | function ctor(opts?: Options): From2Ctor<ReadInput>;
|
19 | function ctor(opts: ObjectModeOptions): From2Ctor<ReadObjectInput>;
|
20 |
|
21 | type ObjectModeOptions = { objectMode: true } & stream.ReadableOptions;
|
22 | type Options = { objectMode?: false | undefined } & stream.ReadableOptions;
|
23 |
|
24 | type From2Ctor<R extends ReadInput | ReadObjectInput> = new(read: R) => Stream;
|
25 |
|
26 | type ReadObjectInput = ReadCallback<NextObjectCallback> | any[];
|
27 | type ReadInput = ReadCallback<NextCallback> | Chunk[];
|
28 | type ReadCallback<N extends NextCallback | NextObjectCallback> = (size: number, next: N) => void;
|
29 | type NextCallback = (err: any | undefined, chunk: Chunk) => void;
|
30 | type NextObjectCallback = (err: any | undefined, chunk: any) => void;
|
31 | type Chunk = string | Buffer | Uint8Array | null;
|
32 | }
|