@dereekb/util 10.0.19 → 10.0.21

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/index.cjs.js CHANGED
@@ -1774,6 +1774,84 @@ var addToUnscopables = addToUnscopables$2;
1774
1774
  // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
1775
1775
  addToUnscopables('flat');
1776
1776
 
1777
+ var aCallable$6 = aCallable$a;
1778
+ var toObject$3 = toObject$7;
1779
+ var IndexedObject$1 = indexedObject;
1780
+ var lengthOfArrayLike$2 = lengthOfArrayLike$6;
1781
+
1782
+ var $TypeError$9 = TypeError;
1783
+
1784
+ // `Array.prototype.{ reduce, reduceRight }` methods implementation
1785
+ var createMethod$2 = function (IS_RIGHT) {
1786
+ return function (that, callbackfn, argumentsLength, memo) {
1787
+ var O = toObject$3(that);
1788
+ var self = IndexedObject$1(O);
1789
+ var length = lengthOfArrayLike$2(O);
1790
+ aCallable$6(callbackfn);
1791
+ var index = IS_RIGHT ? length - 1 : 0;
1792
+ var i = IS_RIGHT ? -1 : 1;
1793
+ if (argumentsLength < 2) while (true) {
1794
+ if (index in self) {
1795
+ memo = self[index];
1796
+ index += i;
1797
+ break;
1798
+ }
1799
+ index += i;
1800
+ if (IS_RIGHT ? index < 0 : length <= index) {
1801
+ throw new $TypeError$9('Reduce of empty array with no initial value');
1802
+ }
1803
+ }
1804
+ for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
1805
+ memo = callbackfn(memo, self[index], index, O);
1806
+ }
1807
+ return memo;
1808
+ };
1809
+ };
1810
+
1811
+ var arrayReduce = {
1812
+ // `Array.prototype.reduce` method
1813
+ // https://tc39.es/ecma262/#sec-array.prototype.reduce
1814
+ left: createMethod$2(false),
1815
+ // `Array.prototype.reduceRight` method
1816
+ // https://tc39.es/ecma262/#sec-array.prototype.reduceright
1817
+ right: createMethod$2(true)
1818
+ };
1819
+
1820
+ var fails$d = fails$p;
1821
+
1822
+ var arrayMethodIsStrict$2 = function (METHOD_NAME, argument) {
1823
+ var method = [][METHOD_NAME];
1824
+ return !!method && fails$d(function () {
1825
+ // eslint-disable-next-line no-useless-call -- required for testing
1826
+ method.call(null, argument || function () { return 1; }, 1);
1827
+ });
1828
+ };
1829
+
1830
+ var global$c = global$o;
1831
+ var classof$4 = classofRaw$2;
1832
+
1833
+ var engineIsNode = classof$4(global$c.process) === 'process';
1834
+
1835
+ var $$f = _export;
1836
+ var $reduce = arrayReduce.left;
1837
+ var arrayMethodIsStrict$1 = arrayMethodIsStrict$2;
1838
+ var CHROME_VERSION = engineV8Version;
1839
+ var IS_NODE$4 = engineIsNode;
1840
+
1841
+ // Chrome 80-82 has a critical bug
1842
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
1843
+ var CHROME_BUG = !IS_NODE$4 && CHROME_VERSION > 79 && CHROME_VERSION < 83;
1844
+ var FORCED$2 = CHROME_BUG || !arrayMethodIsStrict$1('reduce');
1845
+
1846
+ // `Array.prototype.reduce` method
1847
+ // https://tc39.es/ecma262/#sec-array.prototype.reduce
1848
+ $$f({ target: 'Array', proto: true, forced: FORCED$2 }, {
1849
+ reduce: function reduce(callbackfn /* , initialValue */) {
1850
+ var length = arguments.length;
1851
+ return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
1852
+ }
1853
+ });
1854
+
1777
1855
  // MARK: Functions
1778
1856
  /**
1779
1857
  * Converts the input value to an array containing itself, or returns itself if it is an array.
@@ -1969,6 +2047,15 @@ function forEachWithArray(array, forEach) {
1969
2047
  }
1970
2048
  return array;
1971
2049
  }
2050
+ /**
2051
+ * Counts all the values in a nested array.
2052
+ *
2053
+ * @param array
2054
+ * @returns
2055
+ */
2056
+ function countAllInNestedArray(array) {
2057
+ return array.reduce((acc, curr) => acc + curr.length, 0);
2058
+ }
1972
2059
  // MARK: Compat
1973
2060
  /**
1974
2061
  * @deprecated Use mergeArraysIntoArray() instead. Will be removed in v10.1.
@@ -1983,12 +2070,12 @@ const mergeArrayIntoArray = pushArrayItemsIntoArray;
1983
2070
  */
1984
2071
  const mergeArrayOrValueIntoArray = pushItemOrArrayItemsIntoArray;
1985
2072
 
1986
- var classof$4 = classof$6;
2073
+ var classof$3 = classof$6;
1987
2074
 
1988
2075
  var $String$1 = String;
1989
2076
 
1990
2077
  var toString$c = function (argument) {
1991
- if (classof$4(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string');
2078
+ if (classof$3(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string');
1992
2079
  return $String$1(argument);
1993
2080
  };
1994
2081
 
@@ -2001,9 +2088,9 @@ var defineBuiltInAccessor$2 = function (target, name, descriptor) {
2001
2088
  return defineProperty$2.f(target, name, descriptor);
2002
2089
  };
2003
2090
 
2004
- var $$f = _export;
2091
+ var $$e = _export;
2005
2092
  var DESCRIPTORS$4 = descriptors;
2006
- var global$c = global$o;
2093
+ var global$b = global$o;
2007
2094
  var uncurryThis$f = functionUncurryThis;
2008
2095
  var hasOwn$3 = hasOwnProperty_1;
2009
2096
  var isCallable$7 = isCallable$n;
@@ -2012,7 +2099,7 @@ var toString$b = toString$c;
2012
2099
  var defineBuiltInAccessor$1 = defineBuiltInAccessor$2;
2013
2100
  var copyConstructorProperties = copyConstructorProperties$2;
2014
2101
 
2015
- var NativeSymbol = global$c.Symbol;
2102
+ var NativeSymbol = global$b.Symbol;
2016
2103
  var SymbolPrototype = NativeSymbol && NativeSymbol.prototype;
2017
2104
 
2018
2105
  if (DESCRIPTORS$4 && isCallable$7(NativeSymbol) && (!('description' in SymbolPrototype) ||
@@ -2053,7 +2140,7 @@ if (DESCRIPTORS$4 && isCallable$7(NativeSymbol) && (!('description' in SymbolPro
2053
2140
  }
2054
2141
  });
2055
2142
 
2056
- $$f({ global: true, constructor: true, forced: true }, {
2143
+ $$e({ global: true, constructor: true, forced: true }, {
2057
2144
  Symbol: SymbolWrapper
2058
2145
  });
2059
2146
  }
@@ -2658,12 +2745,12 @@ function setsAreEquivalent(a, b) {
2658
2745
  var DESCRIPTORS$3 = descriptors;
2659
2746
  var uncurryThis$e = functionUncurryThis;
2660
2747
  var call$e = functionCall;
2661
- var fails$d = fails$p;
2748
+ var fails$c = fails$p;
2662
2749
  var objectKeys = objectKeys$2;
2663
2750
  var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
2664
2751
  var propertyIsEnumerableModule = objectPropertyIsEnumerable;
2665
- var toObject$3 = toObject$7;
2666
- var IndexedObject$1 = indexedObject;
2752
+ var toObject$2 = toObject$7;
2753
+ var IndexedObject = indexedObject;
2667
2754
 
2668
2755
  // eslint-disable-next-line es/no-object-assign -- safe
2669
2756
  var $assign = Object.assign;
@@ -2673,7 +2760,7 @@ var concat$1 = uncurryThis$e([].concat);
2673
2760
 
2674
2761
  // `Object.assign` method
2675
2762
  // https://tc39.es/ecma262/#sec-object.assign
2676
- var objectAssign = !$assign || fails$d(function () {
2763
+ var objectAssign = !$assign || fails$c(function () {
2677
2764
  // should have correct order of operations (Edge bug)
2678
2765
  if (DESCRIPTORS$3 && $assign({ b: 1 }, $assign(defineProperty$1({}, 'a', {
2679
2766
  enumerable: true,
@@ -2694,13 +2781,13 @@ var objectAssign = !$assign || fails$d(function () {
2694
2781
  alphabet.split('').forEach(function (chr) { B[chr] = chr; });
2695
2782
  return $assign({}, A)[symbol] !== 7 || objectKeys($assign({}, B)).join('') !== alphabet;
2696
2783
  }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
2697
- var T = toObject$3(target);
2784
+ var T = toObject$2(target);
2698
2785
  var argumentsLength = arguments.length;
2699
2786
  var index = 1;
2700
2787
  var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
2701
2788
  var propertyIsEnumerable = propertyIsEnumerableModule.f;
2702
2789
  while (argumentsLength > index) {
2703
- var S = IndexedObject$1(arguments[index++]);
2790
+ var S = IndexedObject(arguments[index++]);
2704
2791
  var keys = getOwnPropertySymbols ? concat$1(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
2705
2792
  var length = keys.length;
2706
2793
  var j = 0;
@@ -2712,13 +2799,13 @@ var objectAssign = !$assign || fails$d(function () {
2712
2799
  } return T;
2713
2800
  } : $assign;
2714
2801
 
2715
- var $$e = _export;
2802
+ var $$d = _export;
2716
2803
  var assign = objectAssign;
2717
2804
 
2718
2805
  // `Object.assign` method
2719
2806
  // https://tc39.es/ecma262/#sec-object.assign
2720
2807
  // eslint-disable-next-line es/no-object-assign -- required for testing
2721
- $$e({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
2808
+ $$d({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
2722
2809
  assign: assign
2723
2810
  });
2724
2811
 
@@ -3210,10 +3297,10 @@ const BooleanStringKeyArrayUtilityInstance = new BooleanKeyArrayUtilityInstance(
3210
3297
 
3211
3298
  var tryToString$3 = tryToString$5;
3212
3299
 
3213
- var $TypeError$9 = TypeError;
3300
+ var $TypeError$8 = TypeError;
3214
3301
 
3215
3302
  var deletePropertyOrThrow$1 = function (O, P) {
3216
- if (!delete O[P]) throw new $TypeError$9('Cannot delete property ' + tryToString$3(P) + ' of ' + tryToString$3(O));
3303
+ if (!delete O[P]) throw new $TypeError$8('Cannot delete property ' + tryToString$3(P) + ' of ' + tryToString$3(O));
3217
3304
  };
3218
3305
 
3219
3306
  var uncurryThis$d = functionUncurryThis;
@@ -3262,16 +3349,6 @@ var sort = function (array, comparefn) {
3262
3349
 
3263
3350
  var arraySort = sort;
3264
3351
 
3265
- var fails$c = fails$p;
3266
-
3267
- var arrayMethodIsStrict$2 = function (METHOD_NAME, argument) {
3268
- var method = [][METHOD_NAME];
3269
- return !!method && fails$c(function () {
3270
- // eslint-disable-next-line no-useless-call -- required for testing
3271
- method.call(null, argument || function () { return 1; }, 1);
3272
- });
3273
- };
3274
-
3275
3352
  var userAgent$4 = engineUserAgent;
3276
3353
 
3277
3354
  var firefox = userAgent$4.match(/firefox\/(\d+)/i);
@@ -3288,16 +3365,16 @@ var webkit = userAgent$3.match(/AppleWebKit\/(\d+)\./);
3288
3365
 
3289
3366
  var engineWebkitVersion = !!webkit && +webkit[1];
3290
3367
 
3291
- var $$d = _export;
3368
+ var $$c = _export;
3292
3369
  var uncurryThis$c = functionUncurryThis;
3293
- var aCallable$6 = aCallable$a;
3294
- var toObject$2 = toObject$7;
3295
- var lengthOfArrayLike$2 = lengthOfArrayLike$6;
3370
+ var aCallable$5 = aCallable$a;
3371
+ var toObject$1 = toObject$7;
3372
+ var lengthOfArrayLike$1 = lengthOfArrayLike$6;
3296
3373
  var deletePropertyOrThrow = deletePropertyOrThrow$1;
3297
3374
  var toString$a = toString$c;
3298
3375
  var fails$b = fails$p;
3299
3376
  var internalSort = arraySort;
3300
- var arrayMethodIsStrict$1 = arrayMethodIsStrict$2;
3377
+ var arrayMethodIsStrict = arrayMethodIsStrict$2;
3301
3378
  var FF = engineFfVersion;
3302
3379
  var IE_OR_EDGE = engineIsIeOrEdge;
3303
3380
  var V8 = engineV8Version;
@@ -3316,7 +3393,7 @@ var FAILS_ON_NULL = fails$b(function () {
3316
3393
  test$1.sort(null);
3317
3394
  });
3318
3395
  // Old WebKit
3319
- var STRICT_METHOD = arrayMethodIsStrict$1('sort');
3396
+ var STRICT_METHOD = arrayMethodIsStrict('sort');
3320
3397
 
3321
3398
  var STABLE_SORT = !fails$b(function () {
3322
3399
  // feature detection can be too slow, so check engines versions
@@ -3353,7 +3430,7 @@ var STABLE_SORT = !fails$b(function () {
3353
3430
  return result !== 'DGBEFHACIJK';
3354
3431
  });
3355
3432
 
3356
- var FORCED$2 = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
3433
+ var FORCED$1 = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
3357
3434
 
3358
3435
  var getSortCompare = function (comparefn) {
3359
3436
  return function (x, y) {
@@ -3366,16 +3443,16 @@ var getSortCompare = function (comparefn) {
3366
3443
 
3367
3444
  // `Array.prototype.sort` method
3368
3445
  // https://tc39.es/ecma262/#sec-array.prototype.sort
3369
- $$d({ target: 'Array', proto: true, forced: FORCED$2 }, {
3446
+ $$c({ target: 'Array', proto: true, forced: FORCED$1 }, {
3370
3447
  sort: function sort(comparefn) {
3371
- if (comparefn !== undefined) aCallable$6(comparefn);
3448
+ if (comparefn !== undefined) aCallable$5(comparefn);
3372
3449
 
3373
- var array = toObject$2(this);
3450
+ var array = toObject$1(this);
3374
3451
 
3375
3452
  if (STABLE_SORT) return comparefn === undefined ? nativeSort(array) : nativeSort(array, comparefn);
3376
3453
 
3377
3454
  var items = [];
3378
- var arrayLength = lengthOfArrayLike$2(array);
3455
+ var arrayLength = lengthOfArrayLike$1(array);
3379
3456
  var itemsLength, index;
3380
3457
 
3381
3458
  for (index = 0; index < arrayLength; index++) {
@@ -3384,7 +3461,7 @@ $$d({ target: 'Array', proto: true, forced: FORCED$2 }, {
3384
3461
 
3385
3462
  internalSort(items, getSortCompare(comparefn));
3386
3463
 
3387
- itemsLength = lengthOfArrayLike$2(items);
3464
+ itemsLength = lengthOfArrayLike$1(items);
3388
3465
  index = 0;
3389
3466
 
3390
3467
  while (index < itemsLength) array[index] = items[index++];
@@ -4390,10 +4467,10 @@ function boundNumber(input, min, max) {
4390
4467
  }
4391
4468
 
4392
4469
  var fails$9 = fails$p;
4393
- var global$b = global$o;
4470
+ var global$a = global$o;
4394
4471
 
4395
4472
  // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
4396
- var $RegExp$2 = global$b.RegExp;
4473
+ var $RegExp$2 = global$a.RegExp;
4397
4474
 
4398
4475
  var UNSUPPORTED_Y$3 = fails$9(function () {
4399
4476
  var re = $RegExp$2('a', 'y');
@@ -4421,10 +4498,10 @@ var regexpStickyHelpers = {
4421
4498
  };
4422
4499
 
4423
4500
  var fails$8 = fails$p;
4424
- var global$a = global$o;
4501
+ var global$9 = global$o;
4425
4502
 
4426
4503
  // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
4427
- var $RegExp$1 = global$a.RegExp;
4504
+ var $RegExp$1 = global$9.RegExp;
4428
4505
 
4429
4506
  var regexpUnsupportedDotAll = fails$8(function () {
4430
4507
  var re = $RegExp$1('.', 's');
@@ -4432,10 +4509,10 @@ var regexpUnsupportedDotAll = fails$8(function () {
4432
4509
  });
4433
4510
 
4434
4511
  var fails$7 = fails$p;
4435
- var global$9 = global$o;
4512
+ var global$8 = global$o;
4436
4513
 
4437
4514
  // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError
4438
- var $RegExp = global$9.RegExp;
4515
+ var $RegExp = global$8.RegExp;
4439
4516
 
4440
4517
  var regexpUnsupportedNcg = fails$7(function () {
4441
4518
  var re = $RegExp('(?<a>b)', 'g');
@@ -4560,12 +4637,12 @@ if (PATCH) {
4560
4637
 
4561
4638
  var regexpExec$2 = patchedExec;
4562
4639
 
4563
- var $$c = _export;
4640
+ var $$b = _export;
4564
4641
  var exec$1 = regexpExec$2;
4565
4642
 
4566
4643
  // `RegExp.prototype.exec` method
4567
4644
  // https://tc39.es/ecma262/#sec-regexp.prototype.exec
4568
- $$c({ target: 'RegExp', proto: true, forced: /./.exec !== exec$1 }, {
4645
+ $$b({ target: 'RegExp', proto: true, forced: /./.exec !== exec$1 }, {
4569
4646
  exec: exec$1
4570
4647
  });
4571
4648
 
@@ -4592,7 +4669,7 @@ var stringRepeat = function repeat(count) {
4592
4669
  return result;
4593
4670
  };
4594
4671
 
4595
- var $$b = _export;
4672
+ var $$a = _export;
4596
4673
  var uncurryThis$9 = functionUncurryThis;
4597
4674
  var toIntegerOrInfinity$2 = toIntegerOrInfinity$7;
4598
4675
  var thisNumberValue = thisNumberValue$1;
@@ -4654,7 +4731,7 @@ var dataToString = function (data) {
4654
4731
  } return s;
4655
4732
  };
4656
4733
 
4657
- var FORCED$1 = fails$6(function () {
4734
+ var FORCED = fails$6(function () {
4658
4735
  return nativeToFixed(0.00008, 3) !== '0.000' ||
4659
4736
  nativeToFixed(0.9, 0) !== '1' ||
4660
4737
  nativeToFixed(1.255, 2) !== '1.25' ||
@@ -4666,7 +4743,7 @@ var FORCED$1 = fails$6(function () {
4666
4743
 
4667
4744
  // `Number.prototype.toFixed` method
4668
4745
  // https://tc39.es/ecma262/#sec-number.prototype.tofixed
4669
- $$b({ target: 'Number', proto: true, forced: FORCED$1 }, {
4746
+ $$a({ target: 'Number', proto: true, forced: FORCED }, {
4670
4747
  toFixed: function toFixed(fractionDigits) {
4671
4748
  var number = thisNumberValue(this);
4672
4749
  var fractDigits = toIntegerOrInfinity$2(fractionDigits);
@@ -5054,74 +5131,6 @@ function transformNumberFunction(config) {
5054
5131
  return chainMapSameFunctions(transformFunctions);
5055
5132
  }
5056
5133
 
5057
- var aCallable$5 = aCallable$a;
5058
- var toObject$1 = toObject$7;
5059
- var IndexedObject = indexedObject;
5060
- var lengthOfArrayLike$1 = lengthOfArrayLike$6;
5061
-
5062
- var $TypeError$8 = TypeError;
5063
-
5064
- // `Array.prototype.{ reduce, reduceRight }` methods implementation
5065
- var createMethod$2 = function (IS_RIGHT) {
5066
- return function (that, callbackfn, argumentsLength, memo) {
5067
- var O = toObject$1(that);
5068
- var self = IndexedObject(O);
5069
- var length = lengthOfArrayLike$1(O);
5070
- aCallable$5(callbackfn);
5071
- var index = IS_RIGHT ? length - 1 : 0;
5072
- var i = IS_RIGHT ? -1 : 1;
5073
- if (argumentsLength < 2) while (true) {
5074
- if (index in self) {
5075
- memo = self[index];
5076
- index += i;
5077
- break;
5078
- }
5079
- index += i;
5080
- if (IS_RIGHT ? index < 0 : length <= index) {
5081
- throw new $TypeError$8('Reduce of empty array with no initial value');
5082
- }
5083
- }
5084
- for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
5085
- memo = callbackfn(memo, self[index], index, O);
5086
- }
5087
- return memo;
5088
- };
5089
- };
5090
-
5091
- var arrayReduce = {
5092
- // `Array.prototype.reduce` method
5093
- // https://tc39.es/ecma262/#sec-array.prototype.reduce
5094
- left: createMethod$2(false),
5095
- // `Array.prototype.reduceRight` method
5096
- // https://tc39.es/ecma262/#sec-array.prototype.reduceright
5097
- right: createMethod$2(true)
5098
- };
5099
-
5100
- var global$8 = global$o;
5101
- var classof$3 = classofRaw$2;
5102
-
5103
- var engineIsNode = classof$3(global$8.process) === 'process';
5104
-
5105
- var $$a = _export;
5106
- var $reduce = arrayReduce.left;
5107
- var arrayMethodIsStrict = arrayMethodIsStrict$2;
5108
- var CHROME_VERSION = engineV8Version;
5109
- var IS_NODE$4 = engineIsNode;
5110
-
5111
- // Chrome 80-82 has a critical bug
5112
- // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
5113
- var CHROME_BUG = !IS_NODE$4 && CHROME_VERSION > 79 && CHROME_VERSION < 83;
5114
- var FORCED = CHROME_BUG || !arrayMethodIsStrict('reduce');
5115
-
5116
- // `Array.prototype.reduce` method
5117
- // https://tc39.es/ecma262/#sec-array.prototype.reduce
5118
- $$a({ target: 'Array', proto: true, forced: FORCED }, {
5119
- reduce: function reduce(callbackfn /* , initialValue */) {
5120
- var length = arguments.length;
5121
- return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
5122
- }
5123
- });
5124
-
5125
5134
  function reduceNumbersWithMax(array, emptyArrayValue) {
5126
5135
  return reduceNumbersWithMaxFn(emptyArrayValue)(array);
5127
5136
  }
@@ -5813,6 +5822,22 @@ function arrayFactory(factory) {
5813
5822
  function arrayInputFactory(factory) {
5814
5823
  return input => makeWithFactoryInput(factory, input);
5815
5824
  }
5825
+ function terminatingFactoryFromArray(array, terminatingValue) {
5826
+ if (arguments.length === 1) {
5827
+ terminatingValue = null;
5828
+ }
5829
+ let index = 0;
5830
+ return () => {
5831
+ let result;
5832
+ if (array.length > index) {
5833
+ result = array[index];
5834
+ index += 1;
5835
+ } else {
5836
+ result = terminatingValue;
5837
+ }
5838
+ return result;
5839
+ };
5840
+ }
5816
5841
 
5817
5842
  // TODO: Remove from `core-js@4` since it's moved to entry points
5818
5843
 
@@ -10917,7 +10942,7 @@ function performTaskLoop(config) {
10917
10942
  return __awaiter(this, void 0, void 0, function* () {
10918
10943
  let result;
10919
10944
  const initValue = config.initValue;
10920
- const startLoop = initValue == null || config.checkContinue(initValue, -1);
10945
+ const startLoop = initValue == null || (yield config.checkContinue(initValue, -1));
10921
10946
  if (startLoop) {
10922
10947
  let i = 0;
10923
10948
  let prevValue = initValue;
@@ -10925,7 +10950,7 @@ function performTaskLoop(config) {
10925
10950
  do {
10926
10951
  prevValue = yield config.next(i, prevValue);
10927
10952
  i += 1;
10928
- check = config.checkContinue(prevValue, i);
10953
+ check = yield config.checkContinue(prevValue, i);
10929
10954
  } while (check);
10930
10955
  result = prevValue;
10931
10956
  } else {
@@ -12093,6 +12118,31 @@ function stringFactoryFromFactory(factory, toStringFunction) {
12093
12118
  return () => toStringFunction(factory());
12094
12119
  }
12095
12120
 
12121
+ /**
12122
+ * Convenience function for calling Promise.resolve
12123
+ *
12124
+ * @param input
12125
+ * @returns
12126
+ */
12127
+ function asPromise(input) {
12128
+ return Promise.resolve(input);
12129
+ }
12130
+
12131
+ let PROMISE_REF_NUMBER = 0;
12132
+ /**
12133
+ * Creates a new promise and returns the full ref for it.
12134
+ */
12135
+ function promiseReference(executor) {
12136
+ const ref = {};
12137
+ ref.promise = new Promise((resolve, reject) => {
12138
+ ref.resolve = resolve;
12139
+ ref.reject = reject;
12140
+ executor === null || executor === void 0 ? void 0 : executor(resolve, reject);
12141
+ });
12142
+ ref.number = PROMISE_REF_NUMBER += 1; // added for debugging
12143
+ return ref;
12144
+ }
12145
+
12096
12146
  /**
12097
12147
  * Runs the task using the input config, and returns the value. Is always configured to throw the error if it fails.
12098
12148
  */
@@ -12246,7 +12296,6 @@ function performTasksInParallel(input, config) {
12246
12296
  * @param config
12247
12297
  */
12248
12298
  function performTasksInParallelFunction(config) {
12249
- const defaultNonConcurrentTaskKeyFactory = stringFactoryFromFactory(incrementingNumberFactory(), x => x.toString());
12250
12299
  const {
12251
12300
  taskFactory,
12252
12301
  sequential,
@@ -12256,32 +12305,110 @@ function performTasksInParallelFunction(config) {
12256
12305
  } = config;
12257
12306
  const maxParallelTasks = inputMaxParallelTasks !== null && inputMaxParallelTasks !== void 0 ? inputMaxParallelTasks : sequential ? 1 : undefined;
12258
12307
  if (!maxParallelTasks && !nonConcurrentTaskKeyFactory) {
12308
+ const defaultNonConcurrentTaskKeyFactory = stringFactoryFromFactory(incrementingNumberFactory(), x => x.toString());
12259
12309
  // if the max number of parallel tasks is not defined, then run all tasks at once, unless there is a nonConcurrentTaskKeyFactory
12260
12310
  return input => __awaiter(this, void 0, void 0, function* () {
12261
12311
  yield Promise.all(input.map((value, i) => taskFactory(value, i, defaultNonConcurrentTaskKeyFactory())));
12262
12312
  });
12263
12313
  } else {
12264
- return input => {
12265
- if (input.length === 0) {
12266
- return Promise.resolve();
12314
+ const performTasks = performTasksFromFactoryInParallelFunction(config);
12315
+ return input => __awaiter(this, void 0, void 0, function* () {
12316
+ const taskInputFactory = terminatingFactoryFromArray([input],
12317
+ // all in a single task array to run concurrently
12318
+ null);
12319
+ return performTasks(taskInputFactory);
12320
+ });
12321
+ }
12322
+ }
12323
+ /**
12324
+ * Creates a function that performs tasks from the task factory in parallel.
12325
+ *
12326
+ * @param config
12327
+ */
12328
+ function performTasksFromFactoryInParallelFunction(config) {
12329
+ const defaultNonConcurrentTaskKeyFactory = stringFactoryFromFactory(incrementingNumberFactory(), x => x.toString());
12330
+ const {
12331
+ taskFactory,
12332
+ sequential,
12333
+ waitBetweenTaskInputRequests,
12334
+ nonConcurrentTaskKeyFactory,
12335
+ maxParallelTasks: inputMaxParallelTasks,
12336
+ waitBetweenTasks
12337
+ } = config;
12338
+ const maxParallelTasks = inputMaxParallelTasks !== null && inputMaxParallelTasks !== void 0 ? inputMaxParallelTasks : sequential ? 1 : undefined;
12339
+ const maxPromisesToRunAtOneTime = Math.max(1, maxParallelTasks !== null && maxParallelTasks !== void 0 ? maxParallelTasks : 1);
12340
+ return taskInputFactory => {
12341
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
12342
+ const taskKeyFactory = nonConcurrentTaskKeyFactory !== null && nonConcurrentTaskKeyFactory !== void 0 ? nonConcurrentTaskKeyFactory : defaultNonConcurrentTaskKeyFactory;
12343
+ let incompleteTasks = [];
12344
+ let baseI = 0;
12345
+ let isOutOfTasks = false;
12346
+ let isFulfillingTask = false;
12347
+ const requestTasksQueue = [];
12348
+ function fulfillRequestMoreTasks(parallelIndex, promiseReference) {
12349
+ return __awaiter(this, void 0, void 0, function* () {
12350
+ if (incompleteTasks.length === 0) {
12351
+ isFulfillingTask = true;
12352
+ const newTasks = yield asPromise(taskInputFactory());
12353
+ if (newTasks === null) {
12354
+ isOutOfTasks = true;
12355
+ } else {
12356
+ const newTaskEntries = asArray(newTasks).map((x, i) => [x, asArray(taskKeyFactory(x)), baseI + i]).reverse(); // reverse to use push/pop
12357
+ baseI += newTaskEntries.length;
12358
+ incompleteTasks = [...newTaskEntries, ...incompleteTasks]; // new tasks go to the front of the stack
12359
+ }
12360
+ }
12361
+
12362
+ const nextTask = incompleteTasks.pop();
12363
+ promiseReference.resolve(nextTask); // resolve that promise
12364
+ isFulfillingTask = false;
12365
+ // wait before popping off the next task in the queue, if applicable
12366
+ if (waitBetweenTaskInputRequests) {
12367
+ yield waitForMs(waitBetweenTaskInputRequests);
12368
+ }
12369
+ if (!isFulfillingTask && requestTasksQueue.length) {
12370
+ const nextItemInQueue = requestTasksQueue.pop();
12371
+ if (nextItemInQueue) {
12372
+ fulfillRequestMoreTasks(nextItemInQueue[0], nextItemInQueue[1]);
12373
+ }
12374
+ }
12375
+ });
12267
12376
  }
12268
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
12269
- const taskKeyFactory = nonConcurrentTaskKeyFactory !== null && nonConcurrentTaskKeyFactory !== void 0 ? nonConcurrentTaskKeyFactory : defaultNonConcurrentTaskKeyFactory;
12270
- const maxPromisesToRunAtOneTime = Math.min(maxParallelTasks !== null && maxParallelTasks !== void 0 ? maxParallelTasks : 100, input.length);
12271
- const incompleteTasks = input.map((x, i) => [x, asArray(taskKeyFactory(x)), i]).reverse(); // reverse to use push/pop
12272
- let currentRunIndex = 0;
12273
- let finishedParallels = 0;
12274
- let hasEncounteredFailure = false;
12275
- /**
12276
- * Set of tasks keys that are currently running.
12277
- */
12278
- const currentParellelTaskKeys = new Set();
12279
- const visitedTaskIndexes = new Set();
12280
- const waitingConcurrentTasks = multiValueMapBuilder();
12281
- function getNextTask() {
12377
+ function requestMoreTasks(parallelIndex) {
12378
+ return __awaiter(this, void 0, void 0, function* () {
12379
+ if (isOutOfTasks) {
12380
+ return;
12381
+ } else {
12382
+ const promiseRef = promiseReference();
12383
+ if (isFulfillingTask) {
12384
+ requestTasksQueue.push([parallelIndex, promiseRef]);
12385
+ const waited = yield promiseRef.promise;
12386
+ return waited;
12387
+ } else {
12388
+ fulfillRequestMoreTasks(parallelIndex, promiseRef);
12389
+ }
12390
+ return promiseRef.promise;
12391
+ }
12392
+ });
12393
+ }
12394
+ let currentRunIndex = 0;
12395
+ let finishedParallels = 0;
12396
+ let hasEncounteredFailure = false;
12397
+ /**
12398
+ * Set of tasks keys that are currently running.
12399
+ */
12400
+ const currentParellelTaskKeys = new Set();
12401
+ const visitedTaskIndexes = new Set();
12402
+ const waitingConcurrentTasks = multiValueMapBuilder();
12403
+ function getNextTask(parallelIndex) {
12404
+ return __awaiter(this, void 0, void 0, function* () {
12282
12405
  let nextTask = undefined;
12283
12406
  while (!nextTask) {
12284
- nextTask = incompleteTasks.pop();
12407
+ // request more tasks if the tasks list is empty
12408
+ if (!isOutOfTasks && incompleteTasks.length === 0) {
12409
+ nextTask = yield requestMoreTasks(parallelIndex);
12410
+ }
12411
+ nextTask = nextTask !== null && nextTask !== void 0 ? nextTask : incompleteTasks.pop();
12285
12412
  if (nextTask != null) {
12286
12413
  const nextTaskTuple = nextTask;
12287
12414
  const nextTaskTupleIndex = nextTaskTuple[2];
@@ -12309,46 +12436,48 @@ function performTasksInParallelFunction(config) {
12309
12436
  visitedTaskIndexes.add(nextTask[2]);
12310
12437
  }
12311
12438
  return nextTask;
12312
- }
12313
- function onTaskCompleted(task) {
12314
- const keys = task[1];
12315
- const indexesPushed = new Set();
12316
- keys.forEach(key => {
12317
- // un-reserve the key from each parallel task
12318
- currentParellelTaskKeys.delete(key);
12319
- const waitingForKey = waitingConcurrentTasks.get(key);
12320
- while (true) {
12321
- const nextWaitingTask = waitingForKey.shift(); // take from the front to retain unique task order
12322
- if (nextWaitingTask) {
12323
- const nextWaitingTaskIndex = nextWaitingTask[2];
12324
- if (visitedTaskIndexes.has(nextWaitingTaskIndex) || indexesPushed.has(nextWaitingTaskIndex)) {
12325
- // if the task has already been visited, then don't push back onto incomplete tasks.
12326
- continue;
12327
- } else {
12328
- // push to front for the next dispatch to take for this key
12329
- incompleteTasks.push(nextWaitingTask);
12330
- // mark to prevent pushing this one again since it will not get run
12331
- indexesPushed.add(nextWaitingTaskIndex);
12332
- break;
12333
- }
12439
+ });
12440
+ }
12441
+ function onTaskCompleted(task, parallelIndex) {
12442
+ const keys = task[1];
12443
+ const indexesPushed = new Set();
12444
+ keys.forEach(key => {
12445
+ // un-reserve the key from each parallel task
12446
+ currentParellelTaskKeys.delete(key);
12447
+ const waitingForKey = waitingConcurrentTasks.get(key);
12448
+ while (true) {
12449
+ const nextWaitingTask = waitingForKey.shift(); // take from the front to retain unique task order
12450
+ if (nextWaitingTask) {
12451
+ const nextWaitingTaskIndex = nextWaitingTask[2];
12452
+ if (visitedTaskIndexes.has(nextWaitingTaskIndex) || indexesPushed.has(nextWaitingTaskIndex)) {
12453
+ // if the task has already been visited, then don't push back onto incomplete tasks.
12454
+ continue;
12334
12455
  } else {
12456
+ // push to front for the next dispatch to take for this key
12457
+ incompleteTasks.push(nextWaitingTask);
12458
+ // mark to prevent pushing this one again since it will not get run
12459
+ indexesPushed.add(nextWaitingTaskIndex);
12335
12460
  break;
12336
12461
  }
12462
+ } else {
12463
+ break;
12337
12464
  }
12338
- });
12339
- }
12340
- // start initial promises
12341
- function dispatchNextPromise() {
12465
+ }
12466
+ });
12467
+ }
12468
+ // start initial promises
12469
+ function dispatchNextPromise(parallelIndex) {
12470
+ return __awaiter(this, void 0, void 0, function* () {
12342
12471
  // if a failure has been encountered then the promise has already been rejected.
12343
12472
  if (!hasEncounteredFailure) {
12344
- const nextTask = getNextTask();
12473
+ const nextTask = yield getNextTask(parallelIndex);
12345
12474
  if (nextTask) {
12346
12475
  // build/start promise
12347
12476
  const promise = taskFactory(nextTask[0], currentRunIndex, nextTask[1]);
12348
12477
  currentRunIndex += 1;
12349
12478
  promise.then(() => {
12350
12479
  onTaskCompleted(nextTask);
12351
- setTimeout(dispatchNextPromise, waitBetweenTasks);
12480
+ setTimeout(() => dispatchNextPromise(parallelIndex), waitBetweenTasks);
12352
12481
  }, e => {
12353
12482
  hasEncounteredFailure = true;
12354
12483
  reject(e);
@@ -12361,39 +12490,14 @@ function performTasksInParallelFunction(config) {
12361
12490
  }
12362
12491
  }
12363
12492
  }
12364
- }
12365
- // run the initial promises
12366
- range(0, maxPromisesToRunAtOneTime).forEach(() => {
12367
- dispatchNextPromise();
12368
12493
  });
12369
- }));
12370
- };
12371
- }
12372
- }
12373
-
12374
- let PROMISE_REF_NUMBER = 0;
12375
- /**
12376
- * Creates a new promise and returns the full ref for it.
12377
- */
12378
- function promiseReference(executor) {
12379
- const ref = {};
12380
- ref.promise = new Promise((resolve, reject) => {
12381
- ref.resolve = resolve;
12382
- ref.reject = reject;
12383
- executor === null || executor === void 0 ? void 0 : executor(resolve, reject);
12384
- });
12385
- ref.number = PROMISE_REF_NUMBER += 1; // added for debugging
12386
- return ref;
12387
- }
12388
-
12389
- /**
12390
- * Convenience function for calling Promise.resolve
12391
- *
12392
- * @param input
12393
- * @returns
12394
- */
12395
- function asPromise(input) {
12396
- return Promise.resolve(input);
12494
+ }
12495
+ // run the initial promises
12496
+ range(0, maxPromisesToRunAtOneTime).forEach(parallelIndex => {
12497
+ dispatchNextPromise(parallelIndex);
12498
+ });
12499
+ }));
12500
+ };
12397
12501
  }
12398
12502
 
12399
12503
  /**
@@ -13903,6 +14007,7 @@ exports.copyLatLngBound = copyLatLngBound;
13903
14007
  exports.copyLatLngPoint = copyLatLngPoint;
13904
14008
  exports.copyObject = copyObject;
13905
14009
  exports.copySetAndDo = copySetAndDo;
14010
+ exports.countAllInNestedArray = countAllInNestedArray;
13906
14011
  exports.countPOJOKeys = countPOJOKeys;
13907
14012
  exports.countPOJOKeysFunction = countPOJOKeysFunction;
13908
14013
  exports.cronExpressionRepeatingEveryNMinutes = cronExpressionRepeatingEveryNMinutes;
@@ -14275,6 +14380,7 @@ exports.performBatchLoop = performBatchLoop;
14275
14380
  exports.performMakeLoop = performMakeLoop;
14276
14381
  exports.performTaskCountLoop = performTaskCountLoop;
14277
14382
  exports.performTaskLoop = performTaskLoop;
14383
+ exports.performTasksFromFactoryInParallelFunction = performTasksFromFactoryInParallelFunction;
14278
14384
  exports.performTasksInParallel = performTasksInParallel;
14279
14385
  exports.performTasksInParallelFunction = performTasksInParallelFunction;
14280
14386
  exports.pickOneRandomly = pickOneRandomly;
@@ -14434,6 +14540,7 @@ exports.takeLast = takeLast;
14434
14540
  exports.takeValuesFromIterable = takeValuesFromIterable;
14435
14541
  exports.telUrlString = telUrlString;
14436
14542
  exports.telUrlStringForE164PhoneNumberPair = telUrlStringForE164PhoneNumberPair;
14543
+ exports.terminatingFactoryFromArray = terminatingFactoryFromArray;
14437
14544
  exports.throwKeyIsRequired = throwKeyIsRequired;
14438
14545
  exports.toAbsoluteSlashPathStartType = toAbsoluteSlashPathStartType;
14439
14546
  exports.toCaseInsensitiveStringArray = toCaseInsensitiveStringArray;