@naturalcycles/nodejs-lib 15.18.0 → 15.18.1
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.
|
@@ -77,6 +77,9 @@ export function transformMap(mapper, opt = {}) {
|
|
|
77
77
|
const currentIndex = ++index;
|
|
78
78
|
try {
|
|
79
79
|
const res = await mapper(chunk, currentIndex);
|
|
80
|
+
// Check for isSettled again, as it may happen while mapper was running
|
|
81
|
+
if (isSettled)
|
|
82
|
+
return cb();
|
|
80
83
|
// todo: consider retiring flattenArrayOutput from here
|
|
81
84
|
// and implementing it as a separate .flat transform/operator
|
|
82
85
|
const resInput = (flattenArrayOutput && Array.isArray(res) ? res : [res]);
|
|
@@ -89,6 +92,8 @@ export function transformMap(mapper, opt = {}) {
|
|
|
89
92
|
if (r === SKIP)
|
|
90
93
|
return;
|
|
91
94
|
if (await predicate(r, currentIndex)) {
|
|
95
|
+
if (isSettled)
|
|
96
|
+
return END; // isSettled could have happened in parallel
|
|
92
97
|
countOut++;
|
|
93
98
|
this.push(r);
|
|
94
99
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "15.18.
|
|
4
|
+
"version": "15.18.1",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@naturalcycles/js-lib": "^15",
|
|
7
7
|
"@types/js-yaml": "^4",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/through2-concurrent": "^2",
|
|
26
|
-
"@naturalcycles/dev-lib": "
|
|
26
|
+
"@naturalcycles/dev-lib": "19.27.0"
|
|
27
27
|
},
|
|
28
28
|
"exports": {
|
|
29
29
|
".": "./dist/index.js",
|
|
@@ -204,6 +204,8 @@ export function transformMap<IN = any, OUT = IN>(
|
|
|
204
204
|
|
|
205
205
|
try {
|
|
206
206
|
const res: OUT | typeof SKIP | typeof END = await mapper(chunk, currentIndex)
|
|
207
|
+
// Check for isSettled again, as it may happen while mapper was running
|
|
208
|
+
if (isSettled) return cb()
|
|
207
209
|
// todo: consider retiring flattenArrayOutput from here
|
|
208
210
|
// and implementing it as a separate .flat transform/operator
|
|
209
211
|
const resInput = (flattenArrayOutput && Array.isArray(res) ? res : [res]) as (
|
|
@@ -220,6 +222,7 @@ export function transformMap<IN = any, OUT = IN>(
|
|
|
220
222
|
}
|
|
221
223
|
if (r === SKIP) return
|
|
222
224
|
if (await predicate(r, currentIndex)) {
|
|
225
|
+
if (isSettled) return END // isSettled could have happened in parallel
|
|
223
226
|
countOut++
|
|
224
227
|
this.push(r)
|
|
225
228
|
}
|