UNPKG

2.8 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/combined-stream`
3
4# Summary
5This package contains type definitions for combined-stream (https://github.com/felixge/node-combined-stream).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/combined-stream.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/combined-stream/index.d.ts)
10````ts
11// Type definitions for combined-stream 1.0
12// Project: https://github.com/felixge/node-combined-stream
13// Definitions by: Felix Geisendörfer <https://github.com/felixge>, Tomek Łaziuk <https://github.com/tlaziuk>, Kon Pik <https://github.com/konpikwastaken>
14// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
15
16/// <reference types="node" />
17
18import { Stream } from 'stream';
19
20type Appendable = NodeJS.ReadableStream | NodeJS.WritableStream | Buffer | string | NextFunction;
21type NextFunction = (next: (stream: Appendable) => any) => any;
22
23interface Options {
24 maxDataSize?: number | undefined;
25 pauseStreams?: boolean | undefined;
26}
27
28declare class CombinedStream extends Stream implements Options {
29 readonly writable: boolean;
30 readonly readable: boolean;
31 readonly dataSize: number;
32 maxDataSize: number;
33 pauseStreams: boolean;
34 append(stream: Appendable): this;
35 write(data: any): void;
36 pause(): void;
37 resume(): void;
38 end(): void;
39 destroy(): void;
40
41 // private properties
42 _released: boolean;
43 // @TODO it should be a type of Array<'delayed-stream' instance | Buffer | string>
44 _streams: Array<Stream | Buffer | string>;
45 _currentStream: Stream | Buffer | string | null;
46 _getNext(): void;
47 _pipeNext(): void;
48 _handleErrors(stream: NodeJS.EventEmitter): void;
49 _reset(): void;
50 _checkDataSize(): void;
51 _updateDataSize(): void;
52 _emitError(error: Error): void;
53
54 // events
55 on(event: 'close' | 'end' | 'resume' | 'pause', cb: () => void): this;
56 on(event: 'error', cb: (err: Error) => void): this;
57 on(event: 'data', cb: (data: any) => void): this;
58 once(event: 'close' | 'end' | 'resume' | 'pause', cb: () => void): this;
59 once(event: 'error', cb: (err: Error) => void): this;
60 once(event: 'data', cb: (data: any) => void): this;
61
62 static create(options?: Options): CombinedStream;
63 static isStreamLike(stream: any): stream is Stream;
64}
65
66export = CombinedStream;
67
68````
69
70### Additional Details
71 * Last updated: Tue, 06 Jul 2021 18:05:57 GMT
72 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)
73 * Global values: none
74
75# Credits
76These definitions were written by [Felix Geisendörfer](https://github.com/felixge), [Tomek Łaziuk](https://github.com/tlaziuk), and [Kon Pik](https://github.com/konpikwastaken).
77
\No newline at end of file