1 | /// <reference types="node" />
|
2 |
|
3 | import * as stream from "stream";
|
4 |
|
5 | export interface MapStream extends stream.Stream {
|
6 | writable: boolean;
|
7 | readable: boolean;
|
8 |
|
9 | destroy: () => void;
|
10 | end: any;
|
11 | pause: () => void;
|
12 | resume: () => void;
|
13 | write: any;
|
14 | }
|
15 |
|
16 | /**
|
17 | * Create a stream from a series of MapStreams
|
18 | */
|
19 | export declare function pipeline(...streams: MapStream[]): MapStream;
|
20 |
|
21 | /**
|
22 | * Create a through stream from an asynchronous function
|
23 | *
|
24 | * @param asyncFunction
|
25 | */
|
26 | export declare function map(asyncFunction: Function): MapStream;
|
27 |
|
28 | /**
|
29 | * Same as map, but the callback is called synchronously. Based on es.through
|
30 | * @param syncFunction
|
31 | */
|
32 | export declare function mapSync(syncFunction: Function): MapStream;
|
33 |
|
34 | /**
|
35 | * Filter elements of the stream.
|
36 | * @param syncFunction
|
37 | */
|
38 | export declare function filterSync(syncFunction: (value: any) => boolean): MapStream;
|
39 |
|
40 | /**
|
41 | * Break up a stream and reassemble it so that each line is a chunk. matcher may be a String, or a RegExp
|
42 | *
|
43 | * @param matcher
|
44 | */
|
45 | export declare function split(matcher?: string | RegExp): MapStream;
|
46 |
|
47 | /**
|
48 | * Create a through stream that emits separator between each chunk, just like Array#join
|
49 | *
|
50 | * @param separator
|
51 | */
|
52 | export declare function join(separator: string): MapStream;
|
53 |
|
54 | /**
|
55 | * Merges streams into one and returns it. Incoming data will be emitted as soon it comes into - no ordering will be applied
|
56 | * (for example: data1 data1 data2 data1 data2 - where data1 and data2 is data from two streams).
|
57 | * Counts how many streams were passed to it and emits end only when all streams emitted end.
|
58 | *
|
59 | * @param stream
|
60 | */
|
61 | export declare function concat(...stream: MapStream[]): MapStream;
|
62 |
|
63 | /**
|
64 | * Merges streams into one and returns it. Incoming data will be emitted as soon it comes into - no ordering will be applied
|
65 | * (for example: data1 data1 data2 data1 data2 - where data1 and data2 is data from two streams).
|
66 | * Counts how many streams were passed to it and emits end only when all streams emitted end.
|
67 | *
|
68 | * @param stream
|
69 | */
|
70 | export declare function concat(streamArray: MapStream[]): MapStream;
|
71 |
|
72 | /**
|
73 | * Merges streams into one and returns it. Incoming data will be emitted as soon it comes into - no ordering will be applied
|
74 | * (for example: data1 data1 data2 data1 data2 - where data1 and data2 is data from two streams).
|
75 | * Counts how many streams were passed to it and emits end only when all streams emitted end.
|
76 | *
|
77 | * @param stream
|
78 | */
|
79 | export declare function merge(...stream: MapStream[]): MapStream;
|
80 |
|
81 | /**
|
82 | * Merges streams into one and returns it. Incoming data will be emitted as soon it comes into - no ordering will be applied
|
83 | * (for example: data1 data1 data2 data1 data2 - where data1 and data2 is data from two streams).
|
84 | * Counts how many streams were passed to it and emits end only when all streams emitted end.
|
85 | *
|
86 | * @param stream
|
87 | */
|
88 | export declare function merge(streamArray: MapStream[]): MapStream;
|
89 |
|
90 | /**
|
91 | * Replace all occurrences of from with to
|
92 | * @param from
|
93 | * @param to
|
94 | */
|
95 | export declare function replace(from: string | RegExp, to: string | RegExp): MapStream;
|
96 |
|
97 | /**
|
98 | * Convenience function for parsing JSON chunks. For newline separated JSON, use with es.split.
|
99 | * By default it logs parsing errors by console.error; for another behaviour, transforms created by es.parse({error: true})
|
100 | * will emit error events for exceptions thrown from JSON.parse, unmodified.
|
101 | */
|
102 | export declare function parse(): any;
|
103 |
|
104 | /**
|
105 | * convert javascript objects into lines of text. The text will have whitespace escaped and have a \n appended, so it will be compatible with es.parse
|
106 | */
|
107 | export declare function stringify(): MapStream;
|
108 |
|
109 | /**
|
110 | * create a readable stream (that respects pause) from an async function.
|
111 | *
|
112 | * @param asyncFunction
|
113 | */
|
114 | export declare function readable(asyncFunction: Function): MapStream;
|
115 |
|
116 | /**
|
117 | * Create a readable stream from an Array.
|
118 | *
|
119 | * @param array
|
120 | */
|
121 | export declare function readArray(array: any[]): MapStream;
|
122 |
|
123 | /**
|
124 | * create a writeable stream from a callback
|
125 | *
|
126 | * @param callback
|
127 | */
|
128 | export declare function writeArray(callback: Function): MapStream;
|
129 |
|
130 | /**
|
131 | * A stream that buffers all chunks when paused
|
132 | */
|
133 | // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
134 | export declare function pause(): MapStream | void;
|
135 |
|
136 | /**
|
137 | * Takes a writable stream and a readable stream and makes them appear as a readable writable stream.
|
138 | *
|
139 | * @param writeStream
|
140 | * @param readStream
|
141 | */
|
142 | export declare function duplex(writeStream: stream.Writable, readStream: stream.Readable): MapStream;
|
143 |
|
144 | /**
|
145 | * Create a through stream from a child process
|
146 | *
|
147 | * @param child_process
|
148 | */
|
149 | export declare function child(child_process: any): MapStream;
|
150 |
|
151 | /**
|
152 | * waits for stream to emit 'end'. joins chunks of a stream into a single string or buffer.
|
153 | * Takes an optional callback, which will be passed the complete string/buffer when it receives the 'end' event.
|
154 | *
|
155 | * @param callback
|
156 | */
|
157 | export declare function wait(callback: Function): MapStream;
|