@naturalcycles/nodejs-lib 15.24.0 → 15.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/stream/pipeline.d.ts +2 -0
- package/dist/stream/pipeline.js +14 -0
- package/package.json +1 -1
- package/src/stream/pipeline.ts +18 -0
|
@@ -81,6 +81,8 @@ export declare class Pipeline<T> {
|
|
|
81
81
|
*/
|
|
82
82
|
toNDJson(): Pipeline<Uint8Array>;
|
|
83
83
|
parseNDJson<TO = unknown>(this: Pipeline<Uint8Array>): Pipeline<TO>;
|
|
84
|
+
splitOnNewline(this: Pipeline<Uint8Array>): Pipeline<Buffer>;
|
|
85
|
+
parseJson<TO = unknown>(this: Pipeline<Buffer> | Pipeline<Uint8Array> | Pipeline<string>): Pipeline<TO>;
|
|
84
86
|
gzip(this: Pipeline<Uint8Array>, opt?: ZlibOptions): Pipeline<Uint8Array>;
|
|
85
87
|
gunzip(this: Pipeline<Uint8Array>, opt?: ZlibOptions): Pipeline<Uint8Array>;
|
|
86
88
|
toArray(opt?: TransformOptions): Promise<T[]>;
|
package/dist/stream/pipeline.js
CHANGED
|
@@ -188,6 +188,20 @@ export class Pipeline {
|
|
|
188
188
|
this.objectMode = true;
|
|
189
189
|
return this;
|
|
190
190
|
}
|
|
191
|
+
splitOnNewline() {
|
|
192
|
+
// Input: objectMode=false - binary stream
|
|
193
|
+
// Output: objectMode=true - stream of Buffer objects (which are also strings?)
|
|
194
|
+
this.transforms.push(transformSplitOnNewline());
|
|
195
|
+
this.objectMode = true;
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
parseJson() {
|
|
199
|
+
// Input: objectMode=false - takes a stream of strings one by one
|
|
200
|
+
// Output: objectMode=true - stream of json-parsed Objects
|
|
201
|
+
this.transforms.push(transformJsonParse());
|
|
202
|
+
this.objectMode = true;
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
191
205
|
gzip(opt) {
|
|
192
206
|
this.transforms.push(createGzip(opt));
|
|
193
207
|
this.objectMode = false;
|
package/package.json
CHANGED
package/src/stream/pipeline.ts
CHANGED
|
@@ -257,6 +257,24 @@ export class Pipeline<T> {
|
|
|
257
257
|
return this as any
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
+
splitOnNewline(this: Pipeline<Uint8Array>): Pipeline<Buffer> {
|
|
261
|
+
// Input: objectMode=false - binary stream
|
|
262
|
+
// Output: objectMode=true - stream of Buffer objects (which are also strings?)
|
|
263
|
+
this.transforms.push(transformSplitOnNewline())
|
|
264
|
+
this.objectMode = true
|
|
265
|
+
return this as any
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
parseJson<TO = unknown>(
|
|
269
|
+
this: Pipeline<Buffer> | Pipeline<Uint8Array> | Pipeline<string>,
|
|
270
|
+
): Pipeline<TO> {
|
|
271
|
+
// Input: objectMode=false - takes a stream of strings one by one
|
|
272
|
+
// Output: objectMode=true - stream of json-parsed Objects
|
|
273
|
+
this.transforms.push(transformJsonParse())
|
|
274
|
+
this.objectMode = true
|
|
275
|
+
return this as any
|
|
276
|
+
}
|
|
277
|
+
|
|
260
278
|
gzip(this: Pipeline<Uint8Array>, opt?: ZlibOptions): Pipeline<Uint8Array> {
|
|
261
279
|
this.transforms.push(createGzip(opt))
|
|
262
280
|
this.objectMode = false
|