@naturalcycles/nodejs-lib 12.57.0 → 12.58.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,5 +1,6 @@
|
|
|
1
1
|
import { AsyncMapper, AsyncPredicate, CommonLogger, ErrorMode } from '@naturalcycles/js-lib';
|
|
2
2
|
import { TransformTyped } from '../stream.model';
|
|
3
|
+
import { transformMapLegacy } from './legacy/transformMap';
|
|
3
4
|
export interface TransformMapOptions<IN = any, OUT = IN> {
|
|
4
5
|
/**
|
|
5
6
|
* Set true to support "multiMap" - possibility to return [] and emit 1 result for each item in the array.
|
|
@@ -44,6 +45,10 @@ export interface TransformMapOptions<IN = any, OUT = IN> {
|
|
|
44
45
|
logger?: CommonLogger;
|
|
45
46
|
}
|
|
46
47
|
export declare function notNullishPredicate(item: any): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Temporary export legacy transformMap, to debug 503 errors
|
|
50
|
+
*/
|
|
51
|
+
export declare const transformMap: typeof transformMapLegacy;
|
|
47
52
|
/**
|
|
48
53
|
* Like pMap, but for streams.
|
|
49
54
|
* Inspired by `through2`.
|
|
@@ -56,4 +61,4 @@ export declare function notNullishPredicate(item: any): boolean;
|
|
|
56
61
|
*
|
|
57
62
|
* If an Array is returned by `mapper` - it will be flattened and multiple results will be emitted from it. Tested by Array.isArray().
|
|
58
63
|
*/
|
|
59
|
-
export declare function
|
|
64
|
+
export declare function transformMapNew<IN = any, OUT = IN>(mapper: AsyncMapper<IN, OUT>, opt?: TransformMapOptions<IN, OUT>): TransformTyped<IN, OUT>;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformMap = exports.notNullishPredicate = void 0;
|
|
3
|
+
exports.transformMapNew = exports.transformMap = exports.notNullishPredicate = void 0;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
5
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
6
6
|
const colors_1 = require("../../colors");
|
|
7
|
+
const transformMap_1 = require("./legacy/transformMap");
|
|
7
8
|
function notNullishPredicate(item) {
|
|
8
9
|
return item !== undefined && item !== null;
|
|
9
10
|
}
|
|
10
11
|
exports.notNullishPredicate = notNullishPredicate;
|
|
12
|
+
/**
|
|
13
|
+
* Temporary export legacy transformMap, to debug 503 errors
|
|
14
|
+
*/
|
|
15
|
+
exports.transformMap = transformMap_1.transformMapLegacy;
|
|
11
16
|
/**
|
|
12
17
|
* Like pMap, but for streams.
|
|
13
18
|
* Inspired by `through2`.
|
|
@@ -20,7 +25,7 @@ exports.notNullishPredicate = notNullishPredicate;
|
|
|
20
25
|
*
|
|
21
26
|
* If an Array is returned by `mapper` - it will be flattened and multiple results will be emitted from it. Tested by Array.isArray().
|
|
22
27
|
*/
|
|
23
|
-
function
|
|
28
|
+
function transformMapNew(mapper, opt = {}) {
|
|
24
29
|
const { concurrency = 16, predicate = notNullishPredicate, errorMode = js_lib_1.ErrorMode.THROW_IMMEDIATELY, flattenArrayOutput, onError, beforeFinal, metric = 'stream', logger = console, } = opt;
|
|
25
30
|
let index = -1;
|
|
26
31
|
let isRejected = false;
|
|
@@ -100,4 +105,4 @@ function transformMap(mapper, opt = {}) {
|
|
|
100
105
|
logger.log(`${metric} ${final ? 'final ' : ''}errors: ${(0, colors_1.yellow)(errors)}`);
|
|
101
106
|
}
|
|
102
107
|
}
|
|
103
|
-
exports.
|
|
108
|
+
exports.transformMapNew = transformMapNew;
|
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from '@naturalcycles/js-lib'
|
|
11
11
|
import { yellow } from '../../colors'
|
|
12
12
|
import { TransformTyped } from '../stream.model'
|
|
13
|
+
import { transformMapLegacy } from './legacy/transformMap'
|
|
13
14
|
|
|
14
15
|
export interface TransformMapOptions<IN = any, OUT = IN> {
|
|
15
16
|
/**
|
|
@@ -66,6 +67,11 @@ export function notNullishPredicate(item: any): boolean {
|
|
|
66
67
|
return item !== undefined && item !== null
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Temporary export legacy transformMap, to debug 503 errors
|
|
72
|
+
*/
|
|
73
|
+
export const transformMap = transformMapLegacy
|
|
74
|
+
|
|
69
75
|
/**
|
|
70
76
|
* Like pMap, but for streams.
|
|
71
77
|
* Inspired by `through2`.
|
|
@@ -78,7 +84,7 @@ export function notNullishPredicate(item: any): boolean {
|
|
|
78
84
|
*
|
|
79
85
|
* If an Array is returned by `mapper` - it will be flattened and multiple results will be emitted from it. Tested by Array.isArray().
|
|
80
86
|
*/
|
|
81
|
-
export function
|
|
87
|
+
export function transformMapNew<IN = any, OUT = IN>(
|
|
82
88
|
mapper: AsyncMapper<IN, OUT>,
|
|
83
89
|
opt: TransformMapOptions<IN, OUT> = {},
|
|
84
90
|
): TransformTyped<IN, OUT> {
|