@naturalcycles/js-lib 14.219.0 → 14.219.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.
@@ -4,11 +4,7 @@ export interface PMapOptions {
4
4
  /**
5
5
  * Number of concurrently pending promises returned by `mapper`.
6
6
  *
7
- * Defaults to 16.
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
  /**
@@ -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 = 16, errorMode = __1.ErrorMode.THROW_IMMEDIATELY, logger = console } = opt;
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: concurrency === Infinity or items.length <= concurrency
51
- if (concurrency === Infinity || items.length <= concurrency) {
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
@@ -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 = 16, errorMode = ErrorMode.THROW_IMMEDIATELY, logger = console } = opt;
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: concurrency === Infinity or items.length <= concurrency
48
- if (concurrency === Infinity || items.length <= concurrency) {
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.219.0",
3
+ "version": "14.219.1",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -5,11 +5,7 @@ export interface PMapOptions {
5
5
  /**
6
6
  * Number of concurrently pending promises returned by `mapper`.
7
7
  *
8
- * Defaults to 16.
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 = 16, errorMode = ErrorMode.THROW_IMMEDIATELY, logger = console } = opt
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: concurrency === Infinity or items.length <= concurrency
85
- if (concurrency === Infinity || items.length <= concurrency) {
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