@naturalcycles/nodejs-lib 15.27.1 → 15.27.3
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/ndjson/createReadStreamAsNDJson.js +1 -1
- package/dist/stream/pipeline.d.ts +1 -1
- package/dist/stream/transform/transformFork.d.ts +1 -1
- package/dist/stream/transform/transformFork.js +1 -2
- package/package.json +1 -1
- package/src/stream/ndjson/createReadStreamAsNDJson.ts +1 -1
- package/src/stream/pipeline.ts +1 -1
- package/src/stream/transform/transformFork.ts +3 -4
|
@@ -21,7 +21,7 @@ export function createReadStreamAsNDJson(inputPath) {
|
|
|
21
21
|
.createReadStream(inputPath, {
|
|
22
22
|
highWaterMark: 64 * 1024, // no observed speedup
|
|
23
23
|
})
|
|
24
|
-
.on('error', err => stream.
|
|
24
|
+
.on('error', err => stream.destroy(err));
|
|
25
25
|
if (inputPath.endsWith('.gz')) {
|
|
26
26
|
stream = stream.pipe(createUnzip({
|
|
27
27
|
chunkSize: 64 * 1024, // speedup from ~3200 to 3800 rps!
|
|
@@ -69,7 +69,7 @@ export declare class Pipeline<T> {
|
|
|
69
69
|
* Not type safe! Prefer using singular `transform()` multiple times for type safety.
|
|
70
70
|
*/
|
|
71
71
|
transformMany<TO>(transforms: Transform[]): Pipeline<TO>;
|
|
72
|
-
fork
|
|
72
|
+
fork(fn: (pipeline: Pipeline<T>) => Promise<void>, opt?: TransformOptions): this;
|
|
73
73
|
/**
|
|
74
74
|
* Utility method just to conveniently type-cast the current Pipeline type.
|
|
75
75
|
* No runtime effect.
|
|
@@ -7,4 +7,4 @@ import type { TransformOptions, TransformTyped } from '../stream.model.js';
|
|
|
7
7
|
*
|
|
8
8
|
* @experimental
|
|
9
9
|
*/
|
|
10
|
-
export declare function transformFork<T
|
|
10
|
+
export declare function transformFork<T>(fn: (pipeline: Pipeline<T>) => Promise<void>, opt?: TransformOptions): TransformTyped<T, T>;
|
|
@@ -24,8 +24,7 @@ export function transformFork(fn, opt = {}) {
|
|
|
24
24
|
lock = undefined;
|
|
25
25
|
lockCopy.resolve();
|
|
26
26
|
});
|
|
27
|
-
|
|
28
|
-
void p.run().then(() => {
|
|
27
|
+
void fn(Pipeline.from(fork)).then(() => {
|
|
29
28
|
logger.log('TransformFork: done');
|
|
30
29
|
});
|
|
31
30
|
return new Transform({
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ export function createReadStreamAsNDJson<ROW = any>(inputPath: string): Readable
|
|
|
25
25
|
.createReadStream(inputPath, {
|
|
26
26
|
highWaterMark: 64 * 1024, // no observed speedup
|
|
27
27
|
})
|
|
28
|
-
.on('error', err => stream.
|
|
28
|
+
.on('error', err => stream.destroy(err))
|
|
29
29
|
|
|
30
30
|
if (inputPath.endsWith('.gz')) {
|
|
31
31
|
stream = stream.pipe(
|
package/src/stream/pipeline.ts
CHANGED
|
@@ -235,7 +235,7 @@ export class Pipeline<T> {
|
|
|
235
235
|
return this as any
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
fork
|
|
238
|
+
fork(fn: (pipeline: Pipeline<T>) => Promise<void>, opt?: TransformOptions): this {
|
|
239
239
|
this.transforms.push(transformFork(fn, opt))
|
|
240
240
|
return this
|
|
241
241
|
}
|
|
@@ -12,8 +12,8 @@ import type { TransformOptions, TransformTyped } from '../stream.model.js'
|
|
|
12
12
|
*
|
|
13
13
|
* @experimental
|
|
14
14
|
*/
|
|
15
|
-
export function transformFork<T
|
|
16
|
-
fn: (pipeline: Pipeline<T>) =>
|
|
15
|
+
export function transformFork<T>(
|
|
16
|
+
fn: (pipeline: Pipeline<T>) => Promise<void>,
|
|
17
17
|
opt: TransformOptions = {},
|
|
18
18
|
): TransformTyped<T, T> {
|
|
19
19
|
const { objectMode = true, highWaterMark } = opt
|
|
@@ -31,8 +31,7 @@ export function transformFork<T, FORK>(
|
|
|
31
31
|
lockCopy.resolve()
|
|
32
32
|
})
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
void p.run().then(() => {
|
|
34
|
+
void fn(Pipeline.from<T>(fork)).then(() => {
|
|
36
35
|
logger.log('TransformFork: done')
|
|
37
36
|
})
|
|
38
37
|
|