UNPKG

2.26 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/from2`
3
4# Summary
5This package contains type definitions for from2 (https://github.com/hughsk/from2).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/from2.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/from2/index.d.ts)
10````ts
11// Type definitions for from2 2.3
12// Project: https://github.com/hughsk/from2
13// Definitions by: BendingBender <https://github.com/BendingBender>
14// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
15
16/// <reference types="node" />
17import * as stream from 'stream';
18
19export = from2;
20
21declare function from2(read: from2.ReadInput): NodeJS.ReadableStream;
22declare function from2(opts: from2.ObjectModeOptions, read: from2.ReadObjectInput): NodeJS.ReadableStream;
23declare function from2(opts: from2.Options, read: from2.ReadInput): NodeJS.ReadableStream;
24
25declare namespace from2 {
26 function obj(read: ReadObjectInput): NodeJS.ReadableStream;
27 function obj(opts: { objectMode?: true | undefined } & stream.ReadableOptions, read: ReadObjectInput): NodeJS.ReadableStream;
28
29 function ctor(opts?: Options): From2Ctor<ReadInput>;
30 function ctor(opts: ObjectModeOptions): From2Ctor<ReadObjectInput>;
31
32 type ObjectModeOptions = { objectMode: true } & stream.ReadableOptions;
33 type Options = { objectMode?: false | undefined } & stream.ReadableOptions;
34
35 type From2Ctor<R extends ReadInput | ReadObjectInput> = new(read: R) => NodeJS.ReadableStream;
36
37 type ReadObjectInput = ReadCallback<NextObjectCallback> | any[];
38 type ReadInput = ReadCallback<NextCallback> | Chunk[];
39 type ReadCallback<N extends NextCallback | NextObjectCallback> = (size: number, next: N) => void;
40 type NextCallback = (err: any | undefined, chunk: Chunk) => void;
41 type NextObjectCallback = (err: any | undefined, chunk: any) => void;
42 type Chunk = string | Buffer | Uint8Array | null;
43}
44
45````
46
47### Additional Details
48 * Last updated: Tue, 06 Jul 2021 20:33:01 GMT
49 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)
50 * Global values: none
51
52# Credits
53These definitions were written by [BendingBender](https://github.com/BendingBender).
54
\No newline at end of file