UNPKG

2.25 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/through2`
3
4# Summary
5This package contains type definitions for through2 (https://github.com/rvagg/through2).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/through2.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/through2/index.d.ts)
10````ts
11/// <reference types="node" />
12
13import stream = require("stream");
14
15declare function through2(transform?: through2.TransformFunction, flush?: through2.FlushCallback): stream.Transform;
16declare function through2(
17 opts?: stream.DuplexOptions,
18 transform?: through2.TransformFunction,
19 flush?: through2.FlushCallback,
20): stream.Transform;
21
22declare namespace through2 {
23 interface Through2Constructor extends stream.Transform {
24 new(opts?: stream.DuplexOptions): stream.Transform;
25 (opts?: stream.DuplexOptions): stream.Transform;
26 }
27
28 type TransformCallback = (err?: any, data?: any) => void;
29 type TransformFunction = (
30 this: stream.Transform,
31 chunk: any,
32 enc: BufferEncoding,
33 callback: TransformCallback,
34 ) => void;
35 type FlushCallback = (this: stream.Transform, flushCallback: () => void) => void;
36
37 /**
38 * Convenvience method for creating object streams
39 */
40 function obj(transform?: TransformFunction, flush?: FlushCallback): stream.Transform;
41
42 /**
43 * Creates a constructor for a custom Transform. This is useful when you
44 * want to use the same transform logic in multiple instances.
45 */
46 function ctor(transform?: TransformFunction, flush?: FlushCallback): Through2Constructor;
47 function ctor(
48 opts?: stream.DuplexOptions,
49 transform?: TransformFunction,
50 flush?: FlushCallback,
51 ): Through2Constructor;
52}
53
54export = through2;
55
56````
57
58### Additional Details
59 * Last updated: Tue, 07 Nov 2023 20:08:00 GMT
60 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)
61
62# Credits
63These definitions were written by [Bart van der Schoor](https://github.com/Bartvds), [Georgios Valotasios](https://github.com/valotas), [TeamworkGuy2](https://github.com/TeamworkGuy2), and [Alorel](https://github.com/Alorel).
64
\No newline at end of file