@naturalcycles/js-lib 14.219.0 → 14.219.2
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/promise/pMap.d.ts
CHANGED
|
@@ -4,11 +4,7 @@ export interface PMapOptions {
|
|
|
4
4
|
/**
|
|
5
5
|
* Number of concurrently pending promises returned by `mapper`.
|
|
6
6
|
*
|
|
7
|
-
* Defaults to
|
|
8
|
-
*
|
|
9
|
-
* It previously (and originally) defaulted to Infinity, which was later changed,
|
|
10
|
-
* because it's somewhat dangerous to run "infinite number of parallel promises".
|
|
11
|
-
* You can still emulate the old behavior by passing `Infinity`.
|
|
7
|
+
* Defaults to Infitity.
|
|
12
8
|
*/
|
|
13
9
|
concurrency?: number;
|
|
14
10
|
/**
|
package/dist/promise/pMap.js
CHANGED
|
@@ -41,14 +41,14 @@ async function pMap(iterable, mapper, opt = {}) {
|
|
|
41
41
|
const itemsLength = items.length;
|
|
42
42
|
if (itemsLength === 0)
|
|
43
43
|
return []; // short circuit
|
|
44
|
-
const { concurrency =
|
|
44
|
+
const { concurrency = Infinity, errorMode = __1.ErrorMode.THROW_IMMEDIATELY, logger = console } = opt;
|
|
45
45
|
// Special cases that are able to preserve async stack traces
|
|
46
46
|
// Special case: serial execution
|
|
47
47
|
if (concurrency === 1) {
|
|
48
48
|
return await pMap1(items, mapper, errorMode, logger);
|
|
49
49
|
}
|
|
50
|
-
// Special case:
|
|
51
|
-
if (
|
|
50
|
+
// Special case: items.length <= concurrency (including when concurrency === Infinity)
|
|
51
|
+
if (items.length <= concurrency) {
|
|
52
52
|
return await pMapAll(items, mapper, errorMode, logger);
|
|
53
53
|
}
|
|
54
54
|
// General case: execution with throttled concurrency
|
|
@@ -71,12 +71,12 @@ function _substringBeforeLast(s, delimiter) {
|
|
|
71
71
|
exports._substringBeforeLast = _substringBeforeLast;
|
|
72
72
|
function _substringAfter(s, delimiter) {
|
|
73
73
|
const pos = s.indexOf(delimiter);
|
|
74
|
-
return pos !== -1 ? s.slice(pos +
|
|
74
|
+
return pos !== -1 ? s.slice(pos + delimiter.length) : s;
|
|
75
75
|
}
|
|
76
76
|
exports._substringAfter = _substringAfter;
|
|
77
77
|
function _substringAfterLast(s, delimiter) {
|
|
78
78
|
const pos = s.lastIndexOf(delimiter);
|
|
79
|
-
return pos !== -1 ? s.slice(pos +
|
|
79
|
+
return pos !== -1 ? s.slice(pos + delimiter.length) : s;
|
|
80
80
|
}
|
|
81
81
|
exports._substringAfterLast = _substringAfterLast;
|
|
82
82
|
/**
|
package/dist-esm/promise/pMap.js
CHANGED
|
@@ -38,14 +38,14 @@ export async function pMap(iterable, mapper, opt = {}) {
|
|
|
38
38
|
const itemsLength = items.length;
|
|
39
39
|
if (itemsLength === 0)
|
|
40
40
|
return []; // short circuit
|
|
41
|
-
const { concurrency =
|
|
41
|
+
const { concurrency = Infinity, errorMode = ErrorMode.THROW_IMMEDIATELY, logger = console } = opt;
|
|
42
42
|
// Special cases that are able to preserve async stack traces
|
|
43
43
|
// Special case: serial execution
|
|
44
44
|
if (concurrency === 1) {
|
|
45
45
|
return await pMap1(items, mapper, errorMode, logger);
|
|
46
46
|
}
|
|
47
|
-
// Special case:
|
|
48
|
-
if (
|
|
47
|
+
// Special case: items.length <= concurrency (including when concurrency === Infinity)
|
|
48
|
+
if (items.length <= concurrency) {
|
|
49
49
|
return await pMapAll(items, mapper, errorMode, logger);
|
|
50
50
|
}
|
|
51
51
|
// General case: execution with throttled concurrency
|
|
@@ -59,11 +59,11 @@ export function _substringBeforeLast(s, delimiter) {
|
|
|
59
59
|
}
|
|
60
60
|
export function _substringAfter(s, delimiter) {
|
|
61
61
|
const pos = s.indexOf(delimiter);
|
|
62
|
-
return pos !== -1 ? s.slice(pos +
|
|
62
|
+
return pos !== -1 ? s.slice(pos + delimiter.length) : s;
|
|
63
63
|
}
|
|
64
64
|
export function _substringAfterLast(s, delimiter) {
|
|
65
65
|
const pos = s.lastIndexOf(delimiter);
|
|
66
|
-
return pos !== -1 ? s.slice(pos +
|
|
66
|
+
return pos !== -1 ? s.slice(pos + delimiter.length) : s;
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Returns the substring between LAST `leftDelimiter` and then FIRST `rightDelimiter`.
|
package/package.json
CHANGED
package/src/promise/pMap.ts
CHANGED
|
@@ -5,11 +5,7 @@ export interface PMapOptions {
|
|
|
5
5
|
/**
|
|
6
6
|
* Number of concurrently pending promises returned by `mapper`.
|
|
7
7
|
*
|
|
8
|
-
* Defaults to
|
|
9
|
-
*
|
|
10
|
-
* It previously (and originally) defaulted to Infinity, which was later changed,
|
|
11
|
-
* because it's somewhat dangerous to run "infinite number of parallel promises".
|
|
12
|
-
* You can still emulate the old behavior by passing `Infinity`.
|
|
8
|
+
* Defaults to Infitity.
|
|
13
9
|
*/
|
|
14
10
|
concurrency?: number
|
|
15
11
|
|
|
@@ -73,7 +69,7 @@ export async function pMap<IN, OUT>(
|
|
|
73
69
|
const itemsLength = items.length
|
|
74
70
|
if (itemsLength === 0) return [] // short circuit
|
|
75
71
|
|
|
76
|
-
const { concurrency =
|
|
72
|
+
const { concurrency = Infinity, errorMode = ErrorMode.THROW_IMMEDIATELY, logger = console } = opt
|
|
77
73
|
|
|
78
74
|
// Special cases that are able to preserve async stack traces
|
|
79
75
|
// Special case: serial execution
|
|
@@ -81,8 +77,8 @@ export async function pMap<IN, OUT>(
|
|
|
81
77
|
return await pMap1(items, mapper, errorMode, logger)
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
// Special case:
|
|
85
|
-
if (
|
|
80
|
+
// Special case: items.length <= concurrency (including when concurrency === Infinity)
|
|
81
|
+
if (items.length <= concurrency) {
|
|
86
82
|
return await pMapAll(items, mapper, errorMode, logger)
|
|
87
83
|
}
|
|
88
84
|
|
|
@@ -65,12 +65,12 @@ export function _substringBeforeLast(s: string, delimiter: string): string {
|
|
|
65
65
|
|
|
66
66
|
export function _substringAfter(s: string, delimiter: string): string {
|
|
67
67
|
const pos = s.indexOf(delimiter)
|
|
68
|
-
return pos !== -1 ? s.slice(pos +
|
|
68
|
+
return pos !== -1 ? s.slice(pos + delimiter.length) : s
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export function _substringAfterLast(s: string, delimiter: string): string {
|
|
72
72
|
const pos = s.lastIndexOf(delimiter)
|
|
73
|
-
return pos !== -1 ? s.slice(pos +
|
|
73
|
+
return pos !== -1 ? s.slice(pos + delimiter.length) : s
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|