@dereekb/util 10.0.8 → 10.0.10

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.
@@ -2,6 +2,14 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [10.0.10](https://github.com/dereekb/dbx-components/compare/v10.0.9-dev...v10.0.10) (2024-01-21)
6
+
7
+
8
+
9
+ ## [10.0.9](https://github.com/dereekb/dbx-components/compare/v10.0.8-dev...v10.0.9) (2024-01-15)
10
+
11
+
12
+
5
13
  ## [10.0.8](https://github.com/dereekb/dbx-components/compare/v10.0.7-dev...v10.0.8) (2024-01-14)
6
14
 
7
15
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util/fetch",
3
- "version": "10.0.8",
3
+ "version": "10.0.10",
4
4
  "type": "commonjs",
5
5
  "peerDependencies": {
6
6
  "@dereekb/util": "*"
package/index.cjs.js CHANGED
@@ -2213,6 +2213,49 @@ function filterFromIterable(values, fn) {
2213
2213
  }
2214
2214
  return keep;
2215
2215
  }
2216
+ /**
2217
+ * Wraps the input tuple values as an array. The tuples should all be the same length in order to wrap them properly, and the tuple value cannot consist of only arrays of the same length.
2218
+ *
2219
+ * This is used to prevent functions from treating the tuple itself as an array.
2220
+ *
2221
+ * @param input
2222
+ */
2223
+ function wrapTuples(input) {
2224
+ if (Array.isArray(input)) {
2225
+ // check if the first item is an array. Tuples can contain arrays as the first value.
2226
+ if (input.length > 0) {
2227
+ const firstValueInPotentialTupleOrArray = input[0];
2228
+ let inputIsSingleTuple = false;
2229
+ if (Array.isArray(firstValueInPotentialTupleOrArray)) {
2230
+ // if the first nested value is an array then the top-level value may be an array and not a tuple. Check the length of all the other values in the array to see if they have the same length.
2231
+ const expectedLength = firstValueInPotentialTupleOrArray.length;
2232
+ // if it is an array of tuples, all values should be the same length and be arrays. If not an array, then we're looking at a tuple.
2233
+ const firstNonUniformTupleValueIndex = input.findIndex(x => {
2234
+ if (Array.isArray(x)) {
2235
+ return x.length !== expectedLength;
2236
+ } else {
2237
+ return true; // non-array value. The input is a tuple.
2238
+ }
2239
+ });
2240
+
2241
+ inputIsSingleTuple = firstNonUniformTupleValueIndex !== -1;
2242
+ } else {
2243
+ inputIsSingleTuple = true;
2244
+ return [input];
2245
+ }
2246
+ // first value of the tuple could also be an array. If it is, check the other tuples all have the same length.
2247
+ if (inputIsSingleTuple) {
2248
+ return [input];
2249
+ } else {
2250
+ return input;
2251
+ }
2252
+ } else {
2253
+ return input; // is an empty array.
2254
+ }
2255
+ } else {
2256
+ throw new Error('Input is not an array/tuple...');
2257
+ }
2258
+ }
2216
2259
 
2217
2260
  /**
2218
2261
  * Creates a ReadKeysFromFunction using a ReadKeyFunction.
@@ -3880,19 +3923,6 @@ function makeValuesGroupMap(values, groupKeyFn) {
3880
3923
  return map;
3881
3924
  }
3882
3925
 
3883
- /**
3884
- * map utility function for an iterable that maps and places the results into an array.
3885
- *
3886
- * @param values
3887
- * @param fn
3888
- * @returns
3889
- */
3890
- function mapIterable(values, fn) {
3891
- const mapping = [];
3892
- forEachInIterable(values, value => mapping.push(fn(value)));
3893
- return mapping;
3894
- }
3895
-
3896
3926
  /**
3897
3927
  *
3898
3928
  * @param maps
@@ -4013,20 +4043,29 @@ function readMultipleKeysToMap(values, read) {
4013
4043
  */
4014
4044
  function multiValueMapBuilder() {
4015
4045
  const map = new Map();
4046
+ const add = (key, value) => {
4047
+ let array = map.get(key);
4048
+ if (array == null) {
4049
+ array = [];
4050
+ map.set(key, array);
4051
+ }
4052
+ useIterableOrValue(value, x => array.push(x));
4053
+ };
4016
4054
  const builder = {
4017
4055
  map: () => map,
4018
4056
  entries: () => mapToTuples(map),
4019
4057
  tuples: () => expandArrayMapTuples(map),
4020
4058
  delete: key => {
4021
- map.delete(key);
4059
+ return map.delete(key);
4022
4060
  },
4023
- add: (key, value) => {
4024
- let array = map.get(key);
4025
- if (array == null) {
4026
- array = [];
4027
- map.set(key, array);
4028
- }
4029
- useIterableOrValue(value, x => array.push(x));
4061
+ add,
4062
+ addTuples: (key, value) => add(key, wrapTuples(value)),
4063
+ has: key => {
4064
+ return map.has(key);
4065
+ },
4066
+ get: key => {
4067
+ var _a;
4068
+ return (_a = map.get(key)) !== null && _a !== void 0 ? _a : [];
4030
4069
  }
4031
4070
  };
4032
4071
  return builder;
@@ -6586,6 +6625,19 @@ function repeatString(string, reapeat) {
6586
6625
  return result;
6587
6626
  }
6588
6627
 
6628
+ /**
6629
+ * map utility function for an iterable that maps and places the results into an array.
6630
+ *
6631
+ * @param values
6632
+ * @param fn
6633
+ * @returns
6634
+ */
6635
+ function mapIterable(values, fn) {
6636
+ const mapping = [];
6637
+ forEachInIterable(values, value => mapping.push(fn(value)));
6638
+ return mapping;
6639
+ }
6640
+
6589
6641
  var isRegExp$1 = isRegexp;
6590
6642
 
6591
6643
  var $TypeError$5 = TypeError;
@@ -12058,6 +12110,17 @@ function mapPromiseOrValue(input, mapFn) {
12058
12110
  }
12059
12111
  }
12060
12112
 
12113
+ /**
12114
+ * Wraps another factory with a ToStringFactory function to generate strings from the original factory.
12115
+ *
12116
+ * @param factory
12117
+ * @param toStringFunction
12118
+ * @returns
12119
+ */
12120
+ function stringFactoryFromFactory(factory, toStringFunction) {
12121
+ return () => toStringFunction(factory());
12122
+ }
12123
+
12061
12124
  /**
12062
12125
  * Runs the task using the input config, and returns the value. Is always configured to throw the error if it fails.
12063
12126
  */
@@ -12099,10 +12162,12 @@ function performAsyncTasks(input, taskFn, config = {
12099
12162
  const {
12100
12163
  sequential,
12101
12164
  maxParallelTasks,
12102
- waitBetweenTasks
12165
+ waitBetweenTasks,
12166
+ nonConcurrentTaskKeyFactory
12103
12167
  } = config;
12104
12168
  const taskResults = [];
12105
12169
  yield performTasksInParallelFunction({
12170
+ nonConcurrentTaskKeyFactory,
12106
12171
  taskFactory: (value, i) => _performAsyncTask(value, taskFn, config).then(x => {
12107
12172
  taskResults[i] = x;
12108
12173
  }),
@@ -12209,17 +12274,19 @@ function performTasksInParallel(input, config) {
12209
12274
  * @param config
12210
12275
  */
12211
12276
  function performTasksInParallelFunction(config) {
12277
+ const defaultNonConcurrentTaskKeyFactory = stringFactoryFromFactory(incrementingNumberFactory(), x => x.toString());
12212
12278
  const {
12213
12279
  taskFactory,
12214
12280
  sequential,
12281
+ nonConcurrentTaskKeyFactory,
12215
12282
  maxParallelTasks: inputMaxParallelTasks,
12216
12283
  waitBetweenTasks
12217
12284
  } = config;
12218
12285
  const maxParallelTasks = inputMaxParallelTasks !== null && inputMaxParallelTasks !== void 0 ? inputMaxParallelTasks : sequential ? 1 : undefined;
12219
- if (!maxParallelTasks) {
12220
- // if the max number of parallel tasks is not defined, then run all tasks at once
12286
+ if (!maxParallelTasks && !nonConcurrentTaskKeyFactory) {
12287
+ // if the max number of parallel tasks is not defined, then run all tasks at once, unless there is a nonConcurrentTaskKeyFactory
12221
12288
  return input => __awaiter(this, void 0, void 0, function* () {
12222
- yield Promise.all(input.map((value, i) => taskFactory(value, i)));
12289
+ yield Promise.all(input.map((value, i) => taskFactory(value, i, defaultNonConcurrentTaskKeyFactory())));
12223
12290
  });
12224
12291
  } else {
12225
12292
  return input => {
@@ -12227,29 +12294,67 @@ function performTasksInParallelFunction(config) {
12227
12294
  return Promise.resolve();
12228
12295
  }
12229
12296
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
12230
- const maxPromisesToRunAtOneTime = Math.min(maxParallelTasks, input.length);
12231
- const endIndex = input.length;
12232
- let i = 0;
12297
+ const taskKeyFactory = nonConcurrentTaskKeyFactory !== null && nonConcurrentTaskKeyFactory !== void 0 ? nonConcurrentTaskKeyFactory : defaultNonConcurrentTaskKeyFactory;
12298
+ const maxPromisesToRunAtOneTime = Math.min(maxParallelTasks !== null && maxParallelTasks !== void 0 ? maxParallelTasks : 100, input.length);
12299
+ const incompleteTasks = input.map(x => [x, taskKeyFactory(x)]).reverse(); // reverse to use push/pop
12300
+ let currentRunIndex = 0;
12233
12301
  let finishedParallels = 0;
12234
12302
  let hasEncounteredFailure = false;
12303
+ /**
12304
+ * Set of tasks keys that are currently running.
12305
+ */
12306
+ const currentParellelTaskKeys = new Set();
12307
+ const waitingConcurrentTasks = multiValueMapBuilder();
12308
+ function getNextTask() {
12309
+ let nextTask = undefined;
12310
+ while (!nextTask) {
12311
+ nextTask = incompleteTasks.pop();
12312
+ if (nextTask) {
12313
+ const key = nextTask[1];
12314
+ if (currentParellelTaskKeys.has(key)) {
12315
+ waitingConcurrentTasks.addTuples(key, nextTask); // wrap the tuple in an array to add it properly.
12316
+ nextTask = undefined; // clear to continue loop
12317
+ } else {
12318
+ currentParellelTaskKeys.add(key); // add to the current task keys, exit loop
12319
+ break;
12320
+ }
12321
+ } else {
12322
+ break; // no tasks remaining, break.
12323
+ }
12324
+ }
12325
+
12326
+ return nextTask;
12327
+ }
12328
+ function onTaskCompleted(task) {
12329
+ const key = task[1];
12330
+ currentParellelTaskKeys.delete(key);
12331
+ const waitingForKey = waitingConcurrentTasks.get(key);
12332
+ const nextWaitingTask = waitingForKey.shift(); // take from the front to retain unique task order
12333
+ if (nextWaitingTask) {
12334
+ incompleteTasks.push(nextWaitingTask); // push to front for the next dispatch to take
12335
+ }
12336
+ }
12235
12337
  // start initial promises
12236
12338
  function dispatchNextPromise() {
12237
- const hasNext = i < endIndex;
12238
- if (hasNext && !hasEncounteredFailure) {
12239
- const value = input[i];
12240
- const promise = taskFactory(value, i);
12241
- i += 1;
12242
- promise.then(() => {
12243
- setTimeout(dispatchNextPromise, waitBetweenTasks);
12244
- }, e => {
12245
- hasEncounteredFailure = true;
12246
- reject(e);
12247
- });
12248
- } else if (!hasNext) {
12249
- finishedParallels += 1;
12250
- // only resolve after the last parallel is complete
12251
- if (finishedParallels === maxPromisesToRunAtOneTime) {
12252
- resolve();
12339
+ // if a failure has been encountered then the promise has already been rejected.
12340
+ if (!hasEncounteredFailure) {
12341
+ const nextTask = getNextTask();
12342
+ if (nextTask) {
12343
+ const promise = taskFactory(nextTask[0], currentRunIndex, nextTask[1]);
12344
+ currentRunIndex += 1;
12345
+ promise.then(() => {
12346
+ onTaskCompleted(nextTask);
12347
+ setTimeout(dispatchNextPromise, waitBetweenTasks);
12348
+ }, e => {
12349
+ hasEncounteredFailure = true;
12350
+ reject(e);
12351
+ });
12352
+ } else {
12353
+ finishedParallels += 1;
12354
+ // only resolve after the last parallel is complete
12355
+ if (finishedParallels === maxPromisesToRunAtOneTime) {
12356
+ resolve();
12357
+ }
12253
12358
  }
12254
12359
  }
12255
12360
  }
@@ -14310,6 +14415,7 @@ exports.splitStringAtFirstCharacterOccurenceFunction = splitStringAtFirstCharact
14310
14415
  exports.splitStringAtIndex = splitStringAtIndex;
14311
14416
  exports.stepsFromIndex = stepsFromIndex;
14312
14417
  exports.stepsFromIndexFunction = stepsFromIndexFunction;
14418
+ exports.stringFactoryFromFactory = stringFactoryFromFactory;
14313
14419
  exports.stringToLowercaseFunction = stringToLowercaseFunction;
14314
14420
  exports.stringToUppercaseFunction = stringToUppercaseFunction;
14315
14421
  exports.stringTrimFunction = stringTrimFunction;
@@ -14371,5 +14477,6 @@ exports.wrapLatLngPoint = wrapLatLngPoint;
14371
14477
  exports.wrapLngValue = wrapLngValue;
14372
14478
  exports.wrapMapFunctionOutput = wrapMapFunctionOutput;
14373
14479
  exports.wrapNumberFunction = wrapNumberFunction;
14480
+ exports.wrapTuples = wrapTuples;
14374
14481
  exports.wrapUseAsyncFunction = wrapUseAsyncFunction;
14375
14482
  exports.wrapUseFunction = wrapUseFunction;
package/index.esm.js CHANGED
@@ -2244,6 +2244,52 @@ function filterFromIterable(values, fn) {
2244
2244
  return keep;
2245
2245
  }
2246
2246
 
2247
+ /**
2248
+ * Wraps the input tuple values as an array. The tuples should all be the same length in order to wrap them properly, and the tuple value cannot consist of only arrays of the same length.
2249
+ *
2250
+ * This is used to prevent functions from treating the tuple itself as an array.
2251
+ *
2252
+ * @param input
2253
+ */
2254
+ function wrapTuples(input) {
2255
+ if (Array.isArray(input)) {
2256
+ // check if the first item is an array. Tuples can contain arrays as the first value.
2257
+ if (input.length > 0) {
2258
+ const firstValueInPotentialTupleOrArray = input[0];
2259
+ let inputIsSingleTuple = false;
2260
+ if (Array.isArray(firstValueInPotentialTupleOrArray)) {
2261
+ // if the first nested value is an array then the top-level value may be an array and not a tuple. Check the length of all the other values in the array to see if they have the same length.
2262
+ const expectedLength = firstValueInPotentialTupleOrArray.length;
2263
+
2264
+ // if it is an array of tuples, all values should be the same length and be arrays. If not an array, then we're looking at a tuple.
2265
+ const firstNonUniformTupleValueIndex = input.findIndex(x => {
2266
+ if (Array.isArray(x)) {
2267
+ return x.length !== expectedLength;
2268
+ } else {
2269
+ return true; // non-array value. The input is a tuple.
2270
+ }
2271
+ });
2272
+
2273
+ inputIsSingleTuple = firstNonUniformTupleValueIndex !== -1;
2274
+ } else {
2275
+ inputIsSingleTuple = true;
2276
+ return [input];
2277
+ }
2278
+
2279
+ // first value of the tuple could also be an array. If it is, check the other tuples all have the same length.
2280
+ if (inputIsSingleTuple) {
2281
+ return [input];
2282
+ } else {
2283
+ return input;
2284
+ }
2285
+ } else {
2286
+ return input; // is an empty array.
2287
+ }
2288
+ } else {
2289
+ throw new Error('Input is not an array/tuple...');
2290
+ }
2291
+ }
2292
+
2247
2293
  /**
2248
2294
  * A key made up of either a string or number value.
2249
2295
  */
@@ -4212,19 +4258,6 @@ function makeValuesGroupMap(values, groupKeyFn) {
4212
4258
  return map;
4213
4259
  }
4214
4260
 
4215
- /**
4216
- * map utility function for an iterable that maps and places the results into an array.
4217
- *
4218
- * @param values
4219
- * @param fn
4220
- * @returns
4221
- */
4222
- function mapIterable(values, fn) {
4223
- const mapping = [];
4224
- forEachInIterable(values, value => mapping.push(fn(value)));
4225
- return mapping;
4226
- }
4227
-
4228
4261
  /**
4229
4262
  *
4230
4263
  * @param maps
@@ -4365,20 +4398,29 @@ function readMultipleKeysToMap(values, read) {
4365
4398
  */
4366
4399
  function multiValueMapBuilder() {
4367
4400
  const map = new Map();
4401
+ const add = (key, value) => {
4402
+ let array = map.get(key);
4403
+ if (array == null) {
4404
+ array = [];
4405
+ map.set(key, array);
4406
+ }
4407
+ useIterableOrValue(value, x => array.push(x));
4408
+ };
4368
4409
  const builder = {
4369
4410
  map: () => map,
4370
4411
  entries: () => mapToTuples(map),
4371
4412
  tuples: () => expandArrayMapTuples(map),
4372
4413
  delete: key => {
4373
- map.delete(key);
4414
+ return map.delete(key);
4374
4415
  },
4375
- add: (key, value) => {
4376
- let array = map.get(key);
4377
- if (array == null) {
4378
- array = [];
4379
- map.set(key, array);
4380
- }
4381
- useIterableOrValue(value, x => array.push(x));
4416
+ add,
4417
+ addTuples: (key, value) => add(key, wrapTuples(value)),
4418
+ has: key => {
4419
+ return map.has(key);
4420
+ },
4421
+ get: key => {
4422
+ var _map$get;
4423
+ return (_map$get = map.get(key)) != null ? _map$get : [];
4382
4424
  }
4383
4425
  };
4384
4426
  return builder;
@@ -7521,6 +7563,19 @@ function repeatString(string, reapeat) {
7521
7563
  return result;
7522
7564
  }
7523
7565
 
7566
+ /**
7567
+ * map utility function for an iterable that maps and places the results into an array.
7568
+ *
7569
+ * @param values
7570
+ * @param fn
7571
+ * @returns
7572
+ */
7573
+ function mapIterable(values, fn) {
7574
+ const mapping = [];
7575
+ forEachInIterable(values, value => mapping.push(fn(value)));
7576
+ return mapping;
7577
+ }
7578
+
7524
7579
  var isRegExp$1 = isRegexp;
7525
7580
 
7526
7581
  var $TypeError$5 = TypeError;
@@ -13854,6 +13909,17 @@ function mapPromiseOrValue(input, mapFn) {
13854
13909
  }
13855
13910
  }
13856
13911
 
13912
+ /**
13913
+ * Wraps another factory with a ToStringFactory function to generate strings from the original factory.
13914
+ *
13915
+ * @param factory
13916
+ * @param toStringFunction
13917
+ * @returns
13918
+ */
13919
+ function stringFactoryFromFactory(factory, toStringFunction) {
13920
+ return () => toStringFunction(factory());
13921
+ }
13922
+
13857
13923
  /**
13858
13924
  * Runs the task using the input config, and returns the value. Is always configured to throw the error if it fails.
13859
13925
  */
@@ -13894,10 +13960,12 @@ async function performAsyncTasks(input, taskFn, config = {
13894
13960
  const {
13895
13961
  sequential,
13896
13962
  maxParallelTasks,
13897
- waitBetweenTasks
13963
+ waitBetweenTasks,
13964
+ nonConcurrentTaskKeyFactory
13898
13965
  } = config;
13899
13966
  const taskResults = [];
13900
13967
  await performTasksInParallelFunction({
13968
+ nonConcurrentTaskKeyFactory,
13901
13969
  taskFactory: (value, i) => _performAsyncTask(value, taskFn, config).then(x => {
13902
13970
  taskResults[i] = x;
13903
13971
  }),
@@ -13979,6 +14047,9 @@ async function _performAsyncTask(value, taskFn, config = {}) {
13979
14047
  }
13980
14048
 
13981
14049
  // MARK: Parallel
14050
+ /**
14051
+ * Used as a key to identify the "group" that a task belongs to to prevent other concurrent tasks from that group from running in parallel when parallel execution is desired.
14052
+ */
13982
14053
 
13983
14054
  /**
13984
14055
  * Function that awaits a promise generate from each of the input values.
@@ -14003,17 +14074,19 @@ function performTasksInParallel(input, config) {
14003
14074
  * @param config
14004
14075
  */
14005
14076
  function performTasksInParallelFunction(config) {
14077
+ const defaultNonConcurrentTaskKeyFactory = stringFactoryFromFactory(incrementingNumberFactory(), x => x.toString());
14006
14078
  const {
14007
14079
  taskFactory,
14008
14080
  sequential,
14081
+ nonConcurrentTaskKeyFactory,
14009
14082
  maxParallelTasks: inputMaxParallelTasks,
14010
14083
  waitBetweenTasks
14011
14084
  } = config;
14012
14085
  const maxParallelTasks = inputMaxParallelTasks != null ? inputMaxParallelTasks : sequential ? 1 : undefined;
14013
- if (!maxParallelTasks) {
14014
- // if the max number of parallel tasks is not defined, then run all tasks at once
14086
+ if (!maxParallelTasks && !nonConcurrentTaskKeyFactory) {
14087
+ // if the max number of parallel tasks is not defined, then run all tasks at once, unless there is a nonConcurrentTaskKeyFactory
14015
14088
  return async input => {
14016
- await Promise.all(input.map((value, i) => taskFactory(value, i)));
14089
+ await Promise.all(input.map((value, i) => taskFactory(value, i, defaultNonConcurrentTaskKeyFactory())));
14017
14090
  };
14018
14091
  } else {
14019
14092
  return input => {
@@ -14021,31 +14094,72 @@ function performTasksInParallelFunction(config) {
14021
14094
  return Promise.resolve();
14022
14095
  }
14023
14096
  return new Promise(async (resolve, reject) => {
14024
- const maxPromisesToRunAtOneTime = Math.min(maxParallelTasks, input.length);
14025
- const endIndex = input.length;
14026
- let i = 0;
14097
+ const taskKeyFactory = nonConcurrentTaskKeyFactory != null ? nonConcurrentTaskKeyFactory : defaultNonConcurrentTaskKeyFactory;
14098
+ const maxPromisesToRunAtOneTime = Math.min(maxParallelTasks != null ? maxParallelTasks : 100, input.length);
14099
+ const incompleteTasks = input.map(x => [x, taskKeyFactory(x)]).reverse(); // reverse to use push/pop
14100
+
14101
+ let currentRunIndex = 0;
14027
14102
  let finishedParallels = 0;
14028
14103
  let hasEncounteredFailure = false;
14029
14104
 
14105
+ /**
14106
+ * Set of tasks keys that are currently running.
14107
+ */
14108
+ const currentParellelTaskKeys = new Set();
14109
+ const waitingConcurrentTasks = multiValueMapBuilder();
14110
+ function getNextTask() {
14111
+ let nextTask = undefined;
14112
+ while (!nextTask) {
14113
+ nextTask = incompleteTasks.pop();
14114
+ if (nextTask) {
14115
+ const key = nextTask[1];
14116
+ if (currentParellelTaskKeys.has(key)) {
14117
+ waitingConcurrentTasks.addTuples(key, nextTask); // wrap the tuple in an array to add it properly.
14118
+ nextTask = undefined; // clear to continue loop
14119
+ } else {
14120
+ currentParellelTaskKeys.add(key); // add to the current task keys, exit loop
14121
+ break;
14122
+ }
14123
+ } else {
14124
+ break; // no tasks remaining, break.
14125
+ }
14126
+ }
14127
+
14128
+ return nextTask;
14129
+ }
14130
+ function onTaskCompleted(task) {
14131
+ const key = task[1];
14132
+ currentParellelTaskKeys.delete(key);
14133
+ const waitingForKey = waitingConcurrentTasks.get(key);
14134
+ const nextWaitingTask = waitingForKey.shift(); // take from the front to retain unique task order
14135
+
14136
+ if (nextWaitingTask) {
14137
+ incompleteTasks.push(nextWaitingTask); // push to front for the next dispatch to take
14138
+ }
14139
+ }
14140
+
14030
14141
  // start initial promises
14031
14142
  function dispatchNextPromise() {
14032
- const hasNext = i < endIndex;
14033
- if (hasNext && !hasEncounteredFailure) {
14034
- const value = input[i];
14035
- const promise = taskFactory(value, i);
14036
- i += 1;
14037
- promise.then(() => {
14038
- setTimeout(dispatchNextPromise, waitBetweenTasks);
14039
- }, e => {
14040
- hasEncounteredFailure = true;
14041
- reject(e);
14042
- });
14043
- } else if (!hasNext) {
14044
- finishedParallels += 1;
14045
-
14046
- // only resolve after the last parallel is complete
14047
- if (finishedParallels === maxPromisesToRunAtOneTime) {
14048
- resolve();
14143
+ // if a failure has been encountered then the promise has already been rejected.
14144
+ if (!hasEncounteredFailure) {
14145
+ const nextTask = getNextTask();
14146
+ if (nextTask) {
14147
+ const promise = taskFactory(nextTask[0], currentRunIndex, nextTask[1]);
14148
+ currentRunIndex += 1;
14149
+ promise.then(() => {
14150
+ onTaskCompleted(nextTask);
14151
+ setTimeout(dispatchNextPromise, waitBetweenTasks);
14152
+ }, e => {
14153
+ hasEncounteredFailure = true;
14154
+ reject(e);
14155
+ });
14156
+ } else {
14157
+ finishedParallels += 1;
14158
+
14159
+ // only resolve after the last parallel is complete
14160
+ if (finishedParallels === maxPromisesToRunAtOneTime) {
14161
+ resolve();
14162
+ }
14049
14163
  }
14050
14164
  }
14051
14165
  }
@@ -15740,4 +15854,4 @@ async function iterateFilteredPages(inputPage, loadFn, iterFn) {
15740
15854
  return count;
15741
15855
  }
15742
15856
 
15743
- export { ALL_DOUBLE_SLASHES_REGEX, ALL_SLASHES_REGEX, ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX, ASSERTION_ERROR_CODE, ASSERTION_HANDLER, AUTH_ADMIN_ROLE, AUTH_ONBOARDED_ROLE, AUTH_ROLE_CLAIMS_DEFAULT_CLAIM_VALUE, AUTH_ROLE_CLAIMS_DEFAULT_EMPTY_VALUE, AUTH_TOS_SIGNED_ROLE, AUTH_USER_ROLE, AbstractUniqueModel, Assert, AssertMax, AssertMin, AssertionError, AssertionIssueHandler, BooleanKeyArrayUtilityInstance, BooleanStringKeyArrayUtilityInstance, CATCH_ALL_HANDLE_RESULT_KEY, CUT_VALUE_TO_ZERO_PRECISION, DATE_NOW_VALUE, DEFAULT_LAT_LNG_STRING_VALUE, DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG, DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG, DEFAULT_READABLE_ERROR_CODE, DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS, DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT, DEFAULT_UNKNOWN_MODEL_TYPE_STRING, DOLLAR_AMOUNT_PRECISION, DOLLAR_AMOUNT_STRING_REGEX, DataDoesNotExistError, DataIsExpiredError, Day, DestroyFunctionObject, E164PHONE_NUMBER_REGEX, E164PHONE_NUMBER_WITH_EXTENSION_REGEX, E164PHONE_NUMBER_WITH_OPTIONAL_EXTENSION_REGEX, FINAL_PAGE, FIRST_PAGE, FRACTIONAL_HOURS_PRECISION_FUNCTION, FullStorageObject, HAS_WEBSITE_DOMAIN_NAME_REGEX, HOURS_IN_DAY, HTTP_OR_HTTPS_REGEX, HashSet, ISO8601_DAY_STRING_REGEX, ISO8601_DAY_STRING_START_REGEX, ISO_8601_DATE_STRING_REGEX, KeyValueTypleValueFilter, LAT_LNG_PATTERN, LAT_LNG_PATTERN_MAX_PRECISION, LAT_LONG_100KM_PRECISION, LAT_LONG_100M_PRECISION, LAT_LONG_10CM_PRECISION, LAT_LONG_10KM_PRECISION, LAT_LONG_10M_PRECISION, LAT_LONG_1CM_PRECISION, LAT_LONG_1KM_PRECISION, LAT_LONG_1MM_PRECISION, LAT_LONG_1M_PRECISION, LAT_LONG_GRAINS_OF_SAND_PRECISION, LEADING_SLASHES_REGEX, MAP_IDENTITY, MAX_BITWISE_SET_SIZE, MAX_LATITUDE_VALUE, MAX_LONGITUDE_VALUE, MINUTES_IN_DAY, MINUTES_IN_HOUR, MIN_LATITUDE_VALUE, MIN_LONGITUDE_VALUE, MONTH_DAY_SLASH_DATE_STRING_REGEX, MS_IN_DAY, MS_IN_HOUR, MS_IN_MINUTE, MS_IN_SECOND, MemoryStorageInstance, ModelRelationUtility, NOOP_MODIFIER, PHONE_EXTENSION_NUMBER_REGEX, PRIMATIVE_KEY_DENCODER_VALUE, PageCalculator, PropertyDescriptorUtility, REGEX_SPECIAL_CHARACTERS, REGEX_SPECIAL_CHARACTERS_SET, RelationChange, SECONDS_IN_MINUTE, SHARED_MEMORY_STORAGE, SLASH_PATH_FILE_TYPE_SEPARATOR, SLASH_PATH_SEPARATOR, SORT_VALUE_EQUAL, SORT_VALUE_GREATER_THAN, SORT_VALUE_LESS_THAN, ServerErrorResponse, SetDeltaChange, SimpleStorageObject, StorageObject, StorageObjectUtility, StoredDataError, SyncState, TOTAL_LATITUDE_RANGE, TOTAL_LONGITUDE_RANGE, TOTAL_SPAN_OF_LONGITUDE, TRAILING_FILE_TYPE_SEPARATORS_REGEX, TRAILING_SLASHES_REGEX, TimeAM, TypedServiceRegistryInstance, UNLOADED_PAGE, US_STATE_CODE_STRING_REGEX, UTC_DATE_STRING_REGEX, UTC_TIMEZONE_STRING, UTF_8_START_CHARACTER, UTF_PRIVATE_USAGE_AREA_START, UnauthorizedServerErrorResponse, WEB_PROTOCOL_PREFIX_REGEX, ZIP_CODE_STRING_REGEX, addHttpToUrl, addLatLngPoints, addModifiers, addPlusPrefixToNumber, addPrefix, addPrefixFunction, addSuffix, addSuffixFunction, addToSet, addToSetCopy, allFalsyOrEmptyKeys, allIndexesInIndexRange, allKeyValueTuples, allMaybeSoKeys, allNonUndefinedKeys, allObjectsAreEqual, allValuesAreMaybeNot, allValuesAreNotMaybe, applyBestFit, applyToMultipleFields, areEqualContext, areEqualPOJOValues, arrayContainsDuplicateValue, arrayContentsDiffer, arrayDecision, arrayDecisionFunction, arrayFactory, arrayInputFactory, arrayToLowercase, arrayToMap, arrayToObject, arrayToUppercase, asArray, asDecisionFunction, asGetter, asIndexRangeCheckFunctionConfig, asIterable, asNumber, asObjectCopyFactory, asPromise, asSet, assignValuesToPOJO, assignValuesToPOJOFunction, authClaims, authRoleClaimsService, authRolesSetHasRoles, baseWebsiteUrl, batch, batchCalc, bitwiseObjectDencoder, bitwiseObjectEncoder, bitwiseObjectdecoder, bitwiseSetDecoder, bitwiseSetDencoder, booleanFactory, boundNumber, boundNumberFunction, boundToRectangle, build, cachedGetter, capLatValue, capitalizeFirstLetter, caseInsensitiveFilterByIndexOfDecisionFactory, caseInsensitiveString, catchAllHandlerKey, chainMapFunction, chainMapSameFunctions, coerceToEmailParticipants, combineMaps, compareEqualityWithValueFromItemsFunction, compareEqualityWithValueFromItemsFunctionFactory, compareFnOrder, computeNextFractionalHour, computeNextFreeIndexFunction, concatArrays, concatArraysUnique, containsAllStringsAnyCase, containsAllValues, containsAnyStringAnyCase, containsAnyValue, containsAnyValueFromSet, containsNoValueFromSet, containsNoneOfValue, containsStringAnyCase, convertEmailParticipantStringToParticipant, convertMaybeToArray, convertParticipantToEmailParticipantString, convertToArray, copyArray, copyField, copyLatLngBound, copyLatLngPoint, copyObject, copySetAndDo, countPOJOKeys, countPOJOKeysFunction, cronExpressionRepeatingEveryNMinutes, cssClassesSet, cutToPrecision, cutValueToInteger, cutValueToPrecision, cutValueToPrecisionFunction, dateFromLogicalDate, dayOfWeek, daysOfWeekArray, daysOfWeekFromEnabledDays, daysOfWeekNameFunction, daysOfWeekNameMap, decisionFunction, decodeHashedValues, decodeHashedValuesWithDecodeMap, decodeModelKeyTypePair, defaultFilterFromPOJOFunctionNoCopy, defaultForwardFunctionFactory, defaultLatLngPoint, defaultLatLngString, dencodeBitwiseSet, diffLatLngBoundPoints, diffLatLngPoints, dollarAmountString, e164PhoneNumberExtensionPair, e164PhoneNumberFromE164PhoneNumberExtensionPair, enabledDaysFromDaysOfWeek, encodeBitwiseSet, encodeModelKeyTypePair, errorMessageContainsString, errorMessageContainsStringFunction, escapeStringForRegex, excludeValues, excludeValuesFromArray, excludeValuesFromSet, existsInIterable, expandArrayMapTuples, expandArrayValueTuples, expandFlattenTreeFunction, expandIndexSet, expandTreeFunction, expandTrees, extendLatLngBound, filterAndMapFunction, filterEmptyValues, filterFalsyAndEmptyValues, filterFromIterable, filterFromPOJO, filterFromPOJOFunction, filterKeyValueTupleFunction, filterKeyValueTuples, filterKeyValueTuplesFunction, filterKeyValueTuplesInputToFilter, filterMaybeValues, filterNullAndUndefinedValues, filterOnlyUndefinedValues, filterUndefinedValues, filterUniqueCaseInsensitiveStrings, filterUniqueFunction, filterUniqueTransform, filterUniqueValues, filterValuesByDistance, filterValuesByDistanceNoOrder, filterValuesToSet, filterValuesUsingSet, filteredPage, findAllCharacterOccurences, findAllCharacterOccurencesFunction, findBest, findBestIndexMatch, findBestIndexMatchFunction, findBestIndexSetPair, findFirstCharacterOccurence, findInIterable, findIndexOfFirstDuplicateValue, findItemsByIndex, findNext, findPOJOKeys, findPOJOKeysFunction, findStringsRegexString, findToIndexSet, findValuesFrom, firstAndLastCharacterOccurrence, firstAndLastValue, firstValue, firstValueFromIterable, fitToIndexRangeFunction, fixExtraQueryParameters, fixMultiSlashesInSlashPath, flattenArray, flattenArrayOrValueArray, flattenArrayToSet, flattenArrayUnique, flattenArrayUniqueCaseInsensitiveStrings, flattenTree, flattenTreeToArray, flattenTreeToArrayFunction, flattenTrees, forEachInIterable, forEachKeyValue, forEachKeyValueOnPOJOFunction, forEachWithArray, forwardFunction, fractionalHoursToMinutes, generateIfDoesNotExist, getArrayNextIndex, getDayOffset, getDayTomorrow, getDayYesterday, getDaysOfWeekNames, getFunctionType, getNextDay, getNextPageNumber, getOverlappingRectangle, getPageNumber, getPreviousDay, getValueFromGetter, groupValues, handlerBindAccessor, handlerConfigurerFactory, handlerFactory, handlerMappedSetFunction, handlerMappedSetFunctionFactory, handlerSetFunction, hasDifferentStringsNoCase, hasDifferentValues, hasHttpPrefix, hasNonNullValue, hasSameTimezone, hasSameValues, hasValueFunction, hasValueOrNotEmpty, hasValueOrNotEmptyObject, hasWebsiteDomain, hashSetForIndexed, hourToFractionalHour, idBatchFactory, incrementingNumberFactory, indexDeltaGroup, indexDeltaGroupFunction, indexRange, indexRangeCheckFunction, indexRangeCheckReaderFunction, indexRangeForArray, indexRangeOverlapsIndexRange, indexRangeOverlapsIndexRangeFunction, indexRangeReaderPairFactory, indexedValuesArrayAccessorFactory, insertIntoBooleanKeyArray, invertBooleanReturnFunction, invertDecision, invertFilter, isAllowed, isClassLikeType, isCompleteUnitedStatesAddress, isConsideredUtcTimezoneString, isDate, isDefaultLatLngPoint, isDefaultLatLngPointValue, isDefaultReadableError, isDefinedAndNotFalse, isDollarAmountString, isE164PhoneNumber, isE164PhoneNumberWithExtension, isEmptyIterable, isEqualContext, isEvenNumber, isFalseBooleanKeyArray, isFinalPage, isGetter, isISO8601DateString, isISO8601DayString, isISO8601DayStringStart, isInAllowedDaysOfWeekSet, isInNumberBoundFunction, isInSetDecisionFunction, isIndexNumberInIndexRange, isIndexNumberInIndexRangeFunction, isIndexRangeInIndexRange, isIndexRangeInIndexRangeFunction, isIterable, isLatLngBound, isLatLngBoundWithinLatLngBound, isLatLngPoint, isLatLngPointWithinLatLngBound, isLatLngString, isLogicalDateStringCode, isMapIdentityFunction, isMaybeNot, isMaybeNotOrTrue, isMaybeSo, isModelKey, isMonthDaySlashDate, isNonClassFunction, isNotNullOrEmptyString, isNumberDivisibleBy, isObjectWithConstructor, isOddNumber, isPromise, isPromiseLike, isSameLatLngBound, isSameLatLngPoint, isSameNonNullValue, isSameVector, isSelectedDecisionFunctionFactory, isSelectedIndexDecisionFunction, isServerError, isSlashPathFile, isSlashPathFolder, isSlashPathTypedFile, isStringOrTrue, isTrueBooleanKeyArray, isUTCDateString, isUsStateCodeString, isValidLatLngPoint, isValidLatitude, isValidLongitude, isValidNumberBound, isValidPhoneExtensionNumber, isValidSlashPath, isWebsiteUrl, isWebsiteUrlWithPrefix, isWithinLatLngBoundFunction, isolateSlashPath, isolateSlashPathFunction, isolateWebsitePathFunction, itemCountForBatchIndex, iterableToArray, iterableToMap, iterablesAreSetEquivalent, iterate, iterateFilteredPages, joinHostAndPort, joinStringsWithSpaces, keepCharactersAfterFirstCharacterOccurence, keepCharactersAfterFirstCharacterOccurenceFunction, keepFromSetCopy, keepValuesFromArray, keepValuesFromSet, keyValueMapFactory, lastValue, latLngBound, latLngBoundCenterPoint, latLngBoundEastBound, latLngBoundFromInput, latLngBoundFullyWrapsMap, latLngBoundFunction, latLngBoundNorthBound, latLngBoundNorthEastPoint, latLngBoundNorthWestPoint, latLngBoundOverlapsLatLngBound, latLngBoundSouthBound, latLngBoundSouthEastPoint, latLngBoundSouthWestPoint, latLngBoundStrictlyWrapsMap, latLngBoundTuple, latLngBoundTupleFunction, latLngBoundWestBound, latLngBoundWrapsMap, latLngDataPointFunction, latLngPoint, latLngPointFromString, latLngPointFunction, latLngPointPrecisionFunction, latLngString, latLngStringFunction, latLngTuple, latLngTupleFunction, limitArray, lonLatTuple, lowercaseFirstLetter, mailToUrlString, makeBestFit, makeCopyModelFieldFunction, makeDateMonthForMonthOfYear, makeGetter, makeHandler, makeHashDecodeMap, makeKeyPairs, makeModelConversionFieldValuesFunction, makeModelMap, makeModelMapFunctions, makeMultiModelKeyMap, makeValuesGroupMap, makeWithFactory, makeWithFactoryInput, mapArrayFunction, mapFunctionOutput, mapFunctionOutputPair, mapGetter, mapGetterFactory, mapIdentityFunction, mapIterable, mapKeysIntersectionObjectToArray, mapMaybeFunction, mapObjectMap, mapObjectMapFunction, mapObjectToTargetObject, mapPromiseOrValue, mapToObject, mapToTuples, mapValuesToSet, mappedUseAsyncFunction, mappedUseFunction, mapsHaveSameKeys, maybeMergeModelModifiers, maybeMergeModifiers, maybeModifierMapToFunction, maybeSet, mergeArrayIntoArray, mergeArrayOrValueIntoArray, mergeArrays, mergeArraysIntoArray, mergeFilterFunctions, mergeIntoArray, mergeModifiers, mergeObjects, mergeObjectsFunction, mergeSlashPaths, messageFromError, minAndMaxFunction, minAndMaxIndex, minAndMaxIndexFunction, minAndMaxIndexItemsFunction, minAndMaxNumber, minutesToFractionalHours, modelFieldConversions, modelFieldMapFunction, modelFieldMapFunctions, modelTypeDataPairFactory, modifier, modifierMapToFunction, modifyModelMapFunction, modifyModelMapFunctions, monthDaySlashDateToDateString, monthOfYearFromDate, monthOfYearFromDateMonth, multiKeyValueMapFactory, multiValueMapBuilder, neMostLatLngPoint, nearestDivisibleValues, objectCopyFactory, objectDeltaArrayCompressor, objectFieldEqualityChecker, objectFlatMergeMatrix, objectHasKey, objectHasKeys, objectHasNoKeys, objectIsEmpty, objectKeyEqualityComparatorFunction, objectKeysEqualityComparatorFunction, objectMergeMatrix, objectToMap, objectToTuples, overlapsLatLngBoundFunction, overrideInObject, overrideInObjectFunctionFactory, pairGroupValues, parseISO8601DayStringToUTCDate, partialServerError, passThrough, percentNumberFromDecimal, percentNumberToDecimal, performAsyncTask, performAsyncTasks, performBatchLoop, performMakeLoop, performTaskCountLoop, performTaskLoop, performTasksInParallel, performTasksInParallelFunction, pickOneRandomly, poll, primativeKeyDencoder, primativeKeyDencoderMap, primativeKeyStringDencoder, primativeValuesDelta, promiseReference, protectedFactory, pushArrayItemsIntoArray, pushElementOntoArray, pushItemOrArrayItemsIntoArray, randomArrayFactory, randomArrayIndex, randomBoolean, randomEmailFactory, randomFromArrayFactory, randomLatLngFactory, randomLatLngFromCenterFactory, randomNumber, randomNumberFactory, randomPhoneNumberFactory, randomPickFactory, range, rangedIndexedValuesArrayAccessorFactory, rangedIndexedValuesArrayAccessorInfoFactory, readBooleanKeySafetyWrap, readDomainFromEmailAddress, readDomainsFromEmailAddresses, readEmailDomainFromUrlOrEmailAddress, readIndexNumber, readKeysFrom, readKeysFromFilterUniqueFunctionAdditionalKeys, readKeysFromFilterUniqueFunctionAdditionalKeysInput, readKeysFunction, readKeysSetFrom, readKeysSetFunction, readKeysToMap, readModelKey, readModelKeyFromObject, readModelKeys, readModelKeysFromObjects, readMultipleKeysToMap, readUniqueModelKey, readableError, readableStreamToBase64, readableStreamToBuffer, readableStreamToStringFunction, rectangleOverlapsRectangle, reduceBooleansFn, reduceBooleansWithAnd, reduceBooleansWithAndFn, reduceBooleansWithOr, reduceBooleansWithOrFn, reduceNumbers, reduceNumbersFn, reduceNumbersWithAdd, reduceNumbersWithAddFn, reduceNumbersWithMax, reduceNumbersWithMaxFn, reduceNumbersWithMin, reduceNumbersWithMinFn, removeByKeyFromBooleanKeyArray, removeCharactersAfterFirstCharacterOccurence, removeCharactersAfterFirstCharacterOccurenceFunction, removeExtensionFromPhoneNumber, removeFromBooleanKeyArray, removeFromSet, removeFromSetCopy, removeHttpFromUrl, removeModelsWithKey, removeModelsWithSameKey, removeModifiers, removeTrailingFileTypeSeparators, removeTrailingSlashes, removeWebProtocolPrefix, repeatString, replaceCharacterAtIndexIf, replaceCharacterAtIndexWith, replaceInvalidFilePathTypeSeparatorsInSlashPath, replaceInvalidFilePathTypeSeparatorsInSlashPathFunction, replaceLastCharacterIf, replaceLastCharacterIfIsFunction, replaceMultipleFilePathsInSlashPath, replaceStringsFunction, requireModelKey, restoreOrder, restoreOrderWithValues, reverseCompareFn, roundNumberToStepFunction, roundNumberUpToStep, roundToPrecision, roundToPrecisionFunction, roundingFunction, runAsyncTaskForValue, runAsyncTasksForValues, safeCompareEquality, safeEqualityComparatorFunction, safeFindBestIndexMatch, searchStringFilterFunction, separateValues, separateValuesToSets, serverError, setContainsAllValues, setContainsAnyValue, setContainsNoneOfValue, setDeltaChangeKeys, setDeltaFunction, setHasValueFunction, setIncludes, setIncludesFunction, setKeysOnMap, setWebProtocolPrefix, setsAreEquivalent, simpleSortValuesFunctionWithSortRef, slashPathFactory, slashPathInvalidError, slashPathName, slashPathParts, slashPathStartTypeFactory, slashPathType, slashPathValidationFactory, sliceIndexRangeFunction, sortAscendingIndexNumberRefFunction, sortByIndexAscendingCompareFunction, sortByIndexRangeAscendingCompareFunction, sortByLabelFunction, sortByNumberFunction, sortByStringFunction, sortCompareNumberFunction, sortNumbersAscendingFunction, sortValues, sortValuesFunctionOrMapIdentityWithSortRef, sortValuesFunctionWithSortRef, spaceSeparatedCssClasses, splitCommaSeparatedString, splitCommaSeparatedStringToSet, splitJoinNameString, splitJoinRemainder, splitStringAtFirstCharacterOccurence, splitStringAtFirstCharacterOccurenceFunction, splitStringAtIndex, stepsFromIndex, stepsFromIndexFunction, stringToLowercaseFunction, stringToUppercaseFunction, stringTrimFunction, sumOfIntegersBetween, swMostLatLngPoint, symmetricDifferenceArray, symmetricDifferenceArrayBetweenSets, symmetricDifferenceWithModels, takeFront, takeLast, takeValuesFromIterable, telUrlString, telUrlStringForE164PhoneNumberPair, throwKeyIsRequired, toAbsoluteSlashPathStartType, toCaseInsensitiveStringArray, toModelFieldConversions, toModelMapFunctions, toReadableError, toRelativeSlashPathStartType, toggleInSet, toggleInSetCopy, transformNumberFunction, transformStringFunction, transformStrings, trimArray, typedServiceRegistry, unique, uniqueCaseInsensitiveStrings, uniqueCaseInsensitiveStringsSet, uniqueKeys, uniqueModels, unitedStatesAddressString, urlWithoutParameters, useAsync, useCallback, useContextFunction, useIterableOrValue, useModelOrKey, usePromise, useValue, validLatLngPoint, validLatLngPointFunction, valueAtIndex, valuesAreBothNullishOrEquivalent, valuesFromPOJO, valuesFromPOJOFunction, vectorMinimumSizeResizeFunction, vectorsAreEqual, waitForMs, websiteDomainAndPathPair, websiteDomainAndPathPairFromWebsiteUrl, websitePathAndQueryPair, websitePathFromWebsiteDomainAndPath, websitePathFromWebsiteUrl, websiteUrlFromPaths, wrapIndexRangeFunction, wrapLatLngPoint, wrapLngValue, wrapMapFunctionOutput, wrapNumberFunction, wrapUseAsyncFunction, wrapUseFunction };
15857
+ export { ALL_DOUBLE_SLASHES_REGEX, ALL_SLASHES_REGEX, ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX, ASSERTION_ERROR_CODE, ASSERTION_HANDLER, AUTH_ADMIN_ROLE, AUTH_ONBOARDED_ROLE, AUTH_ROLE_CLAIMS_DEFAULT_CLAIM_VALUE, AUTH_ROLE_CLAIMS_DEFAULT_EMPTY_VALUE, AUTH_TOS_SIGNED_ROLE, AUTH_USER_ROLE, AbstractUniqueModel, Assert, AssertMax, AssertMin, AssertionError, AssertionIssueHandler, BooleanKeyArrayUtilityInstance, BooleanStringKeyArrayUtilityInstance, CATCH_ALL_HANDLE_RESULT_KEY, CUT_VALUE_TO_ZERO_PRECISION, DATE_NOW_VALUE, DEFAULT_LAT_LNG_STRING_VALUE, DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG, DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG, DEFAULT_READABLE_ERROR_CODE, DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS, DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT, DEFAULT_UNKNOWN_MODEL_TYPE_STRING, DOLLAR_AMOUNT_PRECISION, DOLLAR_AMOUNT_STRING_REGEX, DataDoesNotExistError, DataIsExpiredError, Day, DestroyFunctionObject, E164PHONE_NUMBER_REGEX, E164PHONE_NUMBER_WITH_EXTENSION_REGEX, E164PHONE_NUMBER_WITH_OPTIONAL_EXTENSION_REGEX, FINAL_PAGE, FIRST_PAGE, FRACTIONAL_HOURS_PRECISION_FUNCTION, FullStorageObject, HAS_WEBSITE_DOMAIN_NAME_REGEX, HOURS_IN_DAY, HTTP_OR_HTTPS_REGEX, HashSet, ISO8601_DAY_STRING_REGEX, ISO8601_DAY_STRING_START_REGEX, ISO_8601_DATE_STRING_REGEX, KeyValueTypleValueFilter, LAT_LNG_PATTERN, LAT_LNG_PATTERN_MAX_PRECISION, LAT_LONG_100KM_PRECISION, LAT_LONG_100M_PRECISION, LAT_LONG_10CM_PRECISION, LAT_LONG_10KM_PRECISION, LAT_LONG_10M_PRECISION, LAT_LONG_1CM_PRECISION, LAT_LONG_1KM_PRECISION, LAT_LONG_1MM_PRECISION, LAT_LONG_1M_PRECISION, LAT_LONG_GRAINS_OF_SAND_PRECISION, LEADING_SLASHES_REGEX, MAP_IDENTITY, MAX_BITWISE_SET_SIZE, MAX_LATITUDE_VALUE, MAX_LONGITUDE_VALUE, MINUTES_IN_DAY, MINUTES_IN_HOUR, MIN_LATITUDE_VALUE, MIN_LONGITUDE_VALUE, MONTH_DAY_SLASH_DATE_STRING_REGEX, MS_IN_DAY, MS_IN_HOUR, MS_IN_MINUTE, MS_IN_SECOND, MemoryStorageInstance, ModelRelationUtility, NOOP_MODIFIER, PHONE_EXTENSION_NUMBER_REGEX, PRIMATIVE_KEY_DENCODER_VALUE, PageCalculator, PropertyDescriptorUtility, REGEX_SPECIAL_CHARACTERS, REGEX_SPECIAL_CHARACTERS_SET, RelationChange, SECONDS_IN_MINUTE, SHARED_MEMORY_STORAGE, SLASH_PATH_FILE_TYPE_SEPARATOR, SLASH_PATH_SEPARATOR, SORT_VALUE_EQUAL, SORT_VALUE_GREATER_THAN, SORT_VALUE_LESS_THAN, ServerErrorResponse, SetDeltaChange, SimpleStorageObject, StorageObject, StorageObjectUtility, StoredDataError, SyncState, TOTAL_LATITUDE_RANGE, TOTAL_LONGITUDE_RANGE, TOTAL_SPAN_OF_LONGITUDE, TRAILING_FILE_TYPE_SEPARATORS_REGEX, TRAILING_SLASHES_REGEX, TimeAM, TypedServiceRegistryInstance, UNLOADED_PAGE, US_STATE_CODE_STRING_REGEX, UTC_DATE_STRING_REGEX, UTC_TIMEZONE_STRING, UTF_8_START_CHARACTER, UTF_PRIVATE_USAGE_AREA_START, UnauthorizedServerErrorResponse, WEB_PROTOCOL_PREFIX_REGEX, ZIP_CODE_STRING_REGEX, addHttpToUrl, addLatLngPoints, addModifiers, addPlusPrefixToNumber, addPrefix, addPrefixFunction, addSuffix, addSuffixFunction, addToSet, addToSetCopy, allFalsyOrEmptyKeys, allIndexesInIndexRange, allKeyValueTuples, allMaybeSoKeys, allNonUndefinedKeys, allObjectsAreEqual, allValuesAreMaybeNot, allValuesAreNotMaybe, applyBestFit, applyToMultipleFields, areEqualContext, areEqualPOJOValues, arrayContainsDuplicateValue, arrayContentsDiffer, arrayDecision, arrayDecisionFunction, arrayFactory, arrayInputFactory, arrayToLowercase, arrayToMap, arrayToObject, arrayToUppercase, asArray, asDecisionFunction, asGetter, asIndexRangeCheckFunctionConfig, asIterable, asNumber, asObjectCopyFactory, asPromise, asSet, assignValuesToPOJO, assignValuesToPOJOFunction, authClaims, authRoleClaimsService, authRolesSetHasRoles, baseWebsiteUrl, batch, batchCalc, bitwiseObjectDencoder, bitwiseObjectEncoder, bitwiseObjectdecoder, bitwiseSetDecoder, bitwiseSetDencoder, booleanFactory, boundNumber, boundNumberFunction, boundToRectangle, build, cachedGetter, capLatValue, capitalizeFirstLetter, caseInsensitiveFilterByIndexOfDecisionFactory, caseInsensitiveString, catchAllHandlerKey, chainMapFunction, chainMapSameFunctions, coerceToEmailParticipants, combineMaps, compareEqualityWithValueFromItemsFunction, compareEqualityWithValueFromItemsFunctionFactory, compareFnOrder, computeNextFractionalHour, computeNextFreeIndexFunction, concatArrays, concatArraysUnique, containsAllStringsAnyCase, containsAllValues, containsAnyStringAnyCase, containsAnyValue, containsAnyValueFromSet, containsNoValueFromSet, containsNoneOfValue, containsStringAnyCase, convertEmailParticipantStringToParticipant, convertMaybeToArray, convertParticipantToEmailParticipantString, convertToArray, copyArray, copyField, copyLatLngBound, copyLatLngPoint, copyObject, copySetAndDo, countPOJOKeys, countPOJOKeysFunction, cronExpressionRepeatingEveryNMinutes, cssClassesSet, cutToPrecision, cutValueToInteger, cutValueToPrecision, cutValueToPrecisionFunction, dateFromLogicalDate, dayOfWeek, daysOfWeekArray, daysOfWeekFromEnabledDays, daysOfWeekNameFunction, daysOfWeekNameMap, decisionFunction, decodeHashedValues, decodeHashedValuesWithDecodeMap, decodeModelKeyTypePair, defaultFilterFromPOJOFunctionNoCopy, defaultForwardFunctionFactory, defaultLatLngPoint, defaultLatLngString, dencodeBitwiseSet, diffLatLngBoundPoints, diffLatLngPoints, dollarAmountString, e164PhoneNumberExtensionPair, e164PhoneNumberFromE164PhoneNumberExtensionPair, enabledDaysFromDaysOfWeek, encodeBitwiseSet, encodeModelKeyTypePair, errorMessageContainsString, errorMessageContainsStringFunction, escapeStringForRegex, excludeValues, excludeValuesFromArray, excludeValuesFromSet, existsInIterable, expandArrayMapTuples, expandArrayValueTuples, expandFlattenTreeFunction, expandIndexSet, expandTreeFunction, expandTrees, extendLatLngBound, filterAndMapFunction, filterEmptyValues, filterFalsyAndEmptyValues, filterFromIterable, filterFromPOJO, filterFromPOJOFunction, filterKeyValueTupleFunction, filterKeyValueTuples, filterKeyValueTuplesFunction, filterKeyValueTuplesInputToFilter, filterMaybeValues, filterNullAndUndefinedValues, filterOnlyUndefinedValues, filterUndefinedValues, filterUniqueCaseInsensitiveStrings, filterUniqueFunction, filterUniqueTransform, filterUniqueValues, filterValuesByDistance, filterValuesByDistanceNoOrder, filterValuesToSet, filterValuesUsingSet, filteredPage, findAllCharacterOccurences, findAllCharacterOccurencesFunction, findBest, findBestIndexMatch, findBestIndexMatchFunction, findBestIndexSetPair, findFirstCharacterOccurence, findInIterable, findIndexOfFirstDuplicateValue, findItemsByIndex, findNext, findPOJOKeys, findPOJOKeysFunction, findStringsRegexString, findToIndexSet, findValuesFrom, firstAndLastCharacterOccurrence, firstAndLastValue, firstValue, firstValueFromIterable, fitToIndexRangeFunction, fixExtraQueryParameters, fixMultiSlashesInSlashPath, flattenArray, flattenArrayOrValueArray, flattenArrayToSet, flattenArrayUnique, flattenArrayUniqueCaseInsensitiveStrings, flattenTree, flattenTreeToArray, flattenTreeToArrayFunction, flattenTrees, forEachInIterable, forEachKeyValue, forEachKeyValueOnPOJOFunction, forEachWithArray, forwardFunction, fractionalHoursToMinutes, generateIfDoesNotExist, getArrayNextIndex, getDayOffset, getDayTomorrow, getDayYesterday, getDaysOfWeekNames, getFunctionType, getNextDay, getNextPageNumber, getOverlappingRectangle, getPageNumber, getPreviousDay, getValueFromGetter, groupValues, handlerBindAccessor, handlerConfigurerFactory, handlerFactory, handlerMappedSetFunction, handlerMappedSetFunctionFactory, handlerSetFunction, hasDifferentStringsNoCase, hasDifferentValues, hasHttpPrefix, hasNonNullValue, hasSameTimezone, hasSameValues, hasValueFunction, hasValueOrNotEmpty, hasValueOrNotEmptyObject, hasWebsiteDomain, hashSetForIndexed, hourToFractionalHour, idBatchFactory, incrementingNumberFactory, indexDeltaGroup, indexDeltaGroupFunction, indexRange, indexRangeCheckFunction, indexRangeCheckReaderFunction, indexRangeForArray, indexRangeOverlapsIndexRange, indexRangeOverlapsIndexRangeFunction, indexRangeReaderPairFactory, indexedValuesArrayAccessorFactory, insertIntoBooleanKeyArray, invertBooleanReturnFunction, invertDecision, invertFilter, isAllowed, isClassLikeType, isCompleteUnitedStatesAddress, isConsideredUtcTimezoneString, isDate, isDefaultLatLngPoint, isDefaultLatLngPointValue, isDefaultReadableError, isDefinedAndNotFalse, isDollarAmountString, isE164PhoneNumber, isE164PhoneNumberWithExtension, isEmptyIterable, isEqualContext, isEvenNumber, isFalseBooleanKeyArray, isFinalPage, isGetter, isISO8601DateString, isISO8601DayString, isISO8601DayStringStart, isInAllowedDaysOfWeekSet, isInNumberBoundFunction, isInSetDecisionFunction, isIndexNumberInIndexRange, isIndexNumberInIndexRangeFunction, isIndexRangeInIndexRange, isIndexRangeInIndexRangeFunction, isIterable, isLatLngBound, isLatLngBoundWithinLatLngBound, isLatLngPoint, isLatLngPointWithinLatLngBound, isLatLngString, isLogicalDateStringCode, isMapIdentityFunction, isMaybeNot, isMaybeNotOrTrue, isMaybeSo, isModelKey, isMonthDaySlashDate, isNonClassFunction, isNotNullOrEmptyString, isNumberDivisibleBy, isObjectWithConstructor, isOddNumber, isPromise, isPromiseLike, isSameLatLngBound, isSameLatLngPoint, isSameNonNullValue, isSameVector, isSelectedDecisionFunctionFactory, isSelectedIndexDecisionFunction, isServerError, isSlashPathFile, isSlashPathFolder, isSlashPathTypedFile, isStringOrTrue, isTrueBooleanKeyArray, isUTCDateString, isUsStateCodeString, isValidLatLngPoint, isValidLatitude, isValidLongitude, isValidNumberBound, isValidPhoneExtensionNumber, isValidSlashPath, isWebsiteUrl, isWebsiteUrlWithPrefix, isWithinLatLngBoundFunction, isolateSlashPath, isolateSlashPathFunction, isolateWebsitePathFunction, itemCountForBatchIndex, iterableToArray, iterableToMap, iterablesAreSetEquivalent, iterate, iterateFilteredPages, joinHostAndPort, joinStringsWithSpaces, keepCharactersAfterFirstCharacterOccurence, keepCharactersAfterFirstCharacterOccurenceFunction, keepFromSetCopy, keepValuesFromArray, keepValuesFromSet, keyValueMapFactory, lastValue, latLngBound, latLngBoundCenterPoint, latLngBoundEastBound, latLngBoundFromInput, latLngBoundFullyWrapsMap, latLngBoundFunction, latLngBoundNorthBound, latLngBoundNorthEastPoint, latLngBoundNorthWestPoint, latLngBoundOverlapsLatLngBound, latLngBoundSouthBound, latLngBoundSouthEastPoint, latLngBoundSouthWestPoint, latLngBoundStrictlyWrapsMap, latLngBoundTuple, latLngBoundTupleFunction, latLngBoundWestBound, latLngBoundWrapsMap, latLngDataPointFunction, latLngPoint, latLngPointFromString, latLngPointFunction, latLngPointPrecisionFunction, latLngString, latLngStringFunction, latLngTuple, latLngTupleFunction, limitArray, lonLatTuple, lowercaseFirstLetter, mailToUrlString, makeBestFit, makeCopyModelFieldFunction, makeDateMonthForMonthOfYear, makeGetter, makeHandler, makeHashDecodeMap, makeKeyPairs, makeModelConversionFieldValuesFunction, makeModelMap, makeModelMapFunctions, makeMultiModelKeyMap, makeValuesGroupMap, makeWithFactory, makeWithFactoryInput, mapArrayFunction, mapFunctionOutput, mapFunctionOutputPair, mapGetter, mapGetterFactory, mapIdentityFunction, mapIterable, mapKeysIntersectionObjectToArray, mapMaybeFunction, mapObjectMap, mapObjectMapFunction, mapObjectToTargetObject, mapPromiseOrValue, mapToObject, mapToTuples, mapValuesToSet, mappedUseAsyncFunction, mappedUseFunction, mapsHaveSameKeys, maybeMergeModelModifiers, maybeMergeModifiers, maybeModifierMapToFunction, maybeSet, mergeArrayIntoArray, mergeArrayOrValueIntoArray, mergeArrays, mergeArraysIntoArray, mergeFilterFunctions, mergeIntoArray, mergeModifiers, mergeObjects, mergeObjectsFunction, mergeSlashPaths, messageFromError, minAndMaxFunction, minAndMaxIndex, minAndMaxIndexFunction, minAndMaxIndexItemsFunction, minAndMaxNumber, minutesToFractionalHours, modelFieldConversions, modelFieldMapFunction, modelFieldMapFunctions, modelTypeDataPairFactory, modifier, modifierMapToFunction, modifyModelMapFunction, modifyModelMapFunctions, monthDaySlashDateToDateString, monthOfYearFromDate, monthOfYearFromDateMonth, multiKeyValueMapFactory, multiValueMapBuilder, neMostLatLngPoint, nearestDivisibleValues, objectCopyFactory, objectDeltaArrayCompressor, objectFieldEqualityChecker, objectFlatMergeMatrix, objectHasKey, objectHasKeys, objectHasNoKeys, objectIsEmpty, objectKeyEqualityComparatorFunction, objectKeysEqualityComparatorFunction, objectMergeMatrix, objectToMap, objectToTuples, overlapsLatLngBoundFunction, overrideInObject, overrideInObjectFunctionFactory, pairGroupValues, parseISO8601DayStringToUTCDate, partialServerError, passThrough, percentNumberFromDecimal, percentNumberToDecimal, performAsyncTask, performAsyncTasks, performBatchLoop, performMakeLoop, performTaskCountLoop, performTaskLoop, performTasksInParallel, performTasksInParallelFunction, pickOneRandomly, poll, primativeKeyDencoder, primativeKeyDencoderMap, primativeKeyStringDencoder, primativeValuesDelta, promiseReference, protectedFactory, pushArrayItemsIntoArray, pushElementOntoArray, pushItemOrArrayItemsIntoArray, randomArrayFactory, randomArrayIndex, randomBoolean, randomEmailFactory, randomFromArrayFactory, randomLatLngFactory, randomLatLngFromCenterFactory, randomNumber, randomNumberFactory, randomPhoneNumberFactory, randomPickFactory, range, rangedIndexedValuesArrayAccessorFactory, rangedIndexedValuesArrayAccessorInfoFactory, readBooleanKeySafetyWrap, readDomainFromEmailAddress, readDomainsFromEmailAddresses, readEmailDomainFromUrlOrEmailAddress, readIndexNumber, readKeysFrom, readKeysFromFilterUniqueFunctionAdditionalKeys, readKeysFromFilterUniqueFunctionAdditionalKeysInput, readKeysFunction, readKeysSetFrom, readKeysSetFunction, readKeysToMap, readModelKey, readModelKeyFromObject, readModelKeys, readModelKeysFromObjects, readMultipleKeysToMap, readUniqueModelKey, readableError, readableStreamToBase64, readableStreamToBuffer, readableStreamToStringFunction, rectangleOverlapsRectangle, reduceBooleansFn, reduceBooleansWithAnd, reduceBooleansWithAndFn, reduceBooleansWithOr, reduceBooleansWithOrFn, reduceNumbers, reduceNumbersFn, reduceNumbersWithAdd, reduceNumbersWithAddFn, reduceNumbersWithMax, reduceNumbersWithMaxFn, reduceNumbersWithMin, reduceNumbersWithMinFn, removeByKeyFromBooleanKeyArray, removeCharactersAfterFirstCharacterOccurence, removeCharactersAfterFirstCharacterOccurenceFunction, removeExtensionFromPhoneNumber, removeFromBooleanKeyArray, removeFromSet, removeFromSetCopy, removeHttpFromUrl, removeModelsWithKey, removeModelsWithSameKey, removeModifiers, removeTrailingFileTypeSeparators, removeTrailingSlashes, removeWebProtocolPrefix, repeatString, replaceCharacterAtIndexIf, replaceCharacterAtIndexWith, replaceInvalidFilePathTypeSeparatorsInSlashPath, replaceInvalidFilePathTypeSeparatorsInSlashPathFunction, replaceLastCharacterIf, replaceLastCharacterIfIsFunction, replaceMultipleFilePathsInSlashPath, replaceStringsFunction, requireModelKey, restoreOrder, restoreOrderWithValues, reverseCompareFn, roundNumberToStepFunction, roundNumberUpToStep, roundToPrecision, roundToPrecisionFunction, roundingFunction, runAsyncTaskForValue, runAsyncTasksForValues, safeCompareEquality, safeEqualityComparatorFunction, safeFindBestIndexMatch, searchStringFilterFunction, separateValues, separateValuesToSets, serverError, setContainsAllValues, setContainsAnyValue, setContainsNoneOfValue, setDeltaChangeKeys, setDeltaFunction, setHasValueFunction, setIncludes, setIncludesFunction, setKeysOnMap, setWebProtocolPrefix, setsAreEquivalent, simpleSortValuesFunctionWithSortRef, slashPathFactory, slashPathInvalidError, slashPathName, slashPathParts, slashPathStartTypeFactory, slashPathType, slashPathValidationFactory, sliceIndexRangeFunction, sortAscendingIndexNumberRefFunction, sortByIndexAscendingCompareFunction, sortByIndexRangeAscendingCompareFunction, sortByLabelFunction, sortByNumberFunction, sortByStringFunction, sortCompareNumberFunction, sortNumbersAscendingFunction, sortValues, sortValuesFunctionOrMapIdentityWithSortRef, sortValuesFunctionWithSortRef, spaceSeparatedCssClasses, splitCommaSeparatedString, splitCommaSeparatedStringToSet, splitJoinNameString, splitJoinRemainder, splitStringAtFirstCharacterOccurence, splitStringAtFirstCharacterOccurenceFunction, splitStringAtIndex, stepsFromIndex, stepsFromIndexFunction, stringFactoryFromFactory, stringToLowercaseFunction, stringToUppercaseFunction, stringTrimFunction, sumOfIntegersBetween, swMostLatLngPoint, symmetricDifferenceArray, symmetricDifferenceArrayBetweenSets, symmetricDifferenceWithModels, takeFront, takeLast, takeValuesFromIterable, telUrlString, telUrlStringForE164PhoneNumberPair, throwKeyIsRequired, toAbsoluteSlashPathStartType, toCaseInsensitiveStringArray, toModelFieldConversions, toModelMapFunctions, toReadableError, toRelativeSlashPathStartType, toggleInSet, toggleInSetCopy, transformNumberFunction, transformStringFunction, transformStrings, trimArray, typedServiceRegistry, unique, uniqueCaseInsensitiveStrings, uniqueCaseInsensitiveStringsSet, uniqueKeys, uniqueModels, unitedStatesAddressString, urlWithoutParameters, useAsync, useCallback, useContextFunction, useIterableOrValue, useModelOrKey, usePromise, useValue, validLatLngPoint, validLatLngPointFunction, valueAtIndex, valuesAreBothNullishOrEquivalent, valuesFromPOJO, valuesFromPOJOFunction, vectorMinimumSizeResizeFunction, vectorsAreEqual, waitForMs, websiteDomainAndPathPair, websiteDomainAndPathPairFromWebsiteUrl, websitePathAndQueryPair, websitePathFromWebsiteDomainAndPath, websitePathFromWebsiteUrl, websiteUrlFromPaths, wrapIndexRangeFunction, wrapLatLngPoint, wrapLngValue, wrapMapFunctionOutput, wrapNumberFunction, wrapTuples, wrapUseAsyncFunction, wrapUseFunction };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util",
3
- "version": "10.0.8",
3
+ "version": "10.0.10",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./src/index.d.ts",
@@ -79,3 +79,11 @@ export declare function existsInIterable<T>(values: Iterable<T>, fn: DecisionFun
79
79
  * @returns
80
80
  */
81
81
  export declare function filterFromIterable<T>(values: Iterable<T>, fn: DecisionFunction<T>): T[];
82
+ /**
83
+ * Wraps the input tuple values as an array. The tuples should all be the same length in order to wrap them properly, and the tuple value cannot consist of only arrays of the same length.
84
+ *
85
+ * This is used to prevent functions from treating the tuple itself as an array.
86
+ *
87
+ * @param input
88
+ */
89
+ export declare function wrapTuples<T>(input: IterableOrValue<T>): T[];
@@ -1,5 +1,5 @@
1
1
  import { type PrimativeKey, type ReadKeyFunction, type ReadMultipleKeysFunction } from '../key';
2
- import { type IterableOrValue } from '../iterable';
2
+ import { type IterableOrValue } from '../iterable/iterable';
3
3
  import { type Maybe } from '../value/maybe.type';
4
4
  /**
5
5
  * Creates a map by reading keys from the input values. Values without a key are ignored.
@@ -46,8 +46,42 @@ export interface MultiValueMapBuilder<T, K extends PrimativeKey = PrimativeKey>
46
46
  map(): MultiValueMap<T, K>;
47
47
  entries(): [Maybe<K>, T[]][];
48
48
  tuples(): [Maybe<K>, T][];
49
- delete(key: Maybe<K>): void;
49
+ /**
50
+ * Deletes all values from the map with the input key.
51
+ *
52
+ * Returns true if a value was deleted.
53
+ *
54
+ * @param key
55
+ */
56
+ delete(key: Maybe<K>): boolean;
57
+ /**
58
+ * Adds the input key/value pair to the map. Use for inserting all Tuple values.
59
+ *
60
+ * @param key
61
+ * @param value
62
+ */
63
+ addTuples(key: Maybe<K>, value: IterableOrValue<T>): void;
64
+ /**
65
+ * Adds the input key/value(s) pair to the map.
66
+ *
67
+ * Use the addTuple() function if adding a single tuple value to the array.
68
+ *
69
+ * @param key
70
+ * @param value
71
+ */
50
72
  add(key: Maybe<K>, value: IterableOrValue<T>): void;
73
+ /**
74
+ * Returns true if the map contains the input key.
75
+ *
76
+ * @param key
77
+ */
78
+ has(key: Maybe<K>): boolean;
79
+ /**
80
+ * Returns all current values for the input key. If no values are found,
81
+ *
82
+ * @param key
83
+ */
84
+ get(key: Maybe<K>): T[];
51
85
  }
52
86
  /**
53
87
  * Creates a new MultiValueMapBuilder
@@ -1,4 +1,5 @@
1
1
  import { type Milliseconds } from '../date/date';
2
+ import { type PrimativeKey, type ReadKeyFunction } from '../key';
2
3
  import { type IndexNumber } from '../value';
3
4
  import { type Maybe } from '../value/maybe.type';
4
5
  export type RunAsyncTaskForValueConfig<T = unknown> = Omit<PerformAsyncTaskConfig<T>, 'throwError'>;
@@ -47,20 +48,30 @@ export interface PerformAsyncTaskConfig<I = unknown> {
47
48
  */
48
49
  readonly beforeRetry?: (value: I, tryNumber?: number) => void | Promise<void>;
49
50
  }
50
- export interface PerformAsyncTasksConfig<I = unknown> extends PerformAsyncTaskConfig<I>, Omit<PerformTasksInParallelFunctionConfig<I>, 'taskFactory'> {
51
+ export interface PerformAsyncTasksConfig<I = unknown, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey> extends PerformAsyncTaskConfig<I>, Omit<PerformTasksInParallelFunctionConfig<I, K>, 'taskFactory'> {
51
52
  }
52
53
  /**
53
54
  * Performs the input tasks, and will retry tasks if they fail, up to a certain point.
54
55
  *
55
56
  * This is useful for retrying sections that may experience optimistic concurrency collisions.
56
57
  */
57
- export declare function performAsyncTasks<I, O = unknown>(input: I[], taskFn: PromiseAsyncTaskFn<I, O>, config?: PerformAsyncTasksConfig<I>): Promise<PerformAsyncTasksResult<I, O>>;
58
+ export declare function performAsyncTasks<I, O = unknown, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey>(input: I[], taskFn: PromiseAsyncTaskFn<I, O>, config?: PerformAsyncTasksConfig<I, K>): Promise<PerformAsyncTasksResult<I, O>>;
58
59
  export declare function performAsyncTask<O>(taskFn: () => Promise<O>, config?: PerformAsyncTaskConfig<0>): Promise<PerformAsyncTaskResult<O>>;
59
- export interface PerformTasksInParallelFunctionConfig<I> {
60
+ /**
61
+ * Used as a key to identify the "group" that a task belongs to to prevent other concurrent tasks from that group from running in parallel when parallel execution is desired.
62
+ */
63
+ export type PerformTasksInParallelTaskUniqueKey = string;
64
+ export interface PerformTasksInParallelFunctionConfig<I, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey> {
60
65
  /**
61
66
  * Creates a promise from the input.
62
67
  */
63
- readonly taskFactory: (input: I, value: IndexNumber) => Promise<void>;
68
+ readonly taskFactory: (input: I, value: IndexNumber, taskKey: K) => Promise<void>;
69
+ /**
70
+ * This function is used to uniquely identify tasks that may use the same resources to prevent such tasks from running concurrently.
71
+ *
72
+ * When in use the order is not guranteed.
73
+ */
74
+ readonly nonConcurrentTaskKeyFactory?: ReadKeyFunction<I, K>;
64
75
  /**
65
76
  * Whether or not tasks are performed sequentially or if tasks are all done in "parellel".
66
77
  *
@@ -89,10 +100,10 @@ export type PerformTasksInParallelFunction<I> = (input: I[]) => Promise<void>;
89
100
  * @param config
90
101
  * @returns
91
102
  */
92
- export declare function performTasksInParallel<I>(input: I[], config: PerformTasksInParallelFunctionConfig<I>): Promise<void>;
103
+ export declare function performTasksInParallel<I, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey>(input: I[], config: PerformTasksInParallelFunctionConfig<I, K>): Promise<void>;
93
104
  /**
94
105
  * Creates a function that performs tasks in parallel.
95
106
  *
96
107
  * @param config
97
108
  */
98
- export declare function performTasksInParallelFunction<I>(config: PerformTasksInParallelFunctionConfig<I>): PerformTasksInParallelFunction<I>;
109
+ export declare function performTasksInParallelFunction<I, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey>(config: PerformTasksInParallelFunctionConfig<I, K>): PerformTasksInParallelFunction<I>;
@@ -0,0 +1,11 @@
1
+ import { type Factory, type FactoryWithRequiredInput } from '../getter';
2
+ export type StringFactory<K extends string = string> = Factory<K>;
3
+ export type ToStringFunction<T, K extends string = string> = FactoryWithRequiredInput<K, T>;
4
+ /**
5
+ * Wraps another factory with a ToStringFactory function to generate strings from the original factory.
6
+ *
7
+ * @param factory
8
+ * @param toStringFunction
9
+ * @returns
10
+ */
11
+ export declare function stringFactoryFromFactory<T, K extends string = string>(factory: Factory<T>, toStringFunction: ToStringFunction<T, K>): StringFactory<K>;
@@ -1,5 +1,6 @@
1
1
  export * from './char';
2
2
  export * from './dencoder';
3
+ export * from './factory';
3
4
  export * from './html';
4
5
  export * from './password';
5
6
  export * from './string';
package/test/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [10.0.10](https://github.com/dereekb/dbx-components/compare/v10.0.9-dev...v10.0.10) (2024-01-21)
6
+
7
+
8
+
9
+ ## [10.0.9](https://github.com/dereekb/dbx-components/compare/v10.0.8-dev...v10.0.9) (2024-01-15)
10
+
11
+
12
+
5
13
  ## [10.0.8](https://github.com/dereekb/dbx-components/compare/v10.0.7-dev...v10.0.8) (2024-01-14)
6
14
 
7
15
 
package/test/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util/test",
3
- "version": "10.0.8",
3
+ "version": "10.0.10",
4
4
  "type": "commonjs",
5
5
  "peerDependencies": {
6
6
  "@dereekb/util": "*"