@naturalcycles/nodejs-lib 15.110.0 → 15.112.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Transform } from 'node:stream';
|
|
2
2
|
import type { ReadableStream as WebReadableStream } from 'node:stream/web';
|
|
3
3
|
import type { ZlibOptions, ZstdOptions } from 'node:zlib';
|
|
4
|
-
import type { AbortableAsyncMapper, AsyncIndexedMapper, AsyncPredicate, END, IndexedMapper, Integer, NonNegativeInteger, PositiveInteger, Predicate, SKIP } from '@naturalcycles/js-lib/types';
|
|
4
|
+
import type { AbortableAsyncMapper, AbortableMapper, AsyncIndexedMapper, AsyncPredicate, END, IndexedMapper, Integer, NonNegativeInteger, PositiveInteger, Predicate, SKIP } from '@naturalcycles/js-lib/types';
|
|
5
5
|
import type { ReadableTyped, TransformOptions, TransformTyped, WritableTyped } from './stream.model.js';
|
|
6
6
|
import type { TransformLogProgressOptions } from './transform/transformLogProgress.js';
|
|
7
7
|
import type { TransformMapOptions } from './transform/transformMap.js';
|
|
@@ -68,8 +68,8 @@ export declare class Pipeline<T = unknown> {
|
|
|
68
68
|
filter(asyncPredicate: AsyncPredicate<T>, opt?: TransformMapOptions): this;
|
|
69
69
|
filterSync(predicate: Predicate<T>, opt?: TransformOptions): this;
|
|
70
70
|
offset(opt: TransformOffsetOptions): this;
|
|
71
|
-
tap(fn: AsyncIndexedMapper<T,
|
|
72
|
-
tapSync(fn: IndexedMapper<T,
|
|
71
|
+
tap(fn: AsyncIndexedMapper<T, void>, opt?: TransformOptions): this;
|
|
72
|
+
tapSync(fn: IndexedMapper<T, void>, opt?: TransformOptions): this;
|
|
73
73
|
throttle(opt: TransformThrottleOptions): this;
|
|
74
74
|
throttleByRSS(opt: TransformThrottleByRSSOptions): this;
|
|
75
75
|
/**
|
|
@@ -113,7 +113,7 @@ export declare class Pipeline<T = unknown> {
|
|
|
113
113
|
*/
|
|
114
114
|
toNDJsonFile(outputFilePath: string, level?: Integer): Promise<void>;
|
|
115
115
|
to(destination: WritableTyped<T>): Promise<void>;
|
|
116
|
-
forEach(fn:
|
|
117
|
-
forEachSync(fn:
|
|
116
|
+
forEach(fn: AbortableAsyncMapper<T, void>, opt?: TransformMapOptions<T, void> & TransformLogProgressOptions<T>): Promise<void>;
|
|
117
|
+
forEachSync(fn: AbortableMapper<T, void>, opt?: TransformMapSyncOptions<T, void> & TransformLogProgressOptions<T>): Promise<void>;
|
|
118
118
|
run(): Promise<void>;
|
|
119
119
|
}
|
package/package.json
CHANGED
package/src/stream/pipeline.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { createAbortableSignal } from '@naturalcycles/js-lib'
|
|
|
8
8
|
import { _passthroughPredicate } from '@naturalcycles/js-lib/types'
|
|
9
9
|
import type {
|
|
10
10
|
AbortableAsyncMapper,
|
|
11
|
+
AbortableMapper,
|
|
11
12
|
AsyncIndexedMapper,
|
|
12
13
|
AsyncPredicate,
|
|
13
14
|
END,
|
|
@@ -236,12 +237,12 @@ export class Pipeline<T = unknown> {
|
|
|
236
237
|
return this
|
|
237
238
|
}
|
|
238
239
|
|
|
239
|
-
tap(fn: AsyncIndexedMapper<T,
|
|
240
|
+
tap(fn: AsyncIndexedMapper<T, void>, opt?: TransformOptions): this {
|
|
240
241
|
this.transforms.push(transformTap(fn, opt))
|
|
241
242
|
return this
|
|
242
243
|
}
|
|
243
244
|
|
|
244
|
-
tapSync(fn: IndexedMapper<T,
|
|
245
|
+
tapSync(fn: IndexedMapper<T, void>, opt?: TransformOptions): this {
|
|
245
246
|
this.transforms.push(transformTapSync(fn, opt))
|
|
246
247
|
return this
|
|
247
248
|
}
|
|
@@ -420,7 +421,7 @@ export class Pipeline<T = unknown> {
|
|
|
420
421
|
}
|
|
421
422
|
|
|
422
423
|
async forEach(
|
|
423
|
-
fn:
|
|
424
|
+
fn: AbortableAsyncMapper<T, void>,
|
|
424
425
|
opt: TransformMapOptions<T, void> & TransformLogProgressOptions<T> = {},
|
|
425
426
|
): Promise<void> {
|
|
426
427
|
this.transforms.push(
|
|
@@ -437,7 +438,7 @@ export class Pipeline<T = unknown> {
|
|
|
437
438
|
}
|
|
438
439
|
|
|
439
440
|
async forEachSync(
|
|
440
|
-
fn:
|
|
441
|
+
fn: AbortableMapper<T, void>,
|
|
441
442
|
opt: TransformMapSyncOptions<T, void> & TransformLogProgressOptions<T> = {},
|
|
442
443
|
): Promise<void> {
|
|
443
444
|
this.transforms.push(
|
|
@@ -414,7 +414,7 @@ export class JSchema<OUT, Opt>
|
|
|
414
414
|
* The usage of this function is discouraged as it defeats the purpose of having type-safe validation.
|
|
415
415
|
*/
|
|
416
416
|
castAs<T>(): JSchema<T, Opt> {
|
|
417
|
-
return this as
|
|
417
|
+
return this as any as JSchema<T, Opt>
|
|
418
418
|
}
|
|
419
419
|
|
|
420
420
|
/**
|
|
@@ -529,7 +529,7 @@ export class JSchema<OUT, Opt>
|
|
|
529
529
|
const clone = this.cloneAndUpdateSchema({
|
|
530
530
|
postValidation: fn,
|
|
531
531
|
})
|
|
532
|
-
return clone as
|
|
532
|
+
return clone as any as JSchema<OUT2, Opt>
|
|
533
533
|
}
|
|
534
534
|
|
|
535
535
|
/**
|
|
@@ -557,7 +557,7 @@ export class JBuilder<OUT, Opt> extends JSchema<OUT, Opt> {
|
|
|
557
557
|
* The usage of this function is discouraged as it defeats the purpose of having type-safe validation.
|
|
558
558
|
*/
|
|
559
559
|
override castAs<T>(): JBuilder<T, Opt> {
|
|
560
|
-
return this as
|
|
560
|
+
return this as any as JBuilder<T, Opt>
|
|
561
561
|
}
|
|
562
562
|
|
|
563
563
|
$schema($schema: string): this {
|
|
@@ -683,7 +683,7 @@ export class JBuilder<OUT, Opt> extends JSchema<OUT, Opt> {
|
|
|
683
683
|
const { customValidations = [] } = this.schema
|
|
684
684
|
return this.cloneAndUpdateSchema({
|
|
685
685
|
customValidations: [...customValidations, validator],
|
|
686
|
-
}) as
|
|
686
|
+
}) as any as JBuilder<OUT2, Opt>
|
|
687
687
|
}
|
|
688
688
|
|
|
689
689
|
/**
|
|
@@ -700,7 +700,7 @@ export class JBuilder<OUT, Opt> extends JSchema<OUT, Opt> {
|
|
|
700
700
|
const { customConversions = [] } = this.schema
|
|
701
701
|
return this.cloneAndUpdateSchema({
|
|
702
702
|
customConversions: [...customConversions, converter],
|
|
703
|
-
}) as
|
|
703
|
+
}) as any as JBuilder<OUT2, Opt>
|
|
704
704
|
}
|
|
705
705
|
}
|
|
706
706
|
|
|
@@ -783,7 +783,7 @@ export class JString<
|
|
|
783
783
|
}
|
|
784
784
|
|
|
785
785
|
branded<B extends string>(): JString<B, Opt> {
|
|
786
|
-
return this as
|
|
786
|
+
return this as any as JString<B, Opt>
|
|
787
787
|
}
|
|
788
788
|
|
|
789
789
|
/**
|
|
@@ -934,7 +934,7 @@ export class JNumber<
|
|
|
934
934
|
}
|
|
935
935
|
|
|
936
936
|
branded<B extends number>(): JNumber<B, Opt> {
|
|
937
|
-
return this as
|
|
937
|
+
return this as any as JNumber<B, Opt>
|
|
938
938
|
}
|
|
939
939
|
|
|
940
940
|
multipleOf(multipleOf: number): this {
|
|
@@ -1131,7 +1131,7 @@ export class JObject<OUT extends AnyObject, Opt extends boolean = false> extends
|
|
|
1131
1131
|
const clone = this.clone()
|
|
1132
1132
|
mergeJsonSchemaObjects(clone.schema as any, other.schema as any)
|
|
1133
1133
|
_objectAssign(clone.schema, { hasIsOfTypeCheck: false })
|
|
1134
|
-
return clone as
|
|
1134
|
+
return clone as JObject<OUT & OUT2, false>
|
|
1135
1135
|
}
|
|
1136
1136
|
|
|
1137
1137
|
/**
|
|
@@ -1229,7 +1229,7 @@ export class JObjectInfer<
|
|
|
1229
1229
|
// the new schema loses that quality.
|
|
1230
1230
|
_objectAssign(newBuilder.schema, { hasIsOfTypeCheck: false })
|
|
1231
1231
|
|
|
1232
|
-
return newBuilder as
|
|
1232
|
+
return newBuilder as any as JObjectInfer<
|
|
1233
1233
|
{
|
|
1234
1234
|
[K in keyof PROPS | keyof NEW_PROPS]: K extends keyof NEW_PROPS
|
|
1235
1235
|
? NEW_PROPS[K]
|
|
@@ -1321,7 +1321,7 @@ export class JEnum<
|
|
|
1321
1321
|
}
|
|
1322
1322
|
|
|
1323
1323
|
branded<B extends OUT>(): JEnum<B, Opt> {
|
|
1324
|
-
return this as
|
|
1324
|
+
return this as any as JEnum<B, Opt>
|
|
1325
1325
|
}
|
|
1326
1326
|
}
|
|
1327
1327
|
|