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