@oscarpalmer/atoms 0.213.0 → 0.215.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array/difference.d.mts +1 -1
- package/dist/array/difference.mjs +3 -2
- package/dist/array/exists.d.mts +1 -1
- package/dist/array/exists.mjs +3 -2
- package/dist/array/filter.d.mts +1 -1
- package/dist/array/filter.mjs +1 -0
- package/dist/array/find.d.mts +1 -1
- package/dist/array/find.mjs +4 -3
- package/dist/array/first.d.mts +1 -1
- package/dist/array/flatten.d.mts +1 -1
- package/dist/array/group-by.d.mts +1 -1
- package/dist/array/index.d.mts +2 -2
- package/dist/array/insert.mjs +3 -2
- package/dist/array/intersection.mjs +3 -2
- package/dist/array/last.d.mts +1 -1
- package/dist/array/move.d.mts +1 -1
- package/dist/array/partition.d.mts +1 -1
- package/dist/array/partition.mjs +1 -0
- package/dist/array/push.mjs +3 -2
- package/dist/array/select.d.mts +10 -12
- package/dist/array/select.mjs +1 -0
- package/dist/array/single.d.mts +1 -1
- package/dist/array/single.mjs +1 -0
- package/dist/array/slice.d.mts +1 -1
- package/dist/array/slice.mjs +4 -5
- package/dist/array/sort.d.mts +4 -103
- package/dist/array/sort.mjs +6 -14
- package/dist/array/splice.mjs +3 -2
- package/dist/array/swap.d.mts +1 -1
- package/dist/array/to-map.d.mts +1 -1
- package/dist/array/to-record.d.mts +1 -1
- package/dist/array/to-set.d.mts +1 -1
- package/dist/array/toggle.d.mts +1 -1
- package/dist/array/union.mjs +3 -2
- package/dist/array/unique.d.mts +1 -1
- package/dist/array/unique.mjs +3 -2
- package/dist/array/update.d.mts +1 -1
- package/dist/beacon.d.mts +6 -92
- package/dist/beacon.mjs +6 -16
- package/dist/color/constants.d.mts +2 -2
- package/dist/color/constants.mjs +1 -1
- package/dist/color/index.d.mts +1 -1
- package/dist/color/instance.d.mts +1 -1
- package/dist/color/misc/alpha.d.mts +1 -1
- package/dist/color/misc/format.d.mts +1 -1
- package/dist/color/misc/get.d.mts +1 -1
- package/dist/color/misc/is.d.mts +2 -2
- package/dist/color/misc/is.mjs +1 -0
- package/dist/color/misc/state.d.mts +1 -1
- package/dist/color/space/hex.d.mts +1 -1
- package/dist/color/space/hsl.d.mts +1 -1
- package/dist/color/space/hwb.d.mts +1 -1
- package/dist/color/space/rgb.d.mts +1 -1
- package/dist/function/limit.d.mts +2 -2
- package/dist/function/limit.mjs +2 -1
- package/dist/function/once.d.mts +7 -3
- package/dist/function/once.mjs +5 -10
- package/dist/function/retry.d.mts +4 -14
- package/dist/function/retry.mjs +3 -15
- package/dist/herald.d.mts +2 -2
- package/dist/index.d.mts +500 -333
- package/dist/index.mjs +508 -446
- package/dist/internal/aborter.d.mts +1 -6
- package/dist/internal/aborter.mjs +3 -4
- package/dist/internal/array/callbacks.d.mts +3 -7
- package/dist/internal/array/chunk.mjs +2 -2
- package/dist/internal/array/find.d.mts +5 -23
- package/dist/internal/array/find.mjs +5 -9
- package/dist/internal/array/get.d.mts +1 -1
- package/dist/internal/array/group.d.mts +1 -1
- package/dist/internal/array/index-of.d.mts +1 -1
- package/dist/internal/array/index-of.mjs +4 -3
- package/dist/internal/array/insert.d.mts +2 -5
- package/dist/internal/array/insert.mjs +2 -4
- package/dist/internal/array/match.d.mts +2 -5
- package/dist/internal/array/match.mjs +10 -20
- package/dist/internal/array/overlap.d.mts +2 -10
- package/dist/internal/array/sets.d.mts +2 -5
- package/dist/internal/array/sets.mjs +5 -7
- package/dist/internal/function/assert.d.mts +5 -12
- package/dist/internal/function/assert.mjs +2 -2
- package/dist/internal/function/limit.d.mts +2 -37
- package/dist/internal/function/limit.mjs +4 -15
- package/dist/internal/function/memoize.d.mts +5 -70
- package/dist/internal/function/memoize.mjs +2 -5
- package/dist/internal/function/work.d.mts +16 -22
- package/dist/internal/function/work.mjs +1 -8
- package/dist/internal/herald.d.mts +3 -3
- package/dist/internal/herald.mjs +2 -1
- package/dist/internal/is.d.mts +1 -1
- package/dist/internal/math/aggregate.d.mts +2 -14
- package/dist/internal/math/aggregate.mjs +2 -5
- package/dist/internal/number.mjs +4 -7
- package/dist/internal/result/attempt.d.mts +1 -1
- package/dist/internal/result/misc.d.mts +1 -1
- package/dist/internal/string/case.mjs +6 -16
- package/dist/internal/string/misc.mjs +1 -2
- package/dist/internal/subscription.d.mts +1 -100
- package/dist/internal/subscription.mjs +3 -9
- package/dist/internal/value/compare.d.mts +4 -4
- package/dist/internal/value/compare.mjs +1 -1
- package/dist/internal/value/equal.d.mts +6 -57
- package/dist/internal/value/equal.mjs +5 -10
- package/dist/internal/value/get.d.mts +1 -1
- package/dist/internal/value/handlers.d.mts +2 -21
- package/dist/internal/value/has.d.mts +2 -2
- package/dist/internal/value/misc.d.mts +1 -1
- package/dist/internal/value/misc.mjs +8 -14
- package/dist/internal/value/set.d.mts +1 -1
- package/dist/internal/value/set.mjs +2 -2
- package/dist/is.mjs +3 -3
- package/dist/logger.d.mts +3 -70
- package/dist/logger.mjs +2 -5
- package/dist/math.d.mts +1 -1
- package/dist/math.mjs +2 -1
- package/dist/models/aborter.model.d.mts +12 -0
- package/dist/models/aborter.model.mjs +5 -0
- package/dist/models/array/array.find.model.d.mts +22 -0
- package/dist/models/array/array.find.model.mjs +8 -0
- package/dist/models/array/array.match.model.d.mts +14 -0
- package/dist/models/array/array.match.model.mjs +14 -0
- package/dist/models/array/array.misc.model.d.mts +36 -0
- package/dist/models/array/array.misc.model.mjs +12 -0
- package/dist/models/array/array.sort.model.d.mts +122 -0
- package/dist/models/array/array.sort.model.mjs +12 -0
- package/dist/models/beacon.model.d.mts +119 -0
- package/dist/models/beacon.model.mjs +16 -0
- package/dist/{color/models.d.mts → models/color.model.d.mts} +4 -4
- package/dist/models/function/assert.model.d.mts +13 -0
- package/dist/models/function/assert.model.mjs +4 -0
- package/dist/models/function/limiter.model.d.mts +71 -0
- package/dist/models/function/limiter.model.mjs +15 -0
- package/dist/models/function/memoize.model.d.mts +88 -0
- package/dist/models/function/memoize.model.mjs +7 -0
- package/dist/models/function/once.model.d.mts +76 -0
- package/dist/models/function/once.model.mjs +9 -0
- package/dist/models/function/retry.model.d.mts +17 -0
- package/dist/models/function/retry.model.mjs +17 -0
- package/dist/models/function/work.model.d.mts +20 -0
- package/dist/models/function/work.model.mjs +11 -0
- package/dist/{internal/models → models}/herald.model.d.mts +3 -3
- package/dist/{internal/models → models}/herald.model.mjs +2 -2
- package/dist/{models.d.mts → models/index.d.mts} +5 -47
- package/dist/models/logger.model.d.mts +83 -0
- package/dist/models/logger.model.mjs +7 -0
- package/dist/models/math.model.d.mts +16 -0
- package/dist/models/math.model.mjs +7 -0
- package/dist/models/misc.model.d.mts +10 -0
- package/dist/models/misc.model.mjs +11 -0
- package/dist/{internal/models → models}/plan.model.d.mts +40 -8
- package/dist/{internal/models → models}/plan.model.mjs +1 -1
- package/dist/models/promise.model.d.mts +119 -0
- package/dist/models/promise.model.mjs +47 -0
- package/dist/models/query.model.d.mts +9 -0
- package/dist/models/query.model.mjs +14 -0
- package/dist/models/queue.model.d.mts +251 -0
- package/dist/models/queue.model.mjs +29 -0
- package/dist/models/random.model.d.mts +6 -0
- package/dist/models/random.model.mjs +7 -0
- package/dist/{internal/models → models}/result.model.d.mts +10 -2
- package/dist/models/string/string.case.model.d.mts +19 -0
- package/dist/models/string/string.case.model.mjs +14 -0
- package/dist/models/string/string.fuzzy.model.d.mts +108 -0
- package/dist/models/string/string.fuzzy.model.mjs +9 -0
- package/dist/models/string/string.misc.model.d.mts +13 -0
- package/dist/models/string/string.misc.model.mjs +13 -0
- package/dist/models/string/string.normalize.model.d.mts +85 -0
- package/dist/models/string/string.normalize.model.mjs +43 -0
- package/dist/models/string/string.template.model.d.mts +50 -0
- package/dist/models/string/string.template.model.mjs +5 -0
- package/dist/models/subscription.model.d.mts +127 -0
- package/dist/models/subscription.model.mjs +10 -0
- package/dist/models/value/value.clone.model.d.mts +56 -0
- package/dist/models/value/value.clone.model.mjs +24 -0
- package/dist/models/value/value.diff.model.d.mts +61 -0
- package/dist/models/value/value.diff.model.mjs +6 -0
- package/dist/models/value/value.equal.model.d.mts +76 -0
- package/dist/models/value/value.equal.model.mjs +9 -0
- package/dist/models/value/value.handler.model.d.mts +27 -0
- package/dist/models/value/value.handler.model.mjs +1 -0
- package/dist/models/value/value.merge.model.d.mts +82 -0
- package/dist/models/value/value.merge.model.mjs +5 -0
- package/dist/models/value/value.misc.model.d.mts +33 -0
- package/dist/models/value/value.misc.model.mjs +12 -0
- package/dist/models/value/value.transform.model.d.mts +28 -0
- package/dist/models/value/value.transform.model.mjs +4 -0
- package/dist/plan/generate.d.mts +3 -2
- package/dist/plan/generate.mjs +23 -11
- package/dist/plan/index.d.mts +1 -1
- package/dist/plan/index.mjs +1 -1
- package/dist/plan/is.d.mts +1 -1
- package/dist/plan/is.mjs +1 -1
- package/dist/plan/misc.d.mts +4 -8
- package/dist/plan/misc.mjs +22 -15
- package/dist/plan/models.d.mts +2 -2
- package/dist/plan/result.d.mts +21 -5
- package/dist/plan/result.mjs +15 -11
- package/dist/plan/run.d.mts +26 -4
- package/dist/plan/run.mjs +7 -7
- package/dist/promise/delay.d.mts +1 -1
- package/dist/promise/delay.mjs +2 -1
- package/dist/promise/helpers.d.mts +2 -2
- package/dist/promise/helpers.mjs +6 -6
- package/dist/promise/index.d.mts +2 -2
- package/dist/promise/index.mjs +1 -1
- package/dist/promise/misc.d.mts +3 -3
- package/dist/promise/misc.mjs +7 -4
- package/dist/promise/models.d.mts +2 -106
- package/dist/promise/models.mjs +1 -35
- package/dist/promise/timed.d.mts +2 -2
- package/dist/promise/timed.mjs +3 -3
- package/dist/query.d.mts +1 -1
- package/dist/query.mjs +5 -15
- package/dist/queue.d.mts +6 -200
- package/dist/queue.mjs +9 -34
- package/dist/random.mjs +2 -5
- package/dist/result/match.d.mts +1 -1
- package/dist/result/match.mjs +27 -15
- package/dist/result/misc.d.mts +1 -1
- package/dist/result/work/flow.d.mts +13 -21
- package/dist/result/work/pipe.d.mts +2 -2
- package/dist/string/fuzzy.d.mts +5 -87
- package/dist/string/fuzzy.mjs +6 -11
- package/dist/string/index.mjs +6 -8
- package/dist/string/match.mjs +4 -6
- package/dist/string/normalize.d.mts +4 -40
- package/dist/string/normalize.mjs +9 -48
- package/dist/string/template.d.mts +5 -43
- package/dist/string/template.mjs +1 -2
- package/dist/subscription.d.mts +2 -1
- package/dist/value/clone.d.mts +6 -42
- package/dist/value/clone.mjs +10 -30
- package/dist/value/collection.mjs +2 -0
- package/dist/value/diff.d.mts +3 -44
- package/dist/value/diff.mjs +1 -3
- package/dist/value/freeze.d.mts +1 -5
- package/dist/value/index.d.mts +4 -3
- package/dist/value/merge.d.mts +6 -64
- package/dist/value/merge.mjs +8 -8
- package/dist/value/omit.d.mts +1 -1
- package/dist/value/pick.d.mts +1 -1
- package/dist/value/shake.d.mts +4 -6
- package/dist/value/smush.d.mts +4 -6
- package/dist/value/smush.mjs +2 -2
- package/dist/value/transform.d.mts +6 -22
- package/dist/value/transform.mjs +1 -1
- package/dist/value/unsmush.d.mts +4 -10
- package/package.json +12 -4
- package/dist/promise/constants.d.mts +0 -17
- package/dist/promise/constants.mjs +0 -15
- /package/dist/{color/models.mjs → models/color.model.mjs} +0 -0
- /package/dist/{internal/models/result.model.mjs → models/index.mjs} +0 -0
- /package/dist/{models.mjs → models/result.model.mjs} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
//#region src/models/array/array.find.model.ts
|
|
2
|
+
const ARRAY_FIND_VALUE_INDEX = "index";
|
|
3
|
+
const ARRAY_FIND_VALUE_ITEM = "item";
|
|
4
|
+
const ARRAY_FIND_VALUES_UNIQUE = "unique";
|
|
5
|
+
//#endregion
|
|
1
6
|
//#region src/internal/array/callbacks.ts
|
|
2
7
|
function getArrayCallback(value) {
|
|
3
8
|
switch (typeof value) {
|
|
@@ -25,7 +30,7 @@ function createFindParameters(original) {
|
|
|
25
30
|
};
|
|
26
31
|
}
|
|
27
32
|
function findValue(type, array, parameters, reversed) {
|
|
28
|
-
const findIndex = type ===
|
|
33
|
+
const findIndex = type === ARRAY_FIND_VALUE_INDEX;
|
|
29
34
|
if (!Array.isArray(array) || array.length === 0) return findIndex ? -1 : void 0;
|
|
30
35
|
const { bool, key, value } = createFindParameters(parameters);
|
|
31
36
|
const callbacks = getArrayCallbacks(bool, key);
|
|
@@ -52,7 +57,7 @@ function findAbsoluteValueOrDefault(array, parameters, defaultValue, useDefaultV
|
|
|
52
57
|
if (Array.isArray(array) && array.length > 0) return reversed ? array.at(-1) : array[0];
|
|
53
58
|
return useDefaultValue ? defaultValue : void 0;
|
|
54
59
|
}
|
|
55
|
-
const index = findValue(
|
|
60
|
+
const index = findValue(ARRAY_FIND_VALUE_INDEX, array, parameters, reversed);
|
|
56
61
|
return index > -1 ? array[index] : useDefaultValue ? defaultValue : void 0;
|
|
57
62
|
}
|
|
58
63
|
function findValues(type, array, parameters, mapper) {
|
|
@@ -64,7 +69,7 @@ function findValues(type, array, parameters, mapper) {
|
|
|
64
69
|
const { length } = array;
|
|
65
70
|
const { bool, key, value } = createFindParameters(parameters);
|
|
66
71
|
const callbacks = getArrayCallbacks(bool, key);
|
|
67
|
-
if (type === "unique" && callbacks?.keyed == null && length >=
|
|
72
|
+
if (type === "unique" && callbacks?.keyed == null && length >= 100) {
|
|
68
73
|
result.matched = [...new Set(array)];
|
|
69
74
|
return result;
|
|
70
75
|
}
|
|
@@ -101,10 +106,6 @@ function findValues(type, array, parameters, mapper) {
|
|
|
101
106
|
}
|
|
102
107
|
return result;
|
|
103
108
|
}
|
|
104
|
-
const FIND_VALUE_INDEX = "index";
|
|
105
|
-
const FIND_VALUE_ITEM = "item";
|
|
106
|
-
const FIND_VALUES_UNIQUE = "unique";
|
|
107
|
-
const FIND_UNIQUE_THRESHOLD = 100;
|
|
108
109
|
//#endregion
|
|
109
110
|
//#region src/array/filter.ts
|
|
110
111
|
function exclude(array, ...parameters) {
|
|
@@ -117,10 +118,10 @@ filter.remove = exclude;
|
|
|
117
118
|
//#endregion
|
|
118
119
|
//#region src/array/find.ts
|
|
119
120
|
function find(array, ...parameters) {
|
|
120
|
-
return findValue(
|
|
121
|
+
return findValue(ARRAY_FIND_VALUE_ITEM, array, parameters, false);
|
|
121
122
|
}
|
|
122
123
|
function findLast(array, ...parameters) {
|
|
123
|
-
return findValue(
|
|
124
|
+
return findValue(ARRAY_FIND_VALUE_ITEM, array, parameters, true);
|
|
124
125
|
}
|
|
125
126
|
find.last = findLast;
|
|
126
127
|
//#endregion
|
|
@@ -161,6 +162,17 @@ function groupArraysBy(array, first, second) {
|
|
|
161
162
|
}
|
|
162
163
|
groupBy.arrays = groupArraysBy;
|
|
163
164
|
//#endregion
|
|
165
|
+
//#region src/models/array/array.misc.model.ts
|
|
166
|
+
const ARRAY_CHUNK_MAX_SIZE = 5e3;
|
|
167
|
+
const ARRAY_INSERT_TYPE_INSERT = "insert";
|
|
168
|
+
const ARRAY_INSERT_TYPE_PUSH = "push";
|
|
169
|
+
const ARRAY_INSERT_TYPE_SPLICE = "splice";
|
|
170
|
+
const ARRAY_SETS_COMPARE_DIFFERENCE = "difference";
|
|
171
|
+
const ARRAY_SETS_COMPARE_INTERSECTION = "intersection";
|
|
172
|
+
const ARRAY_SETS_COMPARE_UNION = "union";
|
|
173
|
+
const ARRAY_SLICE_DROP = "drop";
|
|
174
|
+
const ARRAY_SLICE_TAKE = "take";
|
|
175
|
+
//#endregion
|
|
164
176
|
//#region src/internal/array/chunk.ts
|
|
165
177
|
/**
|
|
166
178
|
* Chunk an array into smaller arrays
|
|
@@ -178,7 +190,7 @@ function chunk(array, size) {
|
|
|
178
190
|
if (!Array.isArray(array)) return [];
|
|
179
191
|
if (array.length === 0) return [];
|
|
180
192
|
const { length } = array;
|
|
181
|
-
const actualSize = typeof size === "number" && size > 0 && size <=
|
|
193
|
+
const actualSize = typeof size === "number" && size > 0 && size <= 5e3 ? size : ARRAY_CHUNK_MAX_SIZE;
|
|
182
194
|
if (length <= actualSize) return [array];
|
|
183
195
|
const chunks = [];
|
|
184
196
|
let index = 0;
|
|
@@ -188,7 +200,6 @@ function chunk(array, size) {
|
|
|
188
200
|
}
|
|
189
201
|
return chunks;
|
|
190
202
|
}
|
|
191
|
-
const CHUNK_MAX_SIZE = 5e3;
|
|
192
203
|
//#endregion
|
|
193
204
|
//#region src/internal/array/compact.ts
|
|
194
205
|
function compact(array, strict) {
|
|
@@ -405,24 +416,34 @@ function getArray(value, indiced) {
|
|
|
405
416
|
}
|
|
406
417
|
return array;
|
|
407
418
|
}
|
|
419
|
+
const ARRAY_MATCH_COMPARISON_INSIDE = "inside";
|
|
420
|
+
const ARRAY_MATCH_COMPARISON_INVALID = "invalid";
|
|
421
|
+
const ARRAY_MATCH_COMPARISON_OUTSIDE = "outside";
|
|
422
|
+
const ARRAY_MATCH_COMPARISON_SAME = "same";
|
|
423
|
+
const ARRAY_MATCH_COMPARISON_START = "start";
|
|
424
|
+
const arrayMatchEndings = /* @__PURE__ */ new Set(["end", ARRAY_MATCH_COMPARISON_SAME]);
|
|
425
|
+
const arrayMatchInvalid = [-1, ARRAY_MATCH_COMPARISON_INVALID];
|
|
426
|
+
const arrayMatchOutside = [-1, ARRAY_MATCH_COMPARISON_OUTSIDE];
|
|
427
|
+
const arrayMatchOutsides = /* @__PURE__ */ new Set([ARRAY_MATCH_COMPARISON_INVALID, ARRAY_MATCH_COMPARISON_OUTSIDE]);
|
|
428
|
+
const arrayMatchStarts = /* @__PURE__ */ new Set([ARRAY_MATCH_COMPARISON_START, ARRAY_MATCH_COMPARISON_SAME]);
|
|
408
429
|
//#endregion
|
|
409
430
|
//#region src/internal/array/match.ts
|
|
410
431
|
function endsWithArray(haystack, needle, key) {
|
|
411
|
-
return
|
|
432
|
+
return arrayMatchEndings.has(getPosition(haystack, needle, key)[1]);
|
|
412
433
|
}
|
|
413
434
|
function getArrayComparison(haystack, needle, key) {
|
|
414
435
|
return getPosition(haystack, needle, key)[1];
|
|
415
436
|
}
|
|
416
437
|
function getName(start, haystack, needle) {
|
|
417
|
-
if (start === 0) return haystack === needle ?
|
|
418
|
-
return start + needle === haystack ?
|
|
438
|
+
if (start === 0) return haystack === needle ? ARRAY_MATCH_COMPARISON_SAME : ARRAY_MATCH_COMPARISON_START;
|
|
439
|
+
return start + needle === haystack ? "end" : ARRAY_MATCH_COMPARISON_INSIDE;
|
|
419
440
|
}
|
|
420
441
|
function getPosition(haystack, needle, key) {
|
|
421
|
-
if (!Array.isArray(haystack) || !Array.isArray(needle)) return
|
|
442
|
+
if (!Array.isArray(haystack) || !Array.isArray(needle)) return arrayMatchInvalid;
|
|
422
443
|
const haystackLength = haystack.length;
|
|
423
444
|
const needleLength = needle.length;
|
|
424
|
-
if (haystackLength === 0 || needleLength === 0) return
|
|
425
|
-
if (needleLength > haystackLength) return
|
|
445
|
+
if (haystackLength === 0 || needleLength === 0) return arrayMatchOutside;
|
|
446
|
+
if (needleLength > haystackLength) return arrayMatchOutside;
|
|
426
447
|
const callback = getArrayCallback(key);
|
|
427
448
|
const limit = haystackLength - needleLength + 1;
|
|
428
449
|
let needleValues = callback == null ? needle : needle.slice();
|
|
@@ -439,28 +460,17 @@ function getPosition(haystack, needle, key) {
|
|
|
439
460
|
if (needleIndex === needleLength - 1) return [haystackIndex, getName(haystackIndex, haystackLength, needleLength)];
|
|
440
461
|
}
|
|
441
462
|
}
|
|
442
|
-
return
|
|
463
|
+
return arrayMatchOutside;
|
|
443
464
|
}
|
|
444
465
|
function includesArray(haystack, needle, key) {
|
|
445
|
-
return !
|
|
466
|
+
return !arrayMatchOutsides.has(getPosition(haystack, needle, key)[1]);
|
|
446
467
|
}
|
|
447
468
|
function indexOfArray(haystack, needle, key) {
|
|
448
469
|
return getPosition(haystack, needle, key)[0];
|
|
449
470
|
}
|
|
450
471
|
function startsWithArray(haystack, needle, key) {
|
|
451
|
-
return
|
|
452
|
-
}
|
|
453
|
-
const MATCH_COMPARISON_END = "end";
|
|
454
|
-
const MATCH_COMPARISON_INSIDE = "inside";
|
|
455
|
-
const MATCH_COMPARISON_INVALID = "invalid";
|
|
456
|
-
const MATCH_COMPARISON_OUTSIDE = "outside";
|
|
457
|
-
const MATCH_COMPARISON_SAME = "same";
|
|
458
|
-
const MATCH_COMPARISON_START = "start";
|
|
459
|
-
const endings = /* @__PURE__ */ new Set([MATCH_COMPARISON_END, MATCH_COMPARISON_SAME]);
|
|
460
|
-
const invalid = [-1, MATCH_COMPARISON_INVALID];
|
|
461
|
-
const outside = [-1, MATCH_COMPARISON_OUTSIDE];
|
|
462
|
-
const outsides = /* @__PURE__ */ new Set([MATCH_COMPARISON_INVALID, MATCH_COMPARISON_OUTSIDE]);
|
|
463
|
-
const starts = /* @__PURE__ */ new Set([MATCH_COMPARISON_START, MATCH_COMPARISON_SAME]);
|
|
472
|
+
return arrayMatchStarts.has(getPosition(haystack, needle, key)[1]);
|
|
473
|
+
}
|
|
464
474
|
//#endregion
|
|
465
475
|
//#region src/internal/math/misc.ts
|
|
466
476
|
/**
|
|
@@ -541,9 +551,9 @@ function shuffle(array) {
|
|
|
541
551
|
//#region src/internal/array/sets.ts
|
|
542
552
|
function compareSets(type, first, second, key) {
|
|
543
553
|
if (!Array.isArray(first)) return [];
|
|
544
|
-
const isDifference = type ===
|
|
545
|
-
const isIntersection = type ===
|
|
546
|
-
const isUnion = type ===
|
|
554
|
+
const isDifference = type === ARRAY_SETS_COMPARE_DIFFERENCE;
|
|
555
|
+
const isIntersection = type === ARRAY_SETS_COMPARE_INTERSECTION;
|
|
556
|
+
const isUnion = type === ARRAY_SETS_COMPARE_UNION;
|
|
547
557
|
if (first.length === 0) return isDifference ? first.slice() : isIntersection ? [] : second.slice();
|
|
548
558
|
if (!Array.isArray(second) || second.length === 0) return isIntersection ? [] : first.slice();
|
|
549
559
|
const callback = getArrayCallback(key);
|
|
@@ -564,19 +574,16 @@ function compareSets(type, first, second, key) {
|
|
|
564
574
|
}
|
|
565
575
|
return result;
|
|
566
576
|
}
|
|
567
|
-
const SETS_COMPARE_DIFFERENCE = "difference";
|
|
568
|
-
const SETS_COMPARE_INTERSECTION = "intersection";
|
|
569
|
-
const SETS_COMPARE_UNION = "union";
|
|
570
577
|
//#endregion
|
|
571
578
|
//#region src/array/difference.ts
|
|
572
579
|
function difference(first, second, key) {
|
|
573
|
-
return compareSets(
|
|
580
|
+
return compareSets(ARRAY_SETS_COMPARE_DIFFERENCE, first, second, key);
|
|
574
581
|
}
|
|
575
582
|
//#endregion
|
|
576
583
|
//#region src/array/exists.ts
|
|
577
584
|
function exists(array, ...parameters) {
|
|
578
585
|
if (parameters.length === 1 && typeof parameters[0] !== "function") return Array.isArray(array) ? array.includes(parameters[0]) : false;
|
|
579
|
-
return findValue(
|
|
586
|
+
return findValue(ARRAY_FIND_VALUE_INDEX, array, parameters, false) > -1;
|
|
580
587
|
}
|
|
581
588
|
//#endregion
|
|
582
589
|
//#region src/array/flatten.ts
|
|
@@ -614,6 +621,9 @@ function times(length, value) {
|
|
|
614
621
|
return values;
|
|
615
622
|
}
|
|
616
623
|
//#endregion
|
|
624
|
+
//#region src/models/math.model.ts
|
|
625
|
+
const AGGREGATION_AVERAGE = "average";
|
|
626
|
+
//#endregion
|
|
617
627
|
//#region src/internal/math/aggregate.ts
|
|
618
628
|
function aggregate(type, array, key, first) {
|
|
619
629
|
const length = Array.isArray(array) ? array.length : 0;
|
|
@@ -677,7 +687,6 @@ function max(array, key, first) {
|
|
|
677
687
|
function min(array, key, first) {
|
|
678
688
|
return getAggregated("min", array, key, first);
|
|
679
689
|
}
|
|
680
|
-
const AGGREGATION_AVERAGE = "average";
|
|
681
690
|
const aggregators = {
|
|
682
691
|
average: calculateSum,
|
|
683
692
|
max: getAbsoluteValue.bind(void 0, isMaxValue),
|
|
@@ -707,18 +716,15 @@ function insertValues(type, array, items, start, deleteCount) {
|
|
|
707
716
|
if (!Array.isArray(array) || typeof start !== "number" || !Array.isArray(items) || items.length === 0) return spliceArray ? [] : 0;
|
|
708
717
|
return insertChunkedValues(type, array, items, start, spliceArray ? deleteCount : 0);
|
|
709
718
|
}
|
|
710
|
-
const INSERT_TYPE_INSERT = "insert";
|
|
711
|
-
const INSERT_TYPE_PUSH = "push";
|
|
712
|
-
const INSERT_TYPE_SPLICE = "splice";
|
|
713
719
|
//#endregion
|
|
714
720
|
//#region src/array/insert.ts
|
|
715
721
|
function insert(array, indexOrItems, items) {
|
|
716
|
-
return insertValues(
|
|
722
|
+
return insertValues(ARRAY_INSERT_TYPE_INSERT, array, items == null ? indexOrItems : items, typeof indexOrItems === "number" ? indexOrItems : array?.length, 0);
|
|
717
723
|
}
|
|
718
724
|
//#endregion
|
|
719
725
|
//#region src/array/intersection.ts
|
|
720
726
|
function intersection(first, second, key) {
|
|
721
|
-
return compareSets(
|
|
727
|
+
return compareSets(ARRAY_SETS_COMPARE_INTERSECTION, first, second, key);
|
|
722
728
|
}
|
|
723
729
|
//#endregion
|
|
724
730
|
//#region src/array/partition.ts
|
|
@@ -743,7 +749,7 @@ function partition(array, ...parameters) {
|
|
|
743
749
|
* ```
|
|
744
750
|
*/
|
|
745
751
|
function push(array, pushed) {
|
|
746
|
-
return insertValues(
|
|
752
|
+
return insertValues(ARRAY_INSERT_TYPE_PUSH, array, pushed, array.length, 0);
|
|
747
753
|
}
|
|
748
754
|
//#endregion
|
|
749
755
|
//#region src/array/reverse.ts
|
|
@@ -777,13 +783,13 @@ const SINGLE_MESSAGE = "Multiple items were found";
|
|
|
777
783
|
//#endregion
|
|
778
784
|
//#region src/array/slice.ts
|
|
779
785
|
function drop(array, first, second) {
|
|
780
|
-
return extract(
|
|
786
|
+
return extract(ARRAY_SLICE_DROP, array, first, second);
|
|
781
787
|
}
|
|
782
788
|
function extract(type, array, first, second) {
|
|
783
789
|
if (!Array.isArray(array)) return [];
|
|
784
790
|
const { length } = array;
|
|
785
791
|
if (length === 0) return [];
|
|
786
|
-
const isTake = type ===
|
|
792
|
+
const isTake = type === ARRAY_SLICE_TAKE;
|
|
787
793
|
if (typeof first === "number") {
|
|
788
794
|
if (Math.abs(first) >= length) return isTake ? array.slice() : [];
|
|
789
795
|
if (first === 0) return isTake ? [] : array.slice();
|
|
@@ -821,15 +827,13 @@ function slice(array, first, second) {
|
|
|
821
827
|
return first >= 0 ? array.slice(first, second) : array.slice(array.length + first, array.length + second);
|
|
822
828
|
}
|
|
823
829
|
function take(array, first, second) {
|
|
824
|
-
return extract(
|
|
830
|
+
return extract(ARRAY_SLICE_TAKE, array, first, second);
|
|
825
831
|
}
|
|
826
|
-
const SLICE_DROP = "drop";
|
|
827
|
-
const SLICE_TAKE = "take";
|
|
828
832
|
//#endregion
|
|
829
833
|
//#region src/array/splice.ts
|
|
830
834
|
function splice(array, start, deleteCountOrItems, items) {
|
|
831
835
|
const deleteCountIsNumber = typeof deleteCountOrItems === "number";
|
|
832
|
-
return insertValues(
|
|
836
|
+
return insertValues(ARRAY_INSERT_TYPE_SPLICE, array, deleteCountIsNumber ? items : deleteCountOrItems, start, deleteCountIsNumber ? deleteCountOrItems : 0);
|
|
833
837
|
}
|
|
834
838
|
//#endregion
|
|
835
839
|
//#region src/array/to-set.ts
|
|
@@ -872,13 +876,13 @@ function toggle(array, values, key) {
|
|
|
872
876
|
//#endregion
|
|
873
877
|
//#region src/array/union.ts
|
|
874
878
|
function union(first, second, key) {
|
|
875
|
-
return compareSets(
|
|
879
|
+
return compareSets(ARRAY_SETS_COMPARE_UNION, first, second, key);
|
|
876
880
|
}
|
|
877
881
|
//#endregion
|
|
878
882
|
//#region src/array/unique.ts
|
|
879
883
|
function unique(array, key) {
|
|
880
884
|
if (!Array.isArray(array)) return [];
|
|
881
|
-
return array.length > 1 ? findValues(
|
|
885
|
+
return array.length > 1 ? findValues(ARRAY_FIND_VALUES_UNIQUE, array, [key, void 0]).matched : array;
|
|
882
886
|
}
|
|
883
887
|
//#endregion
|
|
884
888
|
//#region src/array/update.ts
|
|
@@ -1006,6 +1010,24 @@ function selectValues(array, parameters) {
|
|
|
1006
1010
|
}
|
|
1007
1011
|
filterAndMap.reverse = mapAndFilter;
|
|
1008
1012
|
//#endregion
|
|
1013
|
+
//#region src/models/value/value.misc.model.ts
|
|
1014
|
+
const COMPARE_NAME = "compare";
|
|
1015
|
+
const VALUE_MISC_EXPRESSION_BRACKET = /\[(\w+)\]/g;
|
|
1016
|
+
const VALUE_MISC_EXPRESSION_DOTS = /^\.|\.$/g;
|
|
1017
|
+
const VALUE_MISC_EXPRESSION_NESTED = /\.|\[\w+\]/;
|
|
1018
|
+
const VALUE_MISC_NESTED_MESSAGE_INPUT = "Expected data to be an object";
|
|
1019
|
+
const VALUE_MISC_NESTED_MESSAGE_MISSING = "Expected property to exist in object";
|
|
1020
|
+
const VALUE_MISC_NESTED_MESSAGE_PATH = "Expected path to be a string";
|
|
1021
|
+
const VALUE_MISC_NESTED_MESSAGE_UNSAFE = "Access to this property is not allowed";
|
|
1022
|
+
//#endregion
|
|
1023
|
+
//#region src/models/string/string.misc.model.ts
|
|
1024
|
+
const STRING_EXPRESSION_IGNORED = /(^|\.)(__proto__|constructor|prototype)(\.|$)/i;
|
|
1025
|
+
const STRING_EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
1026
|
+
const STRING_EXPRESSION_WHITESPACE_PREFIX = /^(\s+)/;
|
|
1027
|
+
const STRING_MATCH_ENDS_WITH = "endsWith";
|
|
1028
|
+
const STRING_MATCH_INCLUDES = "includes";
|
|
1029
|
+
const STRING_MATCH_STARTS_WITH = "startsWith";
|
|
1030
|
+
//#endregion
|
|
1009
1031
|
//#region src/internal/result/misc.ts
|
|
1010
1032
|
function error(value, original) {
|
|
1011
1033
|
return getError(value, original);
|
|
@@ -1169,8 +1191,6 @@ function tryEncode(value) {
|
|
|
1169
1191
|
function words(value) {
|
|
1170
1192
|
return typeof value === "string" ? value.match(STRING_EXPRESSION_WORDS) ?? [] : [];
|
|
1171
1193
|
}
|
|
1172
|
-
const STRING_EXPRESSION_IGNORED = /(^|\.)(__proto__|constructor|prototype)(\.|$)/i;
|
|
1173
|
-
const STRING_EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
1174
1194
|
//#endregion
|
|
1175
1195
|
//#region src/internal/value/handlers.ts
|
|
1176
1196
|
function BaseHandler(owner, options) {
|
|
@@ -1226,7 +1246,6 @@ function handleValue$1(value, ...parameters) {
|
|
|
1226
1246
|
}
|
|
1227
1247
|
//#endregion
|
|
1228
1248
|
//#region src/internal/value/compare.ts
|
|
1229
|
-
const COMPARE_NAME = "compare";
|
|
1230
1249
|
/**
|
|
1231
1250
|
* Compare two values _(for sorting purposes)_
|
|
1232
1251
|
*
|
|
@@ -1310,6 +1329,15 @@ compare.deregister = deregisterComparator;
|
|
|
1310
1329
|
compare.handler = compareHandler;
|
|
1311
1330
|
compare.register = registerComparator;
|
|
1312
1331
|
//#endregion
|
|
1332
|
+
//#region src/models/array/array.sort.model.ts
|
|
1333
|
+
const SORT_DIRECTION_ASCENDING = "ascending";
|
|
1334
|
+
const SORT_DIRECTION_DESCENDING = "descending";
|
|
1335
|
+
const SORTER_SYMBOL = Symbol("sorter");
|
|
1336
|
+
const arrayModifiers = {
|
|
1337
|
+
[SORT_DIRECTION_ASCENDING]: 1,
|
|
1338
|
+
[SORT_DIRECTION_DESCENDING]: -1
|
|
1339
|
+
};
|
|
1340
|
+
//#endregion
|
|
1313
1341
|
//#region src/array/sort.ts
|
|
1314
1342
|
function Sorter(sorters) {
|
|
1315
1343
|
this[SORTER_SYMBOL] = sorters;
|
|
@@ -1335,7 +1363,7 @@ function getComparisonValue(first, second, sorters, length) {
|
|
|
1335
1363
|
return 0;
|
|
1336
1364
|
}
|
|
1337
1365
|
function getModifier(first, second) {
|
|
1338
|
-
return
|
|
1366
|
+
return arrayModifiers[first === true || second === true ? SORT_DIRECTION_DESCENDING : SORT_DIRECTION_ASCENDING];
|
|
1339
1367
|
}
|
|
1340
1368
|
function getObjectSorter(obj, modifier) {
|
|
1341
1369
|
let sorter;
|
|
@@ -1344,7 +1372,7 @@ function getObjectSorter(obj, modifier) {
|
|
|
1344
1372
|
sorter = getValueSortHandlers(obj.key, modifier);
|
|
1345
1373
|
if (typeof obj.compare === "function") sorter.comparison = { complex: obj.compare };
|
|
1346
1374
|
} else if (typeof obj.value === "function") sorter = getValueSortHandlers(obj.value, modifier);
|
|
1347
|
-
if (sorter != null && typeof obj.direction === "string") sorter.modifier =
|
|
1375
|
+
if (sorter != null && typeof obj.direction === "string") sorter.modifier = arrayModifiers[obj.direction] ?? modifier;
|
|
1348
1376
|
return sorter;
|
|
1349
1377
|
}
|
|
1350
1378
|
function getSortedArrayIndex(array, item) {
|
|
@@ -1412,9 +1440,9 @@ function isSortedArray(array) {
|
|
|
1412
1440
|
const sorters = Array.isArray(this) ? this : this[SORTER_SYMBOL];
|
|
1413
1441
|
const sortersLength = sorters.length;
|
|
1414
1442
|
let offset = 0;
|
|
1415
|
-
if (length >=
|
|
1416
|
-
offset = round(length /
|
|
1417
|
-
offset = offset >
|
|
1443
|
+
if (length >= 100) {
|
|
1444
|
+
offset = round(length / 10);
|
|
1445
|
+
offset = offset > 100 ? 100 : offset;
|
|
1418
1446
|
for (let index = 0; index < offset; index += 1) {
|
|
1419
1447
|
const [firstItem, firstOffset] = [array[index], array[index + 1]];
|
|
1420
1448
|
const [secondItem, secondOffset] = [array[length - index - 2], array[length - index - 1]];
|
|
@@ -1439,25 +1467,16 @@ function sortArray(array) {
|
|
|
1439
1467
|
const { length } = sorters;
|
|
1440
1468
|
return array.length > 1 ? array.sort((first, second) => getComparisonValue(first, second, sorters, length)) : array;
|
|
1441
1469
|
}
|
|
1442
|
-
const SORT_PEEK_PERCENTAGE = 10;
|
|
1443
|
-
const SORT_THRESHOLD = 100;
|
|
1444
|
-
const SORT_DIRECTION_ASCENDING = "ascending";
|
|
1445
|
-
const SORT_DIRECTION_DESCENDING = "descending";
|
|
1446
|
-
const SORTER_SYMBOL = Symbol("sorter");
|
|
1447
|
-
const modifiers = {
|
|
1448
|
-
[SORT_DIRECTION_ASCENDING]: 1,
|
|
1449
|
-
[SORT_DIRECTION_DESCENDING]: -1
|
|
1450
|
-
};
|
|
1451
1470
|
sort.getIndex = getSortedIndex;
|
|
1452
1471
|
sort.initialize = initializeSorter;
|
|
1453
1472
|
sort.is = isSorted;
|
|
1454
1473
|
//#endregion
|
|
1455
1474
|
//#region src/internal/array/index-of.ts
|
|
1456
1475
|
function indexOf(array, ...parameters) {
|
|
1457
|
-
return findValue(
|
|
1476
|
+
return findValue(ARRAY_FIND_VALUE_INDEX, array, parameters, false);
|
|
1458
1477
|
}
|
|
1459
1478
|
function lastIndexOf(array, ...parameters) {
|
|
1460
|
-
return findValue(
|
|
1479
|
+
return findValue(ARRAY_FIND_VALUE_INDEX, array, parameters, true);
|
|
1461
1480
|
}
|
|
1462
1481
|
indexOf.last = lastIndexOf;
|
|
1463
1482
|
//#endregion
|
|
@@ -1559,6 +1578,19 @@ toRecord.arrays = toRecordArrays;
|
|
|
1559
1578
|
*/
|
|
1560
1579
|
function noop() {}
|
|
1561
1580
|
//#endregion
|
|
1581
|
+
//#region src/models/function/limiter.model.ts
|
|
1582
|
+
const LIMITER_DEBOUNCE = "debounce";
|
|
1583
|
+
const LIMITER_NAME_ASYNC = "asyncLimiter";
|
|
1584
|
+
const LIMITER_NAME_SYNC = "limiter";
|
|
1585
|
+
const LIMITER_PROPERTY = "$limiter";
|
|
1586
|
+
const LIMITER_SYMBOL = Symbol("limiter");
|
|
1587
|
+
const LIMITER_THROTTLE = "throttle";
|
|
1588
|
+
const LIMITER_WAIT = "wait";
|
|
1589
|
+
// istanbul ignore next
|
|
1590
|
+
const clearTimer = typeof cancelAnimationFrame === "function" ? cancelAnimationFrame : clearTimeout;
|
|
1591
|
+
// istanbul ignore next
|
|
1592
|
+
const startTimer = typeof requestAnimationFrame === "function" ? requestAnimationFrame : setTimeout;
|
|
1593
|
+
//#endregion
|
|
1562
1594
|
//#region src/internal/defaults.ts
|
|
1563
1595
|
function getBooleanOrDefault(value, defaultValue) {
|
|
1564
1596
|
return typeof value === "boolean" ? value : defaultValue;
|
|
@@ -1568,9 +1600,6 @@ function getNumberOrDefault(value, defaultValue, minimum) {
|
|
|
1568
1600
|
}
|
|
1569
1601
|
//#endregion
|
|
1570
1602
|
//#region src/internal/function/limit.ts
|
|
1571
|
-
const LIMITER_NAME_ASYNC = "asyncLimiter";
|
|
1572
|
-
const LIMITER_NAME_SYNC = "limiter";
|
|
1573
|
-
const LIMITER_PROPERTY = "$limiter";
|
|
1574
1603
|
function AsyncLimiter(type, callback, time) {
|
|
1575
1604
|
this[LIMITER_SYMBOL] = {
|
|
1576
1605
|
callback,
|
|
@@ -1616,7 +1645,7 @@ function getLimiter(type, callback, time) {
|
|
|
1616
1645
|
async function handleAsyncLimiter(state, item) {
|
|
1617
1646
|
const now = performance.now();
|
|
1618
1647
|
state.start ??= now;
|
|
1619
|
-
if (state.interval === 0 || now - state.start >= state.interval -
|
|
1648
|
+
if (state.interval === 0 || now - state.start >= state.interval - 5) {
|
|
1620
1649
|
state.start = state.throttle ? now : void 0;
|
|
1621
1650
|
item.running = true;
|
|
1622
1651
|
const result = await asyncAttempt(async () => {
|
|
@@ -1632,7 +1661,7 @@ async function handleAsyncLimiter(state, item) {
|
|
|
1632
1661
|
function handleLimiter(state) {
|
|
1633
1662
|
const now = performance.now();
|
|
1634
1663
|
state.start ??= now;
|
|
1635
|
-
if (state.interval === 0 || now - state.start >= state.interval -
|
|
1664
|
+
if (state.interval === 0 || now - state.start >= state.interval - 5) {
|
|
1636
1665
|
state.start = state.throttle ? now : void 0;
|
|
1637
1666
|
state.callback(...state.parameters);
|
|
1638
1667
|
} else state.timer = startTimer(() => handleLimiter(state));
|
|
@@ -1660,15 +1689,6 @@ function runLimiter(...parameters) {
|
|
|
1660
1689
|
if (state.throttle) handleLimiter(state);
|
|
1661
1690
|
else state.timer = startTimer(() => handleLimiter(state));
|
|
1662
1691
|
}
|
|
1663
|
-
const LIMITER_DEBOUNCE = "debounce";
|
|
1664
|
-
const LIMITER_OFFSET = 5;
|
|
1665
|
-
const LIMITER_SYMBOL = Symbol("limiter");
|
|
1666
|
-
const LIMITER_THROTTLE = "throttle";
|
|
1667
|
-
const LIMITER_WAIT = "wait";
|
|
1668
|
-
// istanbul ignore next
|
|
1669
|
-
const clearTimer = typeof cancelAnimationFrame === "function" ? cancelAnimationFrame : clearTimeout;
|
|
1670
|
-
// istanbul ignore next
|
|
1671
|
-
const startTimer = typeof requestAnimationFrame === "function" ? requestAnimationFrame : setTimeout;
|
|
1672
1692
|
//#endregion
|
|
1673
1693
|
//#region src/function/limit.ts
|
|
1674
1694
|
/**
|
|
@@ -1733,8 +1753,8 @@ function findKey(needle, haystack) {
|
|
|
1733
1753
|
return index > -1 ? keys[index] : needle;
|
|
1734
1754
|
}
|
|
1735
1755
|
function getNestedValue(data, path, ignoreCase) {
|
|
1736
|
-
if (typeof data !== "object" || data === null) return error(
|
|
1737
|
-
if (typeof path !== "string" || path.trim().length === 0) return error(
|
|
1756
|
+
if (typeof data !== "object" || data === null) return error(VALUE_MISC_NESTED_MESSAGE_INPUT);
|
|
1757
|
+
if (typeof path !== "string" || path.trim().length === 0) return error(VALUE_MISC_NESTED_MESSAGE_PATH);
|
|
1738
1758
|
const shouldIgnoreCase = ignoreCase === true;
|
|
1739
1759
|
const paths = getPaths(path, shouldIgnoreCase);
|
|
1740
1760
|
if (typeof paths === "string") return handleValue(data, paths, null, true, shouldIgnoreCase);
|
|
@@ -1750,26 +1770,19 @@ function getNestedValue(data, path, ignoreCase) {
|
|
|
1750
1770
|
}
|
|
1751
1771
|
function getPaths(path, lowercase) {
|
|
1752
1772
|
const normalized = lowercase ? path.toLowerCase() : path;
|
|
1753
|
-
if (!
|
|
1754
|
-
return normalized.replace(
|
|
1773
|
+
if (!VALUE_MISC_EXPRESSION_NESTED.test(normalized)) return normalized;
|
|
1774
|
+
return normalized.replace(VALUE_MISC_EXPRESSION_BRACKET, ".$1").replace(VALUE_MISC_EXPRESSION_DOTS, "").split(".");
|
|
1755
1775
|
}
|
|
1756
1776
|
function handleValue(data, path, value, get, ignoreCase) {
|
|
1757
1777
|
if (typeof data === "object" && data !== null) {
|
|
1758
|
-
if (ignoreKey(path)) return error(
|
|
1778
|
+
if (ignoreKey(path)) return error(VALUE_MISC_NESTED_MESSAGE_UNSAFE);
|
|
1759
1779
|
const dataObject = data;
|
|
1760
1780
|
const key = ignoreCase ? findKey(path, dataObject) : path;
|
|
1761
|
-
if (get) return key in dataObject ? ok(dataObject[key]) : error(
|
|
1781
|
+
if (get) return key in dataObject ? ok(dataObject[key]) : error(VALUE_MISC_NESTED_MESSAGE_MISSING);
|
|
1762
1782
|
dataObject[key] = typeof value === "function" ? value(dataObject[key]) : value;
|
|
1763
1783
|
}
|
|
1764
|
-
if (get) return error(
|
|
1784
|
+
if (get) return error(VALUE_MISC_NESTED_MESSAGE_MISSING);
|
|
1765
1785
|
}
|
|
1766
|
-
const MISC_EXPRESSION_BRACKET = /\[(\w+)\]/g;
|
|
1767
|
-
const MISC_EXPRESSION_DOTS = /^\.|\.$/g;
|
|
1768
|
-
const MISC_EXPRESSION_NESTED = /\.|\[\w+\]/;
|
|
1769
|
-
const MISC_NESTED_MESSAGE_INPUT = "Expected data to be an object";
|
|
1770
|
-
const MISC_NESTED_MESSAGE_MISSING = "Expected property to exist in object";
|
|
1771
|
-
const MISC_NESTED_MESSAGE_PATH = "Expected path to be a string";
|
|
1772
|
-
const MISC_NESTED_MESSAGE_UNSAFE = "Access to this property is not allowed";
|
|
1773
1786
|
//#endregion
|
|
1774
1787
|
//#region src/internal/value/has.ts
|
|
1775
1788
|
function hasValue(data, path, ignoreCase) {
|
|
@@ -1816,7 +1829,7 @@ function assertCondition(condition, message, error) {
|
|
|
1816
1829
|
* @param error Error constructor _(defaults to `Error`)_
|
|
1817
1830
|
*/
|
|
1818
1831
|
function assertDefined(value, message, error) {
|
|
1819
|
-
assert(() => value != null, message ??
|
|
1832
|
+
assert(() => value != null, message ?? "Expected value to be defined", error);
|
|
1820
1833
|
}
|
|
1821
1834
|
/**
|
|
1822
1835
|
* Creates an _Asserter_ that asserts a value is an instance of a constructor, throwing an error if it is not
|
|
@@ -1867,17 +1880,21 @@ function assertProperty(path, condition, message, error) {
|
|
|
1867
1880
|
}, message, error);
|
|
1868
1881
|
};
|
|
1869
1882
|
}
|
|
1870
|
-
const ASSERT_MESSAGE_VALUE_DEFINED = "Expected value to be defined";
|
|
1871
1883
|
assert.condition = assertCondition;
|
|
1872
1884
|
assert.defined = assertDefined;
|
|
1873
1885
|
assert.instanceOf = assertInstanceOf;
|
|
1874
1886
|
assert.is = assertIs;
|
|
1875
1887
|
assert.property = assertProperty;
|
|
1876
1888
|
//#endregion
|
|
1877
|
-
//#region src/function/once.ts
|
|
1889
|
+
//#region src/models/function/once.model.ts
|
|
1878
1890
|
const ONCE_NAME_ASYNC = "asyncOnce";
|
|
1879
1891
|
const ONCE_NAME_SYNC = "once";
|
|
1880
1892
|
const ONCE_PROPERTY = "$once";
|
|
1893
|
+
const ONCE_MESSAGE_CLEARED = "Once has been cleared";
|
|
1894
|
+
const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
|
|
1895
|
+
const ONCE_SYMBOL = Symbol(ONCE_PROPERTY);
|
|
1896
|
+
//#endregion
|
|
1897
|
+
//#region src/function/once.ts
|
|
1881
1898
|
function AsyncOnce(callback) {
|
|
1882
1899
|
this[ONCE_SYMBOL] = {
|
|
1883
1900
|
callback,
|
|
@@ -1969,9 +1986,9 @@ function handleOnceResult(state, value, error) {
|
|
|
1969
1986
|
const items = state.items.splice(0);
|
|
1970
1987
|
const { length } = items;
|
|
1971
1988
|
for (let index = 0; index < length; index += 1) {
|
|
1972
|
-
const
|
|
1973
|
-
if (error) reject(value);
|
|
1974
|
-
else resolve(value);
|
|
1989
|
+
const item = items[index];
|
|
1990
|
+
if (error) item.reject(value);
|
|
1991
|
+
else item.resolve(value);
|
|
1975
1992
|
}
|
|
1976
1993
|
}
|
|
1977
1994
|
/**
|
|
@@ -1993,7 +2010,7 @@ function isOnce(value) {
|
|
|
1993
2010
|
return isOnceInstance(value, ONCE_NAME_SYNC);
|
|
1994
2011
|
}
|
|
1995
2012
|
function isOnceInstance(value, name) {
|
|
1996
|
-
return typeof value === "object" && value !== null &&
|
|
2013
|
+
return typeof value === "object" && value !== null && "$once" in value && value["$once"] === name;
|
|
1997
2014
|
}
|
|
1998
2015
|
/**
|
|
1999
2016
|
* Create a function that can only be called once, returning the same value on subsequent calls
|
|
@@ -2015,7 +2032,7 @@ function runOnce(...parameters) {
|
|
|
2015
2032
|
}
|
|
2016
2033
|
function runOnceAsync(...parameters) {
|
|
2017
2034
|
const state = this[ONCE_SYMBOL];
|
|
2018
|
-
if (state.cleared) return Promise.reject(new Error(ONCE_MESSAGE_CLEARED));
|
|
2035
|
+
if (state.cleared) return Promise.reject(/* @__PURE__ */ new Error(ONCE_MESSAGE_CLEARED));
|
|
2019
2036
|
if (state.finished) return state.error ? Promise.reject(state.value) : Promise.resolve(state.value);
|
|
2020
2037
|
if (state.called) return new Promise((resolve, reject) => {
|
|
2021
2038
|
state.items.push({
|
|
@@ -2036,15 +2053,12 @@ function runOnceAsync(...parameters) {
|
|
|
2036
2053
|
});
|
|
2037
2054
|
});
|
|
2038
2055
|
}
|
|
2039
|
-
const ONCE_MESSAGE_CLEARED = "Once has been cleared";
|
|
2040
|
-
const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
|
|
2041
|
-
const ONCE_SYMBOL = Symbol(ONCE_PROPERTY);
|
|
2042
2056
|
asyncOnce.is = isAsyncOnce;
|
|
2043
2057
|
once.async = asyncOnce;
|
|
2044
2058
|
once.is = isOnce;
|
|
2045
2059
|
once.isAsync = isAsyncOnce;
|
|
2046
2060
|
//#endregion
|
|
2047
|
-
//#region src/function/retry.ts
|
|
2061
|
+
//#region src/models/function/retry.model.ts
|
|
2048
2062
|
/**
|
|
2049
2063
|
* An error thrown when a retry fails
|
|
2050
2064
|
*/
|
|
@@ -2056,6 +2070,11 @@ var RetryError = class extends Error {
|
|
|
2056
2070
|
this.name = RETRY_ERROR_NAME;
|
|
2057
2071
|
}
|
|
2058
2072
|
};
|
|
2073
|
+
const RETRY_ERROR_NAME = "RetryError";
|
|
2074
|
+
const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
|
|
2075
|
+
const RETRY_MESSAGE_FAILED = "Retry failed";
|
|
2076
|
+
//#endregion
|
|
2077
|
+
//#region src/function/retry.ts
|
|
2059
2078
|
/**
|
|
2060
2079
|
* Retry a callback a specified number of times, with a delay between attempts
|
|
2061
2080
|
*
|
|
@@ -2119,11 +2138,22 @@ function retry(callback, options) {
|
|
|
2119
2138
|
function shouldRetry() {
|
|
2120
2139
|
return true;
|
|
2121
2140
|
}
|
|
2122
|
-
const RETRY_ERROR_NAME = "RetryError";
|
|
2123
|
-
const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
|
|
2124
|
-
const RETRY_MESSAGE_FAILED = "Retry failed";
|
|
2125
2141
|
retry.async = asyncRetry;
|
|
2126
2142
|
//#endregion
|
|
2143
|
+
//#region src/models/function/memoize.model.ts
|
|
2144
|
+
const MEMOIZED_CACHE_SIZE_DEFAULT = 1024;
|
|
2145
|
+
const MEMOIZED_CALLBACK = "Memoized requires a callback function";
|
|
2146
|
+
const MEMOIZED_SYMBOL = Symbol("memoized");
|
|
2147
|
+
//#endregion
|
|
2148
|
+
//#region src/models/misc.model.ts
|
|
2149
|
+
const EXPRESSION_INTEGER = /^\d+$/;
|
|
2150
|
+
const EXPRESSION_NUMBER_BINARY = /^0b[01]+$/i;
|
|
2151
|
+
const EXPRESSION_NUMBER_OCTAL = /^0o[0-7]+$/i;
|
|
2152
|
+
const EXPRESSION_NUMBER_ZEROISH = /^\s*0+\s*$/;
|
|
2153
|
+
const EXPRESSION_NUMERICAL_PREFIX = /^\d/;
|
|
2154
|
+
const EXPRESSION_WHITESPACE_MULTIPLE = /\s+/g;
|
|
2155
|
+
const EXPRESSION_WHITESPACE_ONLY = /^\s*$/;
|
|
2156
|
+
//#endregion
|
|
2127
2157
|
//#region src/internal/number.ts
|
|
2128
2158
|
/**
|
|
2129
2159
|
* Is the number between a minimum and maximum value?
|
|
@@ -2184,15 +2214,11 @@ function getNumber(value) {
|
|
|
2184
2214
|
if (typeof parsed !== "string") return getNumber(parsed);
|
|
2185
2215
|
const trimmed = parsed.trim();
|
|
2186
2216
|
if (trimmed.length === 0) return NaN;
|
|
2187
|
-
if (
|
|
2188
|
-
const isBinary =
|
|
2189
|
-
if (isBinary ||
|
|
2217
|
+
if (EXPRESSION_NUMBER_ZEROISH.test(parsed)) return 0;
|
|
2218
|
+
const isBinary = EXPRESSION_NUMBER_BINARY.test(trimmed);
|
|
2219
|
+
if (isBinary || EXPRESSION_NUMBER_OCTAL.test(trimmed)) return Number.parseInt(trimmed.slice(2), isBinary ? 2 : 8);
|
|
2190
2220
|
return Number(trimmed);
|
|
2191
2221
|
}
|
|
2192
|
-
const NUMBER_EXPRESSION_BINARY = /^0b[01]+$/i;
|
|
2193
|
-
const NUMBER_EXPRESSION_OCTAL = /^0o[0-7]+$/i;
|
|
2194
|
-
const NUMBER_EXPRESSION_ZEROISH = /^\s*0+\s*$/;
|
|
2195
|
-
const NUMBER_OCTAL_VALUE = 8;
|
|
2196
2222
|
//#endregion
|
|
2197
2223
|
//#region src/internal/sized/misc.ts
|
|
2198
2224
|
function getSizedMaximum(first, second) {
|
|
@@ -2291,7 +2317,7 @@ function deleteMemoizedValue(key) {
|
|
|
2291
2317
|
}
|
|
2292
2318
|
function createGetter(state, callback) {
|
|
2293
2319
|
return (...parameters) => {
|
|
2294
|
-
const key = state.options.cacheKey?.(...parameters) ?? (parameters.length === 1 ? parameters[0] : join(parameters.map(getString),
|
|
2320
|
+
const key = state.options.cacheKey?.(...parameters) ?? (parameters.length === 1 ? parameters[0] : join(parameters.map(getString), "_"));
|
|
2295
2321
|
if (state.cache.has(key)) return state.cache.get(key);
|
|
2296
2322
|
const value = callback(...parameters);
|
|
2297
2323
|
state.cache.set(key, value);
|
|
@@ -2331,10 +2357,15 @@ function memoize(callback, options) {
|
|
|
2331
2357
|
function runMemoized(...parameters) {
|
|
2332
2358
|
return this[MEMOIZED_SYMBOL].getter(...parameters);
|
|
2333
2359
|
}
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
const
|
|
2337
|
-
const
|
|
2360
|
+
//#endregion
|
|
2361
|
+
//#region src/models/function/work.model.ts
|
|
2362
|
+
const WORK_MESSAGE_FLOW_ARRAY = "Flow expected to receive an array of functions";
|
|
2363
|
+
const WORK_MESSAGE_FLOW_PROMISE = "Synchronous Flow received a promise. Use `flow.async` instead.";
|
|
2364
|
+
const WORK_MESSAGE_NESTING = "Return values are too deeply nested.";
|
|
2365
|
+
const WORK_MESSAGE_PIPE_ARRAY = "Pipe expected to receive an array of functions";
|
|
2366
|
+
const WORK_MESSAGE_PIPE_PROMISE = "Synchronous Pipe received a promise. Use `pipe.async` instead.";
|
|
2367
|
+
const assertFlowFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_FLOW_ARRAY, TypeError);
|
|
2368
|
+
const assertPipeFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_PIPE_ARRAY, TypeError);
|
|
2338
2369
|
//#endregion
|
|
2339
2370
|
//#region src/internal/function/work.ts
|
|
2340
2371
|
function asyncFlow(...fns) {
|
|
@@ -2386,16 +2417,18 @@ function work(initial, functions, flow) {
|
|
|
2386
2417
|
}
|
|
2387
2418
|
return transformed;
|
|
2388
2419
|
}
|
|
2389
|
-
const WORK_MESSAGE_FLOW_ARRAY = "Flow expected to receive an array of functions";
|
|
2390
|
-
const WORK_MESSAGE_FLOW_PROMISE = "Synchronous Flow received a promise. Use `flow.async` instead.";
|
|
2391
|
-
const WORK_MESSAGE_NESTING = "Return values are too deeply nested.";
|
|
2392
|
-
const WORK_MESSAGE_PIPE_ARRAY = "Pipe expected to receive an array of functions";
|
|
2393
|
-
const WORK_MESSAGE_PIPE_PROMISE = "Synchronous Pipe received a promise. Use `pipe.async` instead.";
|
|
2394
|
-
const assertFlowFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_FLOW_ARRAY, TypeError);
|
|
2395
|
-
const assertPipeFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_PIPE_ARRAY, TypeError);
|
|
2396
2420
|
flow.async = asyncFlow;
|
|
2397
2421
|
pipe.async = asyncPipe;
|
|
2398
2422
|
//#endregion
|
|
2423
|
+
//#region src/models/string/string.case.model.ts
|
|
2424
|
+
const STRING_CASE_CAMEL = "camel";
|
|
2425
|
+
const STRING_CASE_KEBAB = "kebab";
|
|
2426
|
+
const STRING_CASE_PASCAL = "pascal";
|
|
2427
|
+
const STRING_CASE_SNAKE = "snake";
|
|
2428
|
+
const STRING_EXPRESSION_CAMEL_CASE = /(\p{Ll})(\p{Lu})/gu;
|
|
2429
|
+
const STRING_EXPRESSION_ACRONYM = /(\p{Lu}*)(\p{Lu})(\p{Ll}+)/gu;
|
|
2430
|
+
const STRING_REPLACEMENT_CAMEL_CASE = "$1-$2";
|
|
2431
|
+
//#endregion
|
|
2399
2432
|
//#region src/internal/string/case.ts
|
|
2400
2433
|
/**
|
|
2401
2434
|
* Convert a string to camel case _(thisIsCamelCase)_
|
|
@@ -2482,7 +2515,7 @@ function toCaseCallback(value) {
|
|
|
2482
2515
|
const partsLength = parts.length;
|
|
2483
2516
|
const cased = [];
|
|
2484
2517
|
for (let partIndex = 0; partIndex < partsLength; partIndex += 1) {
|
|
2485
|
-
const items = parts[partIndex].replace(STRING_EXPRESSION_ACRONYM, (full, one, two, three) => three ===
|
|
2518
|
+
const items = parts[partIndex].replace(STRING_EXPRESSION_ACRONYM, (full, one, two, three) => three === "s" ? full : `${one}-${two}${three}`).replace(STRING_EXPRESSION_CAMEL_CASE, STRING_REPLACEMENT_CAMEL_CASE).split("-");
|
|
2486
2519
|
const itemsLength = items.length;
|
|
2487
2520
|
const partResult = [];
|
|
2488
2521
|
let itemCount = 0;
|
|
@@ -2508,29 +2541,23 @@ function upperCase(value) {
|
|
|
2508
2541
|
memoizedUpperCase ??= memoize((v) => v.toLocaleUpperCase());
|
|
2509
2542
|
return memoizedUpperCase.run(value);
|
|
2510
2543
|
}
|
|
2511
|
-
const STRING_CASE_CAMEL = "camel";
|
|
2512
|
-
const STRING_CASE_KEBAB = "kebab";
|
|
2513
|
-
const STRING_CASE_PASCAL = "pascal";
|
|
2514
|
-
const STRING_CASE_SNAKE = "snake";
|
|
2515
|
-
const STRING_DELIMTER_EMPTY = "";
|
|
2516
|
-
const STRING_DELIMITER_HYPHEN = "-";
|
|
2517
|
-
const STRING_DELIMITER_UNDERSCORE = "_";
|
|
2518
|
-
const STRING_EXPRESSION_CAMEL_CASE = /(\p{Ll})(\p{Lu})/gu;
|
|
2519
|
-
const STRING_EXPRESSION_ACRONYM = /(\p{Lu}*)(\p{Lu})(\p{Ll}+)/gu;
|
|
2520
|
-
const STRING_REPLACEMENT_CAMEL_CASE = "$1-$2";
|
|
2521
|
-
const STRING_S = "s";
|
|
2522
2544
|
const caseMemoizers = {};
|
|
2523
2545
|
const delimiters = {
|
|
2524
|
-
[STRING_CASE_CAMEL]:
|
|
2525
|
-
[STRING_CASE_KEBAB]:
|
|
2526
|
-
[STRING_CASE_PASCAL]:
|
|
2527
|
-
[STRING_CASE_SNAKE]:
|
|
2546
|
+
[STRING_CASE_CAMEL]: "",
|
|
2547
|
+
[STRING_CASE_KEBAB]: "-",
|
|
2548
|
+
[STRING_CASE_PASCAL]: "",
|
|
2549
|
+
[STRING_CASE_SNAKE]: "_"
|
|
2528
2550
|
};
|
|
2529
2551
|
let memoizedCapitalize;
|
|
2530
2552
|
let memoizedLowerCase;
|
|
2531
2553
|
let memoizedTitleCase;
|
|
2532
2554
|
let memoizedUpperCase;
|
|
2533
2555
|
//#endregion
|
|
2556
|
+
//#region src/models/value/value.equal.model.ts
|
|
2557
|
+
const EQUAL_ERROR_PROPERTIES = ["name", "message"];
|
|
2558
|
+
const EQUAL_EXPRESSION_PROPERTIES = ["source", "flags"];
|
|
2559
|
+
const EQUAL_SYMBOL = Symbol("equal");
|
|
2560
|
+
//#endregion
|
|
2534
2561
|
//#region src/internal/value/equal.ts
|
|
2535
2562
|
function Equalizer(options) {
|
|
2536
2563
|
this[EQUAL_SYMBOL] = options;
|
|
@@ -2590,9 +2617,9 @@ function equalArray(first, second, options) {
|
|
|
2590
2617
|
const { length } = first;
|
|
2591
2618
|
if (length !== second.length) return false;
|
|
2592
2619
|
let offset = 0;
|
|
2593
|
-
if (length >=
|
|
2594
|
-
offset = round(length /
|
|
2595
|
-
offset = offset >
|
|
2620
|
+
if (length >= 100) {
|
|
2621
|
+
offset = round(length / 10);
|
|
2622
|
+
offset = offset > 100 ? 100 : offset;
|
|
2596
2623
|
for (let index = 0; index < offset; index += 1) if (!(equalValue(first[index], second[index], options) && equalValue(first[length - index - 1], second[length - index - 1], options))) return false;
|
|
2597
2624
|
}
|
|
2598
2625
|
const end = length - offset;
|
|
@@ -2622,7 +2649,7 @@ function equalPlainObject(first, second, options) {
|
|
|
2622
2649
|
firstKeys = firstKeys.filter((key) => filterKey(key, options));
|
|
2623
2650
|
secondKeys = secondKeys.filter((key) => filterKey(key, options));
|
|
2624
2651
|
}
|
|
2625
|
-
const secondSet = secondKeys.length >=
|
|
2652
|
+
const secondSet = secondKeys.length >= 16 ? new Set(secondKeys) : void 0;
|
|
2626
2653
|
const { length } = firstKeys;
|
|
2627
2654
|
if (length !== secondKeys.length) return false;
|
|
2628
2655
|
for (let index = 0; index < length; index += 1) {
|
|
@@ -2699,12 +2726,6 @@ function initializeEqualizer(options) {
|
|
|
2699
2726
|
function registerEqualizer(constructor, handler) {
|
|
2700
2727
|
equalHandler.base.register(constructor, handler);
|
|
2701
2728
|
}
|
|
2702
|
-
const EQUAL_ARRAY_PEEK_PERCENTAGE = 10;
|
|
2703
|
-
const EQUAL_ARRAY_THRESHOLD = 100;
|
|
2704
|
-
const EQUAL_ERROR_PROPERTIES = ["name", "message"];
|
|
2705
|
-
const EQUAL_EXPRESSION_PROPERTIES = ["source", "flags"];
|
|
2706
|
-
const EQUAL_MINIMUM_LENGTH_FOR_SET = 16;
|
|
2707
|
-
const EQUAL_SYMBOL = Symbol("equal");
|
|
2708
2729
|
const equalHandler = createCompareHandler(equal, { callback: Object.is });
|
|
2709
2730
|
equal.deregister = deregisterEqualizer;
|
|
2710
2731
|
equal.handler = equalHandler;
|
|
@@ -2737,7 +2758,7 @@ function setValue(data, path, value, ignoreCase) {
|
|
|
2737
2758
|
let next = unwrap(handleValue(target, currentPath, null, true, shouldIgnoreCase), void 0);
|
|
2738
2759
|
if (typeof next !== "object" || next === null) {
|
|
2739
2760
|
const nextPath = paths[index + 1];
|
|
2740
|
-
if (
|
|
2761
|
+
if (EXPRESSION_INTEGER.test(nextPath)) next = Array.from({ length: +nextPath + 1 }, () => void 0);
|
|
2741
2762
|
else next = {};
|
|
2742
2763
|
target[currentPath] = next;
|
|
2743
2764
|
}
|
|
@@ -2745,9 +2766,8 @@ function setValue(data, path, value, ignoreCase) {
|
|
|
2745
2766
|
}
|
|
2746
2767
|
return data;
|
|
2747
2768
|
}
|
|
2748
|
-
const SET_EXPRESSION_INDEX = /^\d+$/;
|
|
2749
2769
|
//#endregion
|
|
2750
|
-
//#region src/
|
|
2770
|
+
//#region src/models/plan.model.ts
|
|
2751
2771
|
const GENERATOR_NAME_ASYNC = "AsyncGeneratorFunction";
|
|
2752
2772
|
const GENERATOR_NAME_SYNC = "GeneratorFunction";
|
|
2753
2773
|
const PLAN_MESSAGE_PLAN_INPUT = "plan requires a generator function";
|
|
@@ -2800,18 +2820,39 @@ function isPlanInstance(type, value) {
|
|
|
2800
2820
|
return typeof value === "object" && value !== null && PLAN_SYMBOL in value && value[PLAN_SYMBOL].type === type;
|
|
2801
2821
|
}
|
|
2802
2822
|
//#endregion
|
|
2823
|
+
//#region src/models/aborter.model.ts
|
|
2824
|
+
const ABORTER_EVENT = "abort";
|
|
2825
|
+
const ABORTER_OPTIONS = { once: true };
|
|
2826
|
+
//#endregion
|
|
2827
|
+
//#region src/internal/aborter.ts
|
|
2828
|
+
function createAborter(value, onAbort) {
|
|
2829
|
+
if (!(value instanceof AbortSignal)) return;
|
|
2830
|
+
value.addEventListener(ABORTER_EVENT, onAbort, ABORTER_OPTIONS);
|
|
2831
|
+
return {
|
|
2832
|
+
callback: onAbort,
|
|
2833
|
+
signal: value,
|
|
2834
|
+
cancel: () => value.removeEventListener(ABORTER_EVENT, onAbort)
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
2837
|
+
//#endregion
|
|
2803
2838
|
//#region src/plan/generate.ts
|
|
2804
|
-
async function asyncGenerate(
|
|
2805
|
-
const
|
|
2839
|
+
async function asyncGenerate(input, unwrap, first, second) {
|
|
2840
|
+
const aborter = createAborter(second ?? first, noop);
|
|
2841
|
+
if (aborter != null && aborter.signal.aborted) throw aborter.signal.reason;
|
|
2842
|
+
const parameters = Array.isArray(first) ? first : [];
|
|
2843
|
+
let generator;
|
|
2844
|
+
if (typeof input === "function") generator = input(...parameters);
|
|
2845
|
+
else generator = input.generator(...parameters);
|
|
2806
2846
|
let success = true;
|
|
2807
2847
|
let lastValue;
|
|
2808
2848
|
try {
|
|
2809
2849
|
while (true) {
|
|
2850
|
+
if (aborter != null && aborter.signal.aborted) await generator.throw(aborter.signal.reason);
|
|
2810
2851
|
const next = await generator.next(lastValue);
|
|
2811
|
-
const
|
|
2812
|
-
|
|
2813
|
-
if (value instanceof Error) throw
|
|
2814
|
-
if (isError(value)) throw
|
|
2852
|
+
const done = next.done === true;
|
|
2853
|
+
const { value } = next;
|
|
2854
|
+
if (value instanceof Error) await generator.throw(value);
|
|
2855
|
+
if (isError(value)) await generator.throw(value.error);
|
|
2815
2856
|
lastValue = value;
|
|
2816
2857
|
if (done === true) break;
|
|
2817
2858
|
}
|
|
@@ -2819,13 +2860,17 @@ async function asyncGenerate(callback, parameters, unwrap) {
|
|
|
2819
2860
|
lastValue = error;
|
|
2820
2861
|
success = false;
|
|
2821
2862
|
} finally {
|
|
2822
|
-
|
|
2863
|
+
aborter?.cancel();
|
|
2864
|
+
await generator.return(lastValue);
|
|
2823
2865
|
}
|
|
2866
|
+
if (aborter != null && aborter.signal.aborted) throw aborter.signal.reason;
|
|
2824
2867
|
if (success) return unwrap && isOk(lastValue) ? lastValue.value : lastValue;
|
|
2825
2868
|
throw lastValue;
|
|
2826
2869
|
}
|
|
2827
|
-
function generate(
|
|
2828
|
-
|
|
2870
|
+
function generate(input, parameters, unwrap) {
|
|
2871
|
+
let generator;
|
|
2872
|
+
if (typeof input === "function") generator = input(...parameters);
|
|
2873
|
+
else generator = input.generator(...parameters);
|
|
2829
2874
|
let success = true;
|
|
2830
2875
|
let lastValue;
|
|
2831
2876
|
try {
|
|
@@ -2833,8 +2878,8 @@ function generate(callback, parameters, unwrap) {
|
|
|
2833
2878
|
const next = generator.next(lastValue);
|
|
2834
2879
|
const done = next.done === true;
|
|
2835
2880
|
const { value } = next;
|
|
2836
|
-
if (value instanceof Error) throw
|
|
2837
|
-
if (isError(value)) throw
|
|
2881
|
+
if (value instanceof Error) generator.throw(value);
|
|
2882
|
+
if (isError(value)) generator.throw(value.error);
|
|
2838
2883
|
lastValue = value;
|
|
2839
2884
|
if (done) break;
|
|
2840
2885
|
}
|
|
@@ -2849,28 +2894,32 @@ function generate(callback, parameters, unwrap) {
|
|
|
2849
2894
|
}
|
|
2850
2895
|
//#endregion
|
|
2851
2896
|
//#region src/plan/result.ts
|
|
2852
|
-
function asyncAttemptRun(input,
|
|
2853
|
-
|
|
2854
|
-
if (
|
|
2855
|
-
|
|
2897
|
+
function asyncAttemptRun(input, first, second) {
|
|
2898
|
+
let generator;
|
|
2899
|
+
if (isAsyncPlan(input)) generator = input[PLAN_SYMBOL];
|
|
2900
|
+
else if (isAsyncGenerator(input)) generator = input;
|
|
2901
|
+
if (generator == null) throw new Error(PLAN_MESSAGE_RUN_INPUT);
|
|
2902
|
+
return asyncAttempt(() => asyncGenerate(generator, true, first, second));
|
|
2856
2903
|
}
|
|
2857
2904
|
function attemptRun(input, ...parameters) {
|
|
2858
|
-
|
|
2859
|
-
if (
|
|
2860
|
-
|
|
2905
|
+
let generator;
|
|
2906
|
+
if (isPlan(input)) generator = input[PLAN_SYMBOL];
|
|
2907
|
+
else if (isGenerator(input)) generator = input;
|
|
2908
|
+
if (generator == null) throw new Error(PLAN_MESSAGE_RUN_INPUT);
|
|
2909
|
+
return attempt(() => generate(generator, parameters, true));
|
|
2861
2910
|
}
|
|
2862
|
-
function attemptRunAsyncPlan(
|
|
2863
|
-
return
|
|
2911
|
+
function attemptRunAsyncPlan(first, second) {
|
|
2912
|
+
return asyncAttemptRun(this, first, second);
|
|
2864
2913
|
}
|
|
2865
2914
|
function attemptRunPlan(...parameters) {
|
|
2866
|
-
return attempt(() => generate(this[PLAN_SYMBOL]
|
|
2915
|
+
return attempt(() => generate(this[PLAN_SYMBOL], parameters, true));
|
|
2867
2916
|
}
|
|
2868
2917
|
attemptRun.async = asyncAttemptRun;
|
|
2869
2918
|
//#endregion
|
|
2870
2919
|
//#region src/plan/run.ts
|
|
2871
|
-
function asyncRun(input,
|
|
2872
|
-
if (isAsyncPlan(input)) return input
|
|
2873
|
-
if (isAsyncGenerator(input)) return asyncGenerate(input,
|
|
2920
|
+
function asyncRun(input, first, second) {
|
|
2921
|
+
if (isAsyncPlan(input)) return asyncGenerate(input[PLAN_SYMBOL], false, first, second);
|
|
2922
|
+
if (isAsyncGenerator(input)) return asyncGenerate(input, false, first, second);
|
|
2874
2923
|
throw new Error(PLAN_MESSAGE_RUN_INPUT);
|
|
2875
2924
|
}
|
|
2876
2925
|
function run(input, ...parameters) {
|
|
@@ -2878,11 +2927,11 @@ function run(input, ...parameters) {
|
|
|
2878
2927
|
if (isGenerator(input)) return generate(input, parameters, false);
|
|
2879
2928
|
throw new Error(PLAN_MESSAGE_RUN_INPUT);
|
|
2880
2929
|
}
|
|
2881
|
-
function runAsyncPlan(
|
|
2882
|
-
return asyncGenerate(this[PLAN_SYMBOL]
|
|
2930
|
+
function runAsyncPlan(first, second) {
|
|
2931
|
+
return asyncGenerate(this[PLAN_SYMBOL], false, first, second);
|
|
2883
2932
|
}
|
|
2884
2933
|
function runPlan(...parameters) {
|
|
2885
|
-
return generate(this[PLAN_SYMBOL]
|
|
2934
|
+
return generate(this[PLAN_SYMBOL], parameters, false);
|
|
2886
2935
|
}
|
|
2887
2936
|
asyncRun.attempt = asyncAttemptRun;
|
|
2888
2937
|
run.async = asyncRun;
|
|
@@ -2918,16 +2967,28 @@ function plan(generator) {
|
|
|
2918
2967
|
}
|
|
2919
2968
|
//#endregion
|
|
2920
2969
|
//#region src/plan/misc.ts
|
|
2970
|
+
function PlanFailure(generator) {
|
|
2971
|
+
this[PLAN_SYMBOL] = { generator };
|
|
2972
|
+
}
|
|
2973
|
+
PlanFailure.prototype[Symbol.iterator] = function() {
|
|
2974
|
+
return this[PLAN_SYMBOL].generator();
|
|
2975
|
+
};
|
|
2976
|
+
function PlanSuccess(generator) {
|
|
2977
|
+
this[PLAN_SYMBOL] = { generator };
|
|
2978
|
+
}
|
|
2979
|
+
PlanSuccess.prototype[Symbol.iterator] = function() {
|
|
2980
|
+
return this[PLAN_SYMBOL].generator();
|
|
2981
|
+
};
|
|
2921
2982
|
/**
|
|
2922
2983
|
* Create an immediately failing plan
|
|
2923
2984
|
*
|
|
2924
|
-
* @param
|
|
2985
|
+
* @param value Failure value
|
|
2925
2986
|
* @returns Plan failure
|
|
2926
2987
|
*/
|
|
2927
|
-
function fail(
|
|
2928
|
-
return (function* () {
|
|
2929
|
-
|
|
2930
|
-
})
|
|
2988
|
+
function fail(value) {
|
|
2989
|
+
return new PlanFailure(function* () {
|
|
2990
|
+
yield error(value);
|
|
2991
|
+
});
|
|
2931
2992
|
}
|
|
2932
2993
|
/**
|
|
2933
2994
|
* Create an immediately succeeding plan
|
|
@@ -2936,43 +2997,12 @@ function fail(reason) {
|
|
|
2936
2997
|
* @returns Plan success
|
|
2937
2998
|
*/
|
|
2938
2999
|
function succeed(value) {
|
|
2939
|
-
return (function* () {
|
|
3000
|
+
return new PlanSuccess(function* () {
|
|
2940
3001
|
return value;
|
|
2941
|
-
})
|
|
2942
|
-
}
|
|
2943
|
-
function succeedResult(value) {
|
|
2944
|
-
return (function* () {
|
|
2945
|
-
return ok(value);
|
|
2946
|
-
})();
|
|
2947
|
-
}
|
|
2948
|
-
succeed.result = succeedResult;
|
|
2949
|
-
//#endregion
|
|
2950
|
-
//#region src/internal/aborter.ts
|
|
2951
|
-
function createAborter(value, onAbort) {
|
|
2952
|
-
if (!(value instanceof AbortSignal)) return;
|
|
2953
|
-
value.addEventListener(ABORT_EVENT, onAbort, ABORT_OPTIONS);
|
|
2954
|
-
return {
|
|
2955
|
-
callback: onAbort,
|
|
2956
|
-
signal: value,
|
|
2957
|
-
cancel: () => value.removeEventListener(ABORT_EVENT, onAbort)
|
|
2958
|
-
};
|
|
3002
|
+
});
|
|
2959
3003
|
}
|
|
2960
|
-
const ABORT_EVENT = "abort";
|
|
2961
|
-
const ABORT_OPTIONS = { once: true };
|
|
2962
|
-
//#endregion
|
|
2963
|
-
//#region src/promise/constants.ts
|
|
2964
|
-
const PROMISE_ERROR_NAME = "PromiseTimeoutError";
|
|
2965
|
-
const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
2966
|
-
const PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE = "promises expected an array or object holding promise-functions or promises";
|
|
2967
|
-
const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
2968
|
-
const PROMISE_MESSAGE_EXPECTATION_TIMED = "Timed function expected a Promise";
|
|
2969
|
-
const PROMISE_MESSAGE_TIMEOUT = "Promise timed out";
|
|
2970
|
-
const PROMISE_STRATEGY_ALL = /* @__PURE__ */ new Set(["complete", "first"]);
|
|
2971
|
-
const PROMISE_STRATEGY_DEFAULT = "complete";
|
|
2972
|
-
const PROMISE_TYPE_FULFILLED = "fulfilled";
|
|
2973
|
-
const PROMISE_TYPE_REJECTED = "rejected";
|
|
2974
3004
|
//#endregion
|
|
2975
|
-
//#region src/promise
|
|
3005
|
+
//#region src/models/promise.model.ts
|
|
2976
3006
|
/**
|
|
2977
3007
|
* A _Promise_ that can be canceled
|
|
2978
3008
|
*/
|
|
@@ -3005,6 +3035,16 @@ var PromiseTimeoutError = class extends Error {
|
|
|
3005
3035
|
this.name = PROMISE_ERROR_NAME;
|
|
3006
3036
|
}
|
|
3007
3037
|
};
|
|
3038
|
+
const PROMISE_ERROR_NAME = "PromiseTimeoutError";
|
|
3039
|
+
const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
3040
|
+
const PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE = "promises expected an array or object holding promise-functions or promises";
|
|
3041
|
+
const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
3042
|
+
const PROMISE_MESSAGE_EXPECTATION_TIMED = "Timed function expected a Promise";
|
|
3043
|
+
const PROMISE_MESSAGE_TIMEOUT = "Promise timed out";
|
|
3044
|
+
const PROMISE_STRATEGY_ALL = /* @__PURE__ */ new Set(["complete", "first"]);
|
|
3045
|
+
const PROMISE_STRATEGY_DEFAULT = "complete";
|
|
3046
|
+
const PROMISE_TYPE_FULFILLED = "fulfilled";
|
|
3047
|
+
const PROMISE_TYPE_REJECTED = "rejected";
|
|
3008
3048
|
//#endregion
|
|
3009
3049
|
//#region src/promise/helpers.ts
|
|
3010
3050
|
function createPromiseOptions(input) {
|
|
@@ -3052,7 +3092,10 @@ function getStrategyOrDefault(value) {
|
|
|
3052
3092
|
* @returns `true` if the value is a fulfilled _Promise_ result, otherwise `false`
|
|
3053
3093
|
*/
|
|
3054
3094
|
function isFulfilled(value) {
|
|
3055
|
-
return
|
|
3095
|
+
return isPromiseResult(value, PROMISE_TYPE_FULFILLED);
|
|
3096
|
+
}
|
|
3097
|
+
function isPromiseResult(value, type) {
|
|
3098
|
+
return isPlainObject(value) && "status" in value && value.status === type;
|
|
3056
3099
|
}
|
|
3057
3100
|
/**
|
|
3058
3101
|
* Is the value a rejected _Promise_ result?
|
|
@@ -3061,10 +3104,7 @@ function isFulfilled(value) {
|
|
|
3061
3104
|
* @returns `true` if the value is a rejected _Promise_ result, otherwise `false`
|
|
3062
3105
|
*/
|
|
3063
3106
|
function isRejected(value) {
|
|
3064
|
-
return
|
|
3065
|
-
}
|
|
3066
|
-
function isType(value, type) {
|
|
3067
|
-
return isPlainObject(value) && "status" in value && value.status === type;
|
|
3107
|
+
return isPromiseResult(value, PROMISE_TYPE_REJECTED);
|
|
3068
3108
|
}
|
|
3069
3109
|
//#endregion
|
|
3070
3110
|
//#region src/promise/misc.ts
|
|
@@ -3081,7 +3121,8 @@ function handleResult(status, parameters) {
|
|
|
3081
3121
|
const { aborter, complete, data, handlers, index, key, value } = parameters;
|
|
3082
3122
|
if (aborter?.signal.aborted ?? false) return;
|
|
3083
3123
|
if (!complete && status === "rejected") {
|
|
3084
|
-
|
|
3124
|
+
aborter?.cancel();
|
|
3125
|
+
handlers.reject(value);
|
|
3085
3126
|
return;
|
|
3086
3127
|
}
|
|
3087
3128
|
data.result[key] = !complete ? value : status === "fulfilled" ? {
|
|
@@ -3091,7 +3132,10 @@ function handleResult(status, parameters) {
|
|
|
3091
3132
|
status,
|
|
3092
3133
|
reason: value
|
|
3093
3134
|
};
|
|
3094
|
-
if (index === data.last)
|
|
3135
|
+
if (index === data.last) {
|
|
3136
|
+
aborter?.cancel();
|
|
3137
|
+
handlers.resolve(data.result);
|
|
3138
|
+
}
|
|
3095
3139
|
}
|
|
3096
3140
|
function settlePromise(settler, value, aborter) {
|
|
3097
3141
|
aborter?.cancel();
|
|
@@ -3219,28 +3263,39 @@ async function resultPromises(items, signal) {
|
|
|
3219
3263
|
promises.result = resultPromises;
|
|
3220
3264
|
//#endregion
|
|
3221
3265
|
//#region src/result/match.ts
|
|
3222
|
-
async function asyncMatchResult(result, first,
|
|
3266
|
+
async function asyncMatchResult(result, first, second) {
|
|
3223
3267
|
let value;
|
|
3224
3268
|
if (typeof result === "function") value = await result();
|
|
3225
3269
|
else if (result instanceof Promise) value = await result;
|
|
3226
3270
|
else value = result;
|
|
3227
|
-
if (!isResult(value)) throw new Error(
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3271
|
+
if (!isResult(value)) throw new Error(MATCH_MESSAGE_RESULT);
|
|
3272
|
+
return handleResult$1(value, first, second);
|
|
3273
|
+
}
|
|
3274
|
+
function handleResult$1(result, first, second) {
|
|
3275
|
+
let error;
|
|
3276
|
+
let ok;
|
|
3277
|
+
if (isPlainObject(first)) {
|
|
3278
|
+
ok = first.ok;
|
|
3279
|
+
error = first.error;
|
|
3280
|
+
} else {
|
|
3281
|
+
ok = first;
|
|
3282
|
+
error = second;
|
|
3283
|
+
}
|
|
3284
|
+
if (isOk(result)) {
|
|
3285
|
+
if (typeof ok !== "function") throw new Error(MATCH_MESSAGE_OK);
|
|
3286
|
+
return ok(result.value);
|
|
3287
|
+
}
|
|
3288
|
+
if (typeof error !== "function") throw new Error(MATCH_MESSAGE_ERROR);
|
|
3289
|
+
return error(result.error, result.original);
|
|
3290
|
+
}
|
|
3291
|
+
function matchResult(result, first, second) {
|
|
3235
3292
|
const value = typeof result === "function" ? result() : result;
|
|
3236
|
-
if (!isResult(value)) throw new Error(
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
}
|
|
3243
|
-
const MATCH_MESSAGE = "`result.match` expected a Result or a function that returns a Result";
|
|
3293
|
+
if (!isResult(value)) throw new Error(MATCH_MESSAGE_RESULT);
|
|
3294
|
+
return handleResult$1(value, first, second);
|
|
3295
|
+
}
|
|
3296
|
+
const MATCH_MESSAGE_ERROR = "`result.match` expected an Error callback";
|
|
3297
|
+
const MATCH_MESSAGE_OK = "`result.match` expected an Ok callback";
|
|
3298
|
+
const MATCH_MESSAGE_RESULT = "`result.match` expected a Result or a function that returns a Result";
|
|
3244
3299
|
matchResult.async = asyncMatchResult;
|
|
3245
3300
|
//#endregion
|
|
3246
3301
|
//#region src/result/work/flow.ts
|
|
@@ -3285,6 +3340,12 @@ function attemptPipe(initial, first, ...seconds) {
|
|
|
3285
3340
|
}
|
|
3286
3341
|
attemptPipe.async = attemptAsyncPipe;
|
|
3287
3342
|
//#endregion
|
|
3343
|
+
//#region src/models/string/string.fuzzy.model.ts
|
|
3344
|
+
const FUZZY_MESSAGE_ARRAY = "Fuzzy requires an array of items";
|
|
3345
|
+
const FUZZY_MESSAGE_HANDLER = "Fuzzy requires a key or function to stringify items";
|
|
3346
|
+
const FUZZY_PROPERTY = "$fuzzy";
|
|
3347
|
+
const FUZZY_SYMBOL = Symbol(FUZZY_PROPERTY);
|
|
3348
|
+
//#endregion
|
|
3288
3349
|
//#region src/string/match.ts
|
|
3289
3350
|
/**
|
|
3290
3351
|
* Check if a string ends with a specified substring
|
|
@@ -3295,7 +3356,7 @@ attemptPipe.async = attemptAsyncPipe;
|
|
|
3295
3356
|
* @returns `true` if the string ends with the given substring, otherwise `false`
|
|
3296
3357
|
*/
|
|
3297
3358
|
function endsWith(haystack, needle, ignoreCase) {
|
|
3298
|
-
return match(
|
|
3359
|
+
return match(STRING_MATCH_ENDS_WITH, haystack, needle, ignoreCase === true);
|
|
3299
3360
|
}
|
|
3300
3361
|
/**
|
|
3301
3362
|
* Check if a string includes a specified substring
|
|
@@ -3306,7 +3367,7 @@ function endsWith(haystack, needle, ignoreCase) {
|
|
|
3306
3367
|
* @returns `true` if the string includes the given substring, otherwise `false`
|
|
3307
3368
|
*/
|
|
3308
3369
|
function includes(haystack, needle, ignoreCase) {
|
|
3309
|
-
return match(
|
|
3370
|
+
return match(STRING_MATCH_INCLUDES, haystack, needle, ignoreCase === true);
|
|
3310
3371
|
}
|
|
3311
3372
|
function match(type, haystack, needle, ignoreCase) {
|
|
3312
3373
|
if (typeof haystack !== "string" || typeof needle !== "string") return false;
|
|
@@ -3325,16 +3386,11 @@ function matchCallback(haystack, needle, ignoreCase) {
|
|
|
3325
3386
|
* @returns `true` if the string starts with the given substring, otherwise `false`
|
|
3326
3387
|
*/
|
|
3327
3388
|
function startsWith(haystack, needle, ignoreCase) {
|
|
3328
|
-
return match(
|
|
3389
|
+
return match(STRING_MATCH_STARTS_WITH, haystack, needle, ignoreCase === true);
|
|
3329
3390
|
}
|
|
3330
|
-
const MATCH_ENDS_WITH = "endsWith";
|
|
3331
|
-
const MATCH_INCLUDES = "includes";
|
|
3332
|
-
const MATCH_STARTS_WITH = "startsWith";
|
|
3333
3391
|
const matchMemoizers = {};
|
|
3334
3392
|
//#endregion
|
|
3335
3393
|
//#region src/string/fuzzy.ts
|
|
3336
|
-
const FUZZY_PROPERTY = "$fuzzy";
|
|
3337
|
-
const FUZZY_SYMBOL = Symbol(FUZZY_PROPERTY);
|
|
3338
3394
|
function Fuzzy(state) {
|
|
3339
3395
|
this[FUZZY_SYMBOL] = state;
|
|
3340
3396
|
}
|
|
@@ -3422,19 +3478,19 @@ function getScore(haystack, needle) {
|
|
|
3422
3478
|
if (haystackIndex === 0) score += 1;
|
|
3423
3479
|
if (previousMatchIndex !== -1) {
|
|
3424
3480
|
const gap = haystackIndex - previousMatchIndex - 1;
|
|
3425
|
-
score += max([0,
|
|
3481
|
+
score += max([0, 5 - gap]);
|
|
3426
3482
|
}
|
|
3427
3483
|
previousMatchIndex = haystackIndex;
|
|
3428
3484
|
needleIndex += 1;
|
|
3429
3485
|
}
|
|
3430
3486
|
if (needleIndex === needleLength) break;
|
|
3431
3487
|
}
|
|
3432
|
-
score -= floor(lowerCaseHaystack.length /
|
|
3488
|
+
score -= floor(lowerCaseHaystack.length / 3);
|
|
3433
3489
|
return max([0, score]);
|
|
3434
3490
|
}
|
|
3435
3491
|
function getTolerance(input, state) {
|
|
3436
3492
|
if (typeof input === "number" && !Number.isNaN(input)) return input < 0 ? 0 : floor(input);
|
|
3437
|
-
return state?.tolerance ??
|
|
3493
|
+
return state?.tolerance ?? 5;
|
|
3438
3494
|
}
|
|
3439
3495
|
/**
|
|
3440
3496
|
* Is the value a fuzzy searcher?
|
|
@@ -3445,7 +3501,7 @@ function getTolerance(input, state) {
|
|
|
3445
3501
|
* @returns `true` if the value is a fuzzy searcher, otherwise `false`
|
|
3446
3502
|
*/
|
|
3447
3503
|
function isFuzzy(value) {
|
|
3448
|
-
return typeof value === "object" && value !== null &&
|
|
3504
|
+
return typeof value === "object" && value !== null && "$fuzzy" in value && value["$fuzzy"] === true;
|
|
3449
3505
|
}
|
|
3450
3506
|
function isSubsequence(haystack, needle) {
|
|
3451
3507
|
const lowerCaseHaystack = lowerCase(haystack);
|
|
@@ -3513,12 +3569,8 @@ function setFuzzyItems(value) {
|
|
|
3513
3569
|
if (!Array.isArray(value)) throw new TypeError(FUZZY_MESSAGE_ARRAY);
|
|
3514
3570
|
const state = this[FUZZY_SYMBOL];
|
|
3515
3571
|
state.items = value.slice();
|
|
3516
|
-
state.strings = value.map(state.handler);
|
|
3572
|
+
state.strings = value.map((item) => state.handler(item));
|
|
3517
3573
|
}
|
|
3518
|
-
const FUZZY_LENGTH_DIVISOR = 3;
|
|
3519
|
-
const FUZZY_MESSAGE_ARRAY = "Fuzzy requires an array of items";
|
|
3520
|
-
const FUZZY_MESSAGE_HANDLER = "Fuzzy requires a key or function to stringify items";
|
|
3521
|
-
const FUZZY_PROXIMITY_THRESHOLD = 5;
|
|
3522
3574
|
fuzzy.is = isFuzzy;
|
|
3523
3575
|
fuzzy.match = fuzzyMatch;
|
|
3524
3576
|
//#endregion
|
|
@@ -3534,7 +3586,7 @@ function dedent(value, ...values) {
|
|
|
3534
3586
|
const lastIndex = length - 1;
|
|
3535
3587
|
const lengths = [];
|
|
3536
3588
|
for (let index = 0; index < length; index += 1) {
|
|
3537
|
-
const [, indentation] =
|
|
3589
|
+
const [, indentation] = STRING_EXPRESSION_WHITESPACE_PREFIX.exec(lines[index]) ?? [];
|
|
3538
3590
|
if (indentation != null) lengths.push(indentation.length);
|
|
3539
3591
|
}
|
|
3540
3592
|
if (lengths.length === 0) return actual.trim();
|
|
@@ -3559,16 +3611,16 @@ function getUuid(html) {
|
|
|
3559
3611
|
crypto.getRandomValues(bytes);
|
|
3560
3612
|
bytes[6] = bytes[6] & 15 | 64;
|
|
3561
3613
|
bytes[8] = bytes[8] & 63 | 128;
|
|
3562
|
-
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2,
|
|
3614
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
3563
3615
|
const first = hex.substring(0, 8);
|
|
3564
|
-
if (forHTML &&
|
|
3616
|
+
if (forHTML && EXPRESSION_NUMERICAL_PREFIX.test(first)) continue;
|
|
3565
3617
|
return [
|
|
3566
3618
|
first,
|
|
3567
3619
|
hex.substring(8, 12),
|
|
3568
3620
|
hex.substring(12, 16),
|
|
3569
3621
|
hex.substring(16, 20),
|
|
3570
3622
|
hex.substring(20, 32)
|
|
3571
|
-
].join(forHTML ?
|
|
3623
|
+
].join(forHTML ? "_" : "-");
|
|
3572
3624
|
}
|
|
3573
3625
|
}
|
|
3574
3626
|
/**
|
|
@@ -3611,17 +3663,51 @@ function truncate(value, length, suffix) {
|
|
|
3611
3663
|
const truncatedLength = length - actualSuffixLength;
|
|
3612
3664
|
return `${value.slice(0, truncatedLength)}${actualSuffix}`;
|
|
3613
3665
|
}
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
const
|
|
3617
|
-
|
|
3666
|
+
//#endregion
|
|
3667
|
+
//#region src/models/string/string.normalize.model.ts
|
|
3668
|
+
const NORMALIZE_DEBURR_CHARACTERS = {
|
|
3669
|
+
Æ: "AE",
|
|
3670
|
+
æ: "ae",
|
|
3671
|
+
Ð: "D",
|
|
3672
|
+
ð: "d",
|
|
3673
|
+
Đ: "D",
|
|
3674
|
+
đ: "d",
|
|
3675
|
+
Ħ: "H",
|
|
3676
|
+
ħ: "h",
|
|
3677
|
+
IJ: "IJ",
|
|
3678
|
+
ij: "ij",
|
|
3679
|
+
İ: "I",
|
|
3680
|
+
ı: "i",
|
|
3681
|
+
ĸ: "k",
|
|
3682
|
+
Ŀ: "L",
|
|
3683
|
+
ŀ: "l",
|
|
3684
|
+
Ł: "L",
|
|
3685
|
+
ł: "l",
|
|
3686
|
+
Ŋ: "N",
|
|
3687
|
+
ŋ: "n",
|
|
3688
|
+
ʼn: "'n",
|
|
3689
|
+
Œ: "OE",
|
|
3690
|
+
œ: "oe",
|
|
3691
|
+
Ø: "O",
|
|
3692
|
+
ø: "o",
|
|
3693
|
+
ſ: "s",
|
|
3694
|
+
ß: "ss",
|
|
3695
|
+
Þ: "TH",
|
|
3696
|
+
þ: "th",
|
|
3697
|
+
Ŧ: "T",
|
|
3698
|
+
ŧ: "t"
|
|
3699
|
+
};
|
|
3700
|
+
const NORMALIZE_DEBURR_PATTERN_CHARACTERS = new RegExp(`(${Object.keys(NORMALIZE_DEBURR_CHARACTERS).join("|")})`, "g");
|
|
3701
|
+
const NORMALIZE_DEBURR_PATTERN_SIMPLE = /[\u0300-\u036f]/g;
|
|
3702
|
+
const NORMALIZE_SPECIAL_PATTERN = /[\p{P}\p{S}]/gu;
|
|
3703
|
+
const NORMALIZE_SYMBOL = Symbol("normalize");
|
|
3618
3704
|
//#endregion
|
|
3619
3705
|
//#region src/string/normalize.ts
|
|
3620
3706
|
function Normalizer(options) {
|
|
3621
3707
|
this[NORMALIZE_SYMBOL] = options;
|
|
3622
3708
|
}
|
|
3623
3709
|
Normalizer.prototype.normalize = normalizeString;
|
|
3624
|
-
function
|
|
3710
|
+
function createNormalizerOptions(input) {
|
|
3625
3711
|
const options = isPlainObject(input) ? input : {};
|
|
3626
3712
|
return {
|
|
3627
3713
|
deburr: options.deburr !== false,
|
|
@@ -3640,7 +3726,7 @@ function createNormalizeOptions(input) {
|
|
|
3640
3726
|
function deburr(value) {
|
|
3641
3727
|
if (typeof value !== "string") return "";
|
|
3642
3728
|
deburrMemoizer ??= memoize((value) => {
|
|
3643
|
-
let deburred = value.normalize(
|
|
3729
|
+
let deburred = value.normalize("NFD").replace(NORMALIZE_DEBURR_PATTERN_SIMPLE, "");
|
|
3644
3730
|
deburred = deburred.replace(NORMALIZE_DEBURR_PATTERN_CHARACTERS, (_, character) => NORMALIZE_DEBURR_CHARACTERS[character]);
|
|
3645
3731
|
return deburred;
|
|
3646
3732
|
});
|
|
@@ -3655,7 +3741,7 @@ function deburr(value) {
|
|
|
3655
3741
|
* @returns Normalizer function
|
|
3656
3742
|
*/
|
|
3657
3743
|
function initializeNormalizer(options) {
|
|
3658
|
-
return new Normalizer(
|
|
3744
|
+
return new Normalizer(createNormalizerOptions(options));
|
|
3659
3745
|
}
|
|
3660
3746
|
/**
|
|
3661
3747
|
* Normalize a string
|
|
@@ -3667,63 +3753,26 @@ function initializeNormalizer(options) {
|
|
|
3667
3753
|
* @returns Normalized string
|
|
3668
3754
|
*/
|
|
3669
3755
|
function normalize(value, options) {
|
|
3670
|
-
return normalizeString.call(
|
|
3756
|
+
return normalizeString.call(createNormalizerOptions(options), value);
|
|
3671
3757
|
}
|
|
3672
3758
|
function normalizeString(value) {
|
|
3673
3759
|
if (typeof value !== "string") return "";
|
|
3674
3760
|
const options = NORMALIZE_SYMBOL in this ? this[NORMALIZE_SYMBOL] : this;
|
|
3675
3761
|
let result = value;
|
|
3676
3762
|
if (options.trim) result = result.trim();
|
|
3677
|
-
if (options.whitespace) result = result.replace(
|
|
3763
|
+
if (options.whitespace) result = result.replace(EXPRESSION_WHITESPACE_MULTIPLE, " ");
|
|
3678
3764
|
if (options.deburr) result = deburr(result);
|
|
3679
3765
|
if (options.lowerCase) result = lowerCase(result);
|
|
3680
|
-
if (options.special) result = result.replace(NORMALIZE_SPECIAL_PATTERN,
|
|
3681
|
-
return result.normalize(
|
|
3766
|
+
if (options.special) result = result.replace(NORMALIZE_SPECIAL_PATTERN, "");
|
|
3767
|
+
return result.normalize("NFC");
|
|
3682
3768
|
}
|
|
3683
|
-
const NORMALIZE_DEBURR_CHARACTERS = {
|
|
3684
|
-
Æ: "AE",
|
|
3685
|
-
æ: "ae",
|
|
3686
|
-
Ð: "D",
|
|
3687
|
-
ð: "d",
|
|
3688
|
-
Đ: "D",
|
|
3689
|
-
đ: "d",
|
|
3690
|
-
Ħ: "H",
|
|
3691
|
-
ħ: "h",
|
|
3692
|
-
IJ: "IJ",
|
|
3693
|
-
ij: "ij",
|
|
3694
|
-
İ: "I",
|
|
3695
|
-
ı: "i",
|
|
3696
|
-
ĸ: "k",
|
|
3697
|
-
Ŀ: "L",
|
|
3698
|
-
ŀ: "l",
|
|
3699
|
-
Ł: "L",
|
|
3700
|
-
ł: "l",
|
|
3701
|
-
Ŋ: "N",
|
|
3702
|
-
ŋ: "n",
|
|
3703
|
-
ʼn: "'n",
|
|
3704
|
-
Œ: "OE",
|
|
3705
|
-
œ: "oe",
|
|
3706
|
-
Ø: "O",
|
|
3707
|
-
ø: "o",
|
|
3708
|
-
ſ: "s",
|
|
3709
|
-
ß: "ss",
|
|
3710
|
-
Þ: "TH",
|
|
3711
|
-
þ: "th",
|
|
3712
|
-
Ŧ: "T",
|
|
3713
|
-
ŧ: "t"
|
|
3714
|
-
};
|
|
3715
|
-
const NORMALIZE_DEBURR_NORMALIZATION = "NFD";
|
|
3716
|
-
const NORMALIZE_DEBURR_PATTERN_CHARACTERS = new RegExp(`(${Object.keys(NORMALIZE_DEBURR_CHARACTERS).join("|")})`, "g");
|
|
3717
|
-
const NORMALIZE_DEBURR_PATTERN_SIMPLE = /[\u0300-\u036f]/g;
|
|
3718
|
-
const NORMALIZE_NORMALIZATION_NORMALIZATION = "NFC";
|
|
3719
|
-
const NORMALIZE_SPECIAL_PATTERN = /[\p{P}\p{S}]/gu;
|
|
3720
|
-
const NORMALIZE_SPECIAL_REPLACEMENT = "";
|
|
3721
|
-
const NORMALIZE_SYMBOL = Symbol("normalize");
|
|
3722
|
-
const NORMALIZE_WHITESPACE_PATTERN = /\s+/g;
|
|
3723
|
-
const NORMALIZE_WHITESPACE_REPLACEMENT = " ";
|
|
3724
3769
|
let deburrMemoizer;
|
|
3725
3770
|
normalize.initialize = initializeNormalizer;
|
|
3726
3771
|
//#endregion
|
|
3772
|
+
//#region src/models/string/string.template.model.ts
|
|
3773
|
+
const TEMPLATE_EXPRESSION_VARIABLE = /{{([\s\S]+?)}}/g;
|
|
3774
|
+
const TEMPLATE_SYMBOL = Symbol("template");
|
|
3775
|
+
//#endregion
|
|
3727
3776
|
//#region src/string/template.ts
|
|
3728
3777
|
function Templater(options) {
|
|
3729
3778
|
this[TEMPLATE_SYMBOL] = options;
|
|
@@ -3774,12 +3823,31 @@ function template(value, ...parameters) {
|
|
|
3774
3823
|
const { ignoreCase, pattern } = createTemplateOptions(parameters[1]);
|
|
3775
3824
|
return handleTemplate(value, pattern, ignoreCase, parameters[0]);
|
|
3776
3825
|
}
|
|
3777
|
-
const TEMPLATE_EXPRESSION_VARIABLE = /{{([\s\S]+?)}}/g;
|
|
3778
|
-
const TEMPLATE_SYMBOL = Symbol("template");
|
|
3779
3826
|
template.initialize = initializeTemplater;
|
|
3780
3827
|
//#endregion
|
|
3781
|
-
//#region src/value/clone.ts
|
|
3828
|
+
//#region src/models/value/value.clone.model.ts
|
|
3782
3829
|
const CLONE_NAME = "clone";
|
|
3830
|
+
const CLONE_COPY_OPTIONS = {
|
|
3831
|
+
copyFunctions: true,
|
|
3832
|
+
copySymbols: true
|
|
3833
|
+
};
|
|
3834
|
+
const CLONE_DEFAULT_OPTIONS = {
|
|
3835
|
+
copyFunctions: false,
|
|
3836
|
+
copySymbols: false
|
|
3837
|
+
};
|
|
3838
|
+
const CLONE_PRIMITIVES = {
|
|
3839
|
+
bigint: true,
|
|
3840
|
+
boolean: true,
|
|
3841
|
+
function: false,
|
|
3842
|
+
number: true,
|
|
3843
|
+
object: false,
|
|
3844
|
+
string: true,
|
|
3845
|
+
symbol: false,
|
|
3846
|
+
undefined: true
|
|
3847
|
+
};
|
|
3848
|
+
const CLONE_SYMBOL = Symbol(CLONE_NAME);
|
|
3849
|
+
//#endregion
|
|
3850
|
+
//#region src/value/clone.ts
|
|
3783
3851
|
function Cloner(options) {
|
|
3784
3852
|
this[CLONE_SYMBOL] = options;
|
|
3785
3853
|
}
|
|
@@ -3816,14 +3884,14 @@ function cloneAny(value, parameters, depth, options) {
|
|
|
3816
3884
|
}
|
|
3817
3885
|
}
|
|
3818
3886
|
function cloneArrayBuffer(value, parameters, depth) {
|
|
3819
|
-
if (parameters.copy || depth >=
|
|
3887
|
+
if (parameters.copy || depth >= 100) return value;
|
|
3820
3888
|
const cloned = new ArrayBuffer(value.byteLength);
|
|
3821
3889
|
new Uint8Array(cloned).set(new Uint8Array(value));
|
|
3822
3890
|
parameters.references.set(value, cloned);
|
|
3823
3891
|
return cloned;
|
|
3824
3892
|
}
|
|
3825
3893
|
function cloneDataView(value, parameters, depth) {
|
|
3826
|
-
if (parameters.copy || depth >=
|
|
3894
|
+
if (parameters.copy || depth >= 100) return value;
|
|
3827
3895
|
const buffer = cloneArrayBuffer(value.buffer, parameters, depth);
|
|
3828
3896
|
const cloned = new DataView(buffer, value.byteOffset, value.byteLength);
|
|
3829
3897
|
parameters.references.set(value, cloned);
|
|
@@ -3836,7 +3904,7 @@ function cloneFromCloner(value) {
|
|
|
3836
3904
|
}, 0);
|
|
3837
3905
|
}
|
|
3838
3906
|
function cloneMap(map, parameters, depth) {
|
|
3839
|
-
if (depth >=
|
|
3907
|
+
if (depth >= 100) return map;
|
|
3840
3908
|
if (parameters.copy) return new Map(map);
|
|
3841
3909
|
const cloned = /* @__PURE__ */ new Map();
|
|
3842
3910
|
for (const [key, value] of map.entries()) cloned.set(cloneAny(key, parameters, depth + 1), cloneAny(value, parameters, depth + 1));
|
|
@@ -3844,13 +3912,13 @@ function cloneMap(map, parameters, depth) {
|
|
|
3844
3912
|
return cloned;
|
|
3845
3913
|
}
|
|
3846
3914
|
function cloneNode(node, parameters, depth) {
|
|
3847
|
-
if (parameters.copy || depth >=
|
|
3915
|
+
if (parameters.copy || depth >= 100) return node;
|
|
3848
3916
|
const cloned = node.cloneNode(true);
|
|
3849
3917
|
parameters.references.set(node, cloned);
|
|
3850
3918
|
return cloned;
|
|
3851
3919
|
}
|
|
3852
3920
|
function cloneObject(value, parameters, depth) {
|
|
3853
|
-
if (depth >=
|
|
3921
|
+
if (depth >= 100) return value;
|
|
3854
3922
|
const isArray = Array.isArray(value);
|
|
3855
3923
|
if (parameters.copy) return isArray ? value.slice() : { ...value };
|
|
3856
3924
|
const cloned = isArray ? [] : {};
|
|
@@ -3864,14 +3932,14 @@ function cloneObject(value, parameters, depth) {
|
|
|
3864
3932
|
return cloned;
|
|
3865
3933
|
}
|
|
3866
3934
|
function cloneRegularExpression(value, parameters, depth) {
|
|
3867
|
-
if (parameters.copy || depth >=
|
|
3935
|
+
if (parameters.copy || depth >= 100) return value;
|
|
3868
3936
|
const cloned = new RegExp(value.source, value.flags);
|
|
3869
3937
|
cloned.lastIndex = value.lastIndex;
|
|
3870
3938
|
parameters.references.set(value, cloned);
|
|
3871
3939
|
return cloned;
|
|
3872
3940
|
}
|
|
3873
3941
|
function cloneSet(set, parameters, depth) {
|
|
3874
|
-
if (depth >=
|
|
3942
|
+
if (depth >= 100) return set;
|
|
3875
3943
|
if (parameters.copy) return new Set(set);
|
|
3876
3944
|
const cloned = /* @__PURE__ */ new Set();
|
|
3877
3945
|
for (const value of set.values()) cloned.add(cloneAny(value, parameters, depth + 1));
|
|
@@ -3879,7 +3947,7 @@ function cloneSet(set, parameters, depth) {
|
|
|
3879
3947
|
return cloned;
|
|
3880
3948
|
}
|
|
3881
3949
|
function cloneTypedArray(value, parameters, depth) {
|
|
3882
|
-
if (parameters.copy || depth >=
|
|
3950
|
+
if (parameters.copy || depth >= 100) return value;
|
|
3883
3951
|
const cloned = new value.constructor(value);
|
|
3884
3952
|
parameters.references.set(value, cloned);
|
|
3885
3953
|
return cloned;
|
|
@@ -3931,35 +3999,15 @@ function registerCloner(constructor, handler) {
|
|
|
3931
3999
|
cloneHandler.base.register(constructor, handler);
|
|
3932
4000
|
}
|
|
3933
4001
|
function tryStructuredClone(value, parameters, depth) {
|
|
3934
|
-
if (depth >=
|
|
4002
|
+
if (depth >= 100) return value;
|
|
3935
4003
|
const cloned = unwrap(attempt(() => structuredClone(value)), value);
|
|
3936
4004
|
parameters.references.set(value, cloned);
|
|
3937
4005
|
return cloned;
|
|
3938
4006
|
}
|
|
3939
|
-
const CLONE_COPY_OPTIONS = {
|
|
3940
|
-
copyFunctions: true,
|
|
3941
|
-
copySymbols: true
|
|
3942
|
-
};
|
|
3943
|
-
const CLONE_DEFAULT_OPTIONS = {
|
|
3944
|
-
copyFunctions: false,
|
|
3945
|
-
copySymbols: false
|
|
3946
|
-
};
|
|
3947
|
-
const CLONE_MAX_DEPTH = 100;
|
|
3948
4007
|
const cloneHandler = createValueHandler(clone, {
|
|
3949
4008
|
callback: tryStructuredClone,
|
|
3950
4009
|
method: CLONE_NAME
|
|
3951
4010
|
});
|
|
3952
|
-
const CLONE_PRIMITIVES = {
|
|
3953
|
-
bigint: true,
|
|
3954
|
-
boolean: true,
|
|
3955
|
-
function: false,
|
|
3956
|
-
number: true,
|
|
3957
|
-
object: false,
|
|
3958
|
-
string: true,
|
|
3959
|
-
symbol: false,
|
|
3960
|
-
undefined: true
|
|
3961
|
-
};
|
|
3962
|
-
const CLONE_SYMBOL = Symbol(CLONE_NAME);
|
|
3963
4011
|
clone.deregister = deregisterCloner;
|
|
3964
4012
|
clone.handlers = cloneHandler;
|
|
3965
4013
|
clone.initialize = initializeCloner;
|
|
@@ -3984,10 +4032,16 @@ function inMap(map, value, key) {
|
|
|
3984
4032
|
function inSet(set, value) {
|
|
3985
4033
|
if (!(set instanceof Set)) return false;
|
|
3986
4034
|
if (set.has(value)) return true;
|
|
4035
|
+
if (isPrimitive(value)) return false;
|
|
3987
4036
|
for (const item of set) if (equal(item, value)) return true;
|
|
3988
4037
|
return false;
|
|
3989
4038
|
}
|
|
3990
4039
|
//#endregion
|
|
4040
|
+
//#region src/models/value/value.diff.model.ts
|
|
4041
|
+
const DIFF_FULL = "full";
|
|
4042
|
+
const DIFF_NONE = "none";
|
|
4043
|
+
const DIFF_PARTIAL = "partial";
|
|
4044
|
+
//#endregion
|
|
3991
4045
|
//#region src/value/diff.ts
|
|
3992
4046
|
/**
|
|
3993
4047
|
* Find the differences between two values
|
|
@@ -4087,9 +4141,6 @@ function setChanges(parameters) {
|
|
|
4087
4141
|
const diffsLength = diffs.length;
|
|
4088
4142
|
for (let diffIndex = 0; diffIndex < diffsLength; diffIndex += 1) changes.push(diffs[diffIndex]);
|
|
4089
4143
|
}
|
|
4090
|
-
const DIFF_FULL = "full";
|
|
4091
|
-
const DIFF_NONE = "none";
|
|
4092
|
-
const DIFF_PARTIAL = "partial";
|
|
4093
4144
|
//#endregion
|
|
4094
4145
|
//#region src/value/freeze.ts
|
|
4095
4146
|
function fakeDelete() {
|
|
@@ -4231,7 +4282,7 @@ function shake(value) {
|
|
|
4231
4282
|
//#endregion
|
|
4232
4283
|
//#region src/value/smush.ts
|
|
4233
4284
|
function flattenObject(value, depth, smushed, prefix) {
|
|
4234
|
-
if (depth >=
|
|
4285
|
+
if (depth >= 100) return {};
|
|
4235
4286
|
if (smushed.has(value)) return smushed.get(value);
|
|
4236
4287
|
const keys = Object.keys(value);
|
|
4237
4288
|
const { length } = keys;
|
|
@@ -4263,7 +4314,6 @@ function flattenObject(value, depth, smushed, prefix) {
|
|
|
4263
4314
|
function smush(value) {
|
|
4264
4315
|
return typeof value === "object" && value !== null ? flattenObject(value, 0, /* @__PURE__ */ new WeakMap()) : {};
|
|
4265
4316
|
}
|
|
4266
|
-
const SMUSH_MAX_DEPTH = 100;
|
|
4267
4317
|
//#endregion
|
|
4268
4318
|
//#region src/value/unsmush.ts
|
|
4269
4319
|
function getKeys(value) {
|
|
@@ -4300,6 +4350,10 @@ function unsmush(value) {
|
|
|
4300
4350
|
return unsmushed;
|
|
4301
4351
|
}
|
|
4302
4352
|
//#endregion
|
|
4353
|
+
//#region src/models/value/value.merge.model.ts
|
|
4354
|
+
const MERGE_SYMBOL_ASSIGN = Symbol("assign");
|
|
4355
|
+
const MERGE_SYMBOL_MERGE = Symbol("merge");
|
|
4356
|
+
//#endregion
|
|
4303
4357
|
//#region src/value/merge.ts
|
|
4304
4358
|
function Assigner(options) {
|
|
4305
4359
|
this[MERGE_SYMBOL_ASSIGN] = {
|
|
@@ -4321,21 +4375,22 @@ Merger.prototype.merge = mergeFromMerger;
|
|
|
4321
4375
|
* @returns Assigned value
|
|
4322
4376
|
*/
|
|
4323
4377
|
function assign(to, from, options) {
|
|
4324
|
-
const actual =
|
|
4378
|
+
const actual = createMergingOptions(options);
|
|
4325
4379
|
actual.assignValues = true;
|
|
4326
4380
|
return mergeValues([to, ...from], actual);
|
|
4327
4381
|
}
|
|
4328
4382
|
function assignFromAssigner(to, from) {
|
|
4329
4383
|
return mergeValues([to, ...from], this[MERGE_SYMBOL_ASSIGN]);
|
|
4330
4384
|
}
|
|
4331
|
-
function
|
|
4385
|
+
function createMergingOptions(input) {
|
|
4332
4386
|
const actual = {
|
|
4333
4387
|
assignValues: false,
|
|
4334
4388
|
replaceableObjects: void 0,
|
|
4335
4389
|
skipNullableAny: false,
|
|
4336
4390
|
skipNullableInArrays: false
|
|
4337
4391
|
};
|
|
4338
|
-
if (typeof
|
|
4392
|
+
if (typeof input !== "object" || input == null) return actual;
|
|
4393
|
+
const options = input;
|
|
4339
4394
|
actual.replaceableObjects = getReplaceableObjects(options.replaceableObjects);
|
|
4340
4395
|
actual.assignValues = options.assignValues === true;
|
|
4341
4396
|
actual.skipNullableAny = options.skipNullableAny === true;
|
|
@@ -4356,7 +4411,7 @@ function getReplaceableObjects(value) {
|
|
|
4356
4411
|
* @returns Assigner function
|
|
4357
4412
|
*/
|
|
4358
4413
|
function initializeAssigner(options) {
|
|
4359
|
-
return new Assigner(
|
|
4414
|
+
return new Assigner(createMergingOptions(options));
|
|
4360
4415
|
}
|
|
4361
4416
|
/**
|
|
4362
4417
|
* Create a merger with predefined options
|
|
@@ -4367,7 +4422,7 @@ function initializeAssigner(options) {
|
|
|
4367
4422
|
* @returns Merger function
|
|
4368
4423
|
*/
|
|
4369
4424
|
function initializeMerger(options) {
|
|
4370
|
-
return new Merger(
|
|
4425
|
+
return new Merger(createMergingOptions(options));
|
|
4371
4426
|
}
|
|
4372
4427
|
/**
|
|
4373
4428
|
* Merge multiple arrays or objects into a single one
|
|
@@ -4377,7 +4432,7 @@ function initializeMerger(options) {
|
|
|
4377
4432
|
* @returns Merged value
|
|
4378
4433
|
*/
|
|
4379
4434
|
function merge(values, options) {
|
|
4380
|
-
return mergeValues(values,
|
|
4435
|
+
return mergeValues(values, createMergingOptions(options));
|
|
4381
4436
|
}
|
|
4382
4437
|
function mergeFromMerger(values) {
|
|
4383
4438
|
return mergeValues(values, this[MERGE_SYMBOL_MERGE]);
|
|
@@ -4411,11 +4466,12 @@ function mergeValues(values, options, prefix) {
|
|
|
4411
4466
|
if (actual.length > 1) return mergeObjects(actual, options, options.assignValues ? actual[0] : void 0, prefix);
|
|
4412
4467
|
return options.assignValues ? actual[0] : Array.isArray(actual[0]) ? actual[0].slice() : { ...actual[0] };
|
|
4413
4468
|
}
|
|
4414
|
-
const MERGE_SYMBOL_ASSIGN = Symbol("assign");
|
|
4415
|
-
const MERGE_SYMBOL_MERGE = Symbol("merge");
|
|
4416
4469
|
assign.initialize = initializeAssigner;
|
|
4417
4470
|
merge.initialize = initializeMerger;
|
|
4418
4471
|
//#endregion
|
|
4472
|
+
//#region src/models/value/value.transform.model.ts
|
|
4473
|
+
const TRANSFORM_SYMBOL = Symbol("transform");
|
|
4474
|
+
//#endregion
|
|
4419
4475
|
//#region src/value/transform.ts
|
|
4420
4476
|
function Transformer(transformer) {
|
|
4421
4477
|
this[TRANSFORM_SYMBOL] = transformer;
|
|
@@ -4454,13 +4510,18 @@ function transformValue(value) {
|
|
|
4454
4510
|
}
|
|
4455
4511
|
return value;
|
|
4456
4512
|
}
|
|
4457
|
-
const TRANSFORM_SYMBOL = Symbol("transform");
|
|
4458
4513
|
transform.initialize = initializeTransformer;
|
|
4459
4514
|
//#endregion
|
|
4460
|
-
//#region src/
|
|
4515
|
+
//#region src/models/subscription.model.ts
|
|
4516
|
+
const SUBSCRIPTION_DISALLOWED_KEY = "Disallowed key for subscription";
|
|
4517
|
+
const SUBSCRIPTION_INVALID_KEY = "Invalid key for subscription";
|
|
4518
|
+
const SUBSCRIPTION_INVALID_VALUE = "A subscription requires a non-null value to identify it";
|
|
4461
4519
|
const SUBSCRIPTION_NAME = "subscription";
|
|
4462
4520
|
const SUBSCRIPTION_PROPERTY = "$subscription";
|
|
4463
4521
|
const SUBSCRIPTION_STORE = "subscriptions";
|
|
4522
|
+
const SUBSCRIPTION_SYMBOL = Symbol(SUBSCRIPTION_PROPERTY);
|
|
4523
|
+
//#endregion
|
|
4524
|
+
//#region src/internal/subscription.ts
|
|
4464
4525
|
function Subscription(state, property, parameters) {
|
|
4465
4526
|
this[SUBSCRIPTION_SYMBOL] = state;
|
|
4466
4527
|
this[property.key] = property.value;
|
|
@@ -4617,7 +4678,7 @@ function isSubscription(value) {
|
|
|
4617
4678
|
return isSubscriptionInstance(value, SUBSCRIPTION_NAME);
|
|
4618
4679
|
}
|
|
4619
4680
|
function isSubscriptionInstance(value, name) {
|
|
4620
|
-
return typeof value === "object" && value !== null &&
|
|
4681
|
+
return typeof value === "object" && value !== null && "$subscription" in value && value["$subscription"] === name;
|
|
4621
4682
|
}
|
|
4622
4683
|
/**
|
|
4623
4684
|
* Is the value a subscriptions store?
|
|
@@ -4668,15 +4729,22 @@ function removeSubscription() {
|
|
|
4668
4729
|
function subscriptions(parameters) {
|
|
4669
4730
|
return new Subscriptions(parameters);
|
|
4670
4731
|
}
|
|
4671
|
-
const SUBSCRIPTION_DISALLOWED_KEY = "Disallowed key for subscription";
|
|
4672
|
-
const SUBSCRIPTION_INVALID_KEY = "Invalid key for subscription";
|
|
4673
|
-
const SUBSCRIPTION_INVALID_VALUE = "A subscription requires a non-null value to identify it";
|
|
4674
|
-
const SUBSCRIPTION_SYMBOL = Symbol(SUBSCRIPTION_PROPERTY);
|
|
4675
4732
|
//#endregion
|
|
4676
|
-
//#region src/beacon.ts
|
|
4733
|
+
//#region src/models/beacon.model.ts
|
|
4734
|
+
const BEACON_MESSAGE_RETRIEVE = "Cannot retrieve observable from a closed beacon";
|
|
4735
|
+
const BEACON_MESSAGE_SUBSCRIBE = "Cannot subscribe to a closed observable";
|
|
4677
4736
|
const BEACON_PROPERTY = "$beacon";
|
|
4678
4737
|
const BEACON_NAME = "beacon";
|
|
4679
4738
|
const BEACON_OBSERVABLE = "observable";
|
|
4739
|
+
const BEACON_SYMBOL = Symbol(BEACON_PROPERTY);
|
|
4740
|
+
const BEACON_TYPE_ERROR = "error";
|
|
4741
|
+
const BEACON_TYPE_NEXT = "next";
|
|
4742
|
+
const beaconSubscription = {
|
|
4743
|
+
key: BEACON_PROPERTY,
|
|
4744
|
+
value: SUBSCRIPTION_NAME
|
|
4745
|
+
};
|
|
4746
|
+
//#endregion
|
|
4747
|
+
//#region src/beacon.ts
|
|
4680
4748
|
function Beacon(value, options) {
|
|
4681
4749
|
this[BEACON_SYMBOL] = {
|
|
4682
4750
|
value,
|
|
@@ -4800,7 +4868,7 @@ function isBeacon(value) {
|
|
|
4800
4868
|
return isBeaconInstance(BEACON_NAME, value);
|
|
4801
4869
|
}
|
|
4802
4870
|
function isBeaconInstance(name, value) {
|
|
4803
|
-
return typeof value === "object" && value !== null &&
|
|
4871
|
+
return typeof value === "object" && value !== null && "$beacon" in value && value["$beacon"] === name;
|
|
4804
4872
|
}
|
|
4805
4873
|
/**
|
|
4806
4874
|
* Is the value a beacon subscription?
|
|
@@ -4809,7 +4877,7 @@ function isBeaconInstance(name, value) {
|
|
|
4809
4877
|
* @returns `true` if the value is a beacon subscription, otherwise `false`
|
|
4810
4878
|
*/
|
|
4811
4879
|
function isBeaconSubscription(value) {
|
|
4812
|
-
return isSubscription(value) && value[
|
|
4880
|
+
return isSubscription(value) && value["$beacon"] === "subscription";
|
|
4813
4881
|
}
|
|
4814
4882
|
/**
|
|
4815
4883
|
* Is the value an observable?
|
|
@@ -4835,7 +4903,7 @@ function subscribeToObservable(first, second, third) {
|
|
|
4835
4903
|
function updateBeacon(instance, type, value, finish) {
|
|
4836
4904
|
const state = instance[BEACON_SYMBOL];
|
|
4837
4905
|
if (!state.active) return;
|
|
4838
|
-
if (type ===
|
|
4906
|
+
if (type === "next") {
|
|
4839
4907
|
if (state.options.equal(state.value, value)) return;
|
|
4840
4908
|
state.value = value;
|
|
4841
4909
|
}
|
|
@@ -4843,17 +4911,8 @@ function updateBeacon(instance, type, value, finish) {
|
|
|
4843
4911
|
if (subscriptions != null && subscriptions.size > 0) for (const [, observer] of subscriptions) observer[type]?.(value);
|
|
4844
4912
|
if (finish === true) closeBeacon(state, true);
|
|
4845
4913
|
}
|
|
4846
|
-
const BEACON_MESSAGE_RETRIEVE = "Cannot retrieve observable from a closed beacon";
|
|
4847
|
-
const BEACON_MESSAGE_SUBSCRIBE = "Cannot subscribe to a closed observable";
|
|
4848
|
-
const BEACON_SYMBOL = Symbol(BEACON_PROPERTY);
|
|
4849
|
-
const BEACON_TYPE_ERROR = "error";
|
|
4850
|
-
const BEACON_TYPE_NEXT = "next";
|
|
4851
|
-
const beaconSubscription = {
|
|
4852
|
-
key: BEACON_PROPERTY,
|
|
4853
|
-
value: SUBSCRIPTION_NAME
|
|
4854
|
-
};
|
|
4855
4914
|
//#endregion
|
|
4856
|
-
//#region src/
|
|
4915
|
+
//#region src/models/herald.model.ts
|
|
4857
4916
|
const HERALD_MESSAGE_ARRAY = "Herald requires an array of event names.";
|
|
4858
4917
|
const HERALD_MESSAGE_ONCREATE = `Herald requires a valid onCreate callback for subscription creation`;
|
|
4859
4918
|
const HERALD_MESSAGE_PROPERTY = `Herald requires valid property information for subscription identification`;
|
|
@@ -6266,7 +6325,7 @@ function isNonNullableOrEmpty(value) {
|
|
|
6266
6325
|
* @returns `true` if the value is not `undefined`, `null`, or matches a whitespace-only string, otherwise `false`
|
|
6267
6326
|
*/
|
|
6268
6327
|
function isNonNullableOrWhitespace(value) {
|
|
6269
|
-
return value != null && !
|
|
6328
|
+
return value != null && !EXPRESSION_WHITESPACE_ONLY.test(getString(value));
|
|
6270
6329
|
}
|
|
6271
6330
|
/**
|
|
6272
6331
|
* Is the value not a number or a number-like string?
|
|
@@ -6311,7 +6370,7 @@ function isNullableOrEmpty(value) {
|
|
|
6311
6370
|
* @returns `true` if the value is nullable or matches a whitespace-only string, otherwise `false`
|
|
6312
6371
|
*/
|
|
6313
6372
|
function isNullableOrWhitespace(value) {
|
|
6314
|
-
return value == null ||
|
|
6373
|
+
return value == null || EXPRESSION_WHITESPACE_ONLY.test(getString(value));
|
|
6315
6374
|
}
|
|
6316
6375
|
/**
|
|
6317
6376
|
* Is the value a number or a number-like string?
|
|
@@ -6331,12 +6390,14 @@ function isNumerical(value) {
|
|
|
6331
6390
|
function isObject(value) {
|
|
6332
6391
|
return typeof value === "object" && value !== null || typeof value === "function";
|
|
6333
6392
|
}
|
|
6334
|
-
const EXPRESSION_WHITESPACE = /^\s*$/;
|
|
6335
6393
|
//#endregion
|
|
6336
|
-
//#region src/logger.ts
|
|
6394
|
+
//#region src/models/logger.model.ts
|
|
6337
6395
|
const LOGGER_NAME = "Logger";
|
|
6338
6396
|
const LOGGER_NAME_TIMED = "TimedLogger";
|
|
6339
6397
|
const LOGGER_PROPERTY = "$logger";
|
|
6398
|
+
const LOGGER_SYMBOL = Symbol(LOGGER_PROPERTY);
|
|
6399
|
+
//#endregion
|
|
6400
|
+
//#region src/logger.ts
|
|
6340
6401
|
function Lumberjack() {}
|
|
6341
6402
|
Lumberjack.prototype[LOGGER_PROPERTY] = LOGGER_NAME;
|
|
6342
6403
|
Lumberjack.prototype.time = getTimeLogger;
|
|
@@ -6403,7 +6464,7 @@ function isLogger(value) {
|
|
|
6403
6464
|
return isLoggerInstance(LOGGER_NAME, value);
|
|
6404
6465
|
}
|
|
6405
6466
|
function isLoggerInstance(name, value) {
|
|
6406
|
-
return typeof value === "object" && value !== null &&
|
|
6467
|
+
return typeof value === "object" && value !== null && "$logger" in value && value["$logger"] === name;
|
|
6407
6468
|
}
|
|
6408
6469
|
function isTimeLogger(value) {
|
|
6409
6470
|
return isLoggerInstance(LOGGER_NAME_TIMED, value);
|
|
@@ -6411,7 +6472,6 @@ function isTimeLogger(value) {
|
|
|
6411
6472
|
function setLoggerEnabled(value) {
|
|
6412
6473
|
enabled = typeof value === "boolean" ? value : enabled;
|
|
6413
6474
|
}
|
|
6414
|
-
const LOGGER_SYMBOL = Symbol(LOGGER_PROPERTY);
|
|
6415
6475
|
/**
|
|
6416
6476
|
* A logger that can be used to log messages to the console
|
|
6417
6477
|
*
|
|
@@ -6467,6 +6527,16 @@ function sum(array, key) {
|
|
|
6467
6527
|
return getAggregated("sum", array, key);
|
|
6468
6528
|
}
|
|
6469
6529
|
//#endregion
|
|
6530
|
+
//#region src/models/query.model.ts
|
|
6531
|
+
const QUERY_EXPRESSION_ARRAY_SUFFIX = /\[\]$/;
|
|
6532
|
+
const QUERY_EXPRESSION_BOOLEAN = /^(false|true)$/;
|
|
6533
|
+
const QUERY_TRUE = "true";
|
|
6534
|
+
const QUERY_TYPES = /* @__PURE__ */ new Set([
|
|
6535
|
+
"boolean",
|
|
6536
|
+
"number",
|
|
6537
|
+
"string"
|
|
6538
|
+
]);
|
|
6539
|
+
//#endregion
|
|
6470
6540
|
//#region src/query.ts
|
|
6471
6541
|
/**
|
|
6472
6542
|
* Convert a query string to a plain _(nested)_ object
|
|
@@ -6476,7 +6546,7 @@ function sum(array, key) {
|
|
|
6476
6546
|
*/
|
|
6477
6547
|
function fromQuery(query) {
|
|
6478
6548
|
if (typeof query !== "string" || query.trim().length === 0) return {};
|
|
6479
|
-
const parts = query.split(
|
|
6549
|
+
const parts = query.split("&").map((part) => part.split("=").map(tryDecode)).sort(([first], [second]) => first.localeCompare(second));
|
|
6480
6550
|
const { length } = parts;
|
|
6481
6551
|
const parameters = {};
|
|
6482
6552
|
let position = 0;
|
|
@@ -6506,9 +6576,9 @@ function getParts(value, fromArray, prefix) {
|
|
|
6506
6576
|
for (let index = 0; index < length; index += 1) {
|
|
6507
6577
|
const key = keys[index];
|
|
6508
6578
|
const val = value[key];
|
|
6509
|
-
const fullKey = join([prefix, fromArray ? void 0 : key],
|
|
6579
|
+
const fullKey = join([prefix, fromArray ? void 0 : key], ".");
|
|
6510
6580
|
const encodedKey = getString(tryEncode(fullKey));
|
|
6511
|
-
const prefixedKey = fromArray ? join([encodedKey, index],
|
|
6581
|
+
const prefixedKey = fromArray ? join([encodedKey, index], ".") : encodedKey;
|
|
6512
6582
|
if (Array.isArray(val)) parts.push(...getParts(val, true, fullKey));
|
|
6513
6583
|
else if (isPlainObject(val)) parts.push(...getParts(val, false, fullKey));
|
|
6514
6584
|
else if (isDecodable(val)) parts.push(`${prefixedKey}=${getString(tryEncode(val))}`);
|
|
@@ -6535,24 +6605,10 @@ function isDecodable(value) {
|
|
|
6535
6605
|
* @returns Query string representation of the object
|
|
6536
6606
|
*/
|
|
6537
6607
|
function toQuery(parameters) {
|
|
6538
|
-
return isPlainObject(parameters) ? join(getParts(parameters, false).filter((part) => part.length > 0),
|
|
6608
|
+
return isPlainObject(parameters) ? join(getParts(parameters, false).filter((part) => part.length > 0), "&") : "";
|
|
6539
6609
|
}
|
|
6540
|
-
const QUERY_AMPERSAND = "&";
|
|
6541
|
-
const QUERY_DOT = ".";
|
|
6542
|
-
const QUERY_EQUAL = "=";
|
|
6543
|
-
const QUERY_EXPRESSION_ARRAY_SUFFIX = /\[\]$/;
|
|
6544
|
-
const QUERY_EXPRESSION_BOOLEAN = /^(false|true)$/;
|
|
6545
|
-
const QUERY_TRUE = "true";
|
|
6546
|
-
const QUERY_TYPES = /* @__PURE__ */ new Set([
|
|
6547
|
-
"boolean",
|
|
6548
|
-
"number",
|
|
6549
|
-
"string"
|
|
6550
|
-
]);
|
|
6551
6610
|
//#endregion
|
|
6552
|
-
//#region src/queue.ts
|
|
6553
|
-
const QUEUE_NAME_KEYED = "keyedQueue";
|
|
6554
|
-
const QUEUE_NAME_QUEUE = "queue";
|
|
6555
|
-
const QUEUE_PROPERTY = "$queue";
|
|
6611
|
+
//#region src/models/queue.model.ts
|
|
6556
6612
|
/**
|
|
6557
6613
|
* An error thrown by the Queue when an operation fails
|
|
6558
6614
|
*/
|
|
@@ -6562,6 +6618,25 @@ var QueueError = class extends Error {
|
|
|
6562
6618
|
this.name = QUEUE_ERROR_NAME;
|
|
6563
6619
|
}
|
|
6564
6620
|
};
|
|
6621
|
+
const QUEUE_ERROR_NAME = "QueueError";
|
|
6622
|
+
const QUEUE_HANDLE_CLEAR = "clear";
|
|
6623
|
+
const QUEUE_HANDLE_PAUSE = "pause";
|
|
6624
|
+
const QUEUE_HANDLE_RESUME = "resume";
|
|
6625
|
+
const QUEUE_MESSAGE_CALLBACK = "A Queue requires a callback function";
|
|
6626
|
+
const QUEUE_MESSAGE_CLEAR = "Queue was cleared";
|
|
6627
|
+
const QUEUE_MESSAGE_KEY = "Key must be a non-empty string";
|
|
6628
|
+
const QUEUE_MESSAGE_MAXIMUM = "Queue has reached its maximum size";
|
|
6629
|
+
const QUEUE_MESSAGE_REMOVE = "Item removed from queue";
|
|
6630
|
+
const QUEUE_NAME_KEYED = "keyedQueue";
|
|
6631
|
+
const QUEUE_NAME_QUEUE = "queue";
|
|
6632
|
+
const QUEUE_PROPERTY = "$queue";
|
|
6633
|
+
const QUEUE_STATUS_ACTIVE = "active";
|
|
6634
|
+
const QUEUE_STATUS_EMPTY = "empty";
|
|
6635
|
+
const QUEUE_STATUS_FULL = "full";
|
|
6636
|
+
const QUEUE_STATUS_PAUSED = "paused";
|
|
6637
|
+
const QUEUE_SYMBOL = Symbol(QUEUE_PROPERTY);
|
|
6638
|
+
//#endregion
|
|
6639
|
+
//#region src/queue.ts
|
|
6565
6640
|
function KeyedQueue(callback, options) {
|
|
6566
6641
|
this[QUEUE_SYMBOL] = {
|
|
6567
6642
|
callback,
|
|
@@ -6705,9 +6780,9 @@ function clearQueue() {
|
|
|
6705
6780
|
const items = this[QUEUE_SYMBOL].items.splice(0);
|
|
6706
6781
|
const { length } = items;
|
|
6707
6782
|
for (let index = 0; index < length; index += 1) {
|
|
6708
|
-
const
|
|
6709
|
-
aborter?.cancel();
|
|
6710
|
-
reject(new QueueError(QUEUE_MESSAGE_CLEAR));
|
|
6783
|
+
const item = items[index];
|
|
6784
|
+
item.aborter?.cancel();
|
|
6785
|
+
item.reject(new QueueError(QUEUE_MESSAGE_CLEAR));
|
|
6711
6786
|
}
|
|
6712
6787
|
}
|
|
6713
6788
|
function clearQueues(key) {
|
|
@@ -6834,7 +6909,7 @@ function isQueue(value) {
|
|
|
6834
6909
|
return isQueueInstance(QUEUE_NAME_QUEUE, value);
|
|
6835
6910
|
}
|
|
6836
6911
|
function isQueueInstance(name, value) {
|
|
6837
|
-
return typeof value === "object" && value != null &&
|
|
6912
|
+
return typeof value === "object" && value != null && "$queue" in value && value["$queue"] === name;
|
|
6838
6913
|
}
|
|
6839
6914
|
function keyedQueue(callback, options) {
|
|
6840
6915
|
if (typeof callback !== "function") throw new TypeError(QUEUE_MESSAGE_CALLBACK);
|
|
@@ -6869,9 +6944,9 @@ function removeQueued(id) {
|
|
|
6869
6944
|
const state = this[QUEUE_SYMBOL];
|
|
6870
6945
|
const index = state.items.findIndex((item) => item.id === id);
|
|
6871
6946
|
if (index > -1) {
|
|
6872
|
-
const
|
|
6873
|
-
aborter?.cancel();
|
|
6874
|
-
reject(new QueueError(QUEUE_MESSAGE_REMOVE));
|
|
6947
|
+
const item = state.items.splice(index, 1)[0];
|
|
6948
|
+
item.aborter?.cancel();
|
|
6949
|
+
item.reject(new QueueError(QUEUE_MESSAGE_REMOVE));
|
|
6875
6950
|
}
|
|
6876
6951
|
}
|
|
6877
6952
|
function resumeQueue() {
|
|
@@ -6917,22 +6992,13 @@ async function run$1(state) {
|
|
|
6917
6992
|
}
|
|
6918
6993
|
state.runners -= 1;
|
|
6919
6994
|
}
|
|
6920
|
-
const QUEUE_ERROR_NAME = "QueueError";
|
|
6921
|
-
const QUEUE_HANDLE_CLEAR = "clear";
|
|
6922
|
-
const QUEUE_HANDLE_PAUSE = "pause";
|
|
6923
|
-
const QUEUE_HANDLE_RESUME = "resume";
|
|
6924
|
-
const QUEUE_MESSAGE_CALLBACK = "A Queue requires a callback function";
|
|
6925
|
-
const QUEUE_MESSAGE_CLEAR = "Queue was cleared";
|
|
6926
|
-
const QUEUE_MESSAGE_KEY = "Key must be a non-empty string";
|
|
6927
|
-
const QUEUE_MESSAGE_MAXIMUM = "Queue has reached its maximum size";
|
|
6928
|
-
const QUEUE_MESSAGE_REMOVE = "Item removed from queue";
|
|
6929
|
-
const QUEUE_STATUS_ACTIVE = "active";
|
|
6930
|
-
const QUEUE_STATUS_EMPTY = "empty";
|
|
6931
|
-
const QUEUE_STATUS_FULL = "full";
|
|
6932
|
-
const QUEUE_STATUS_PAUSED = "paused";
|
|
6933
|
-
const QUEUE_SYMBOL = Symbol(QUEUE_PROPERTY);
|
|
6934
6995
|
queue.keyed = keyedQueue;
|
|
6935
6996
|
//#endregion
|
|
6997
|
+
//#region src/models/random.model.ts
|
|
6998
|
+
const RANDOM_ALPHABET = "abcdefghijklmnopqrstuvwxyz";
|
|
6999
|
+
const RANDOM_BOOLEAN_MODIFIER = .5;
|
|
7000
|
+
const RANDOM_HEX_CHARACTERS = "0123456789ABCDEF";
|
|
7001
|
+
//#endregion
|
|
6936
7002
|
//#region src/random.ts
|
|
6937
7003
|
/**
|
|
6938
7004
|
* Get a random boolean
|
|
@@ -6971,7 +7037,7 @@ function getRandomColor(prefix) {
|
|
|
6971
7037
|
* @returns Random hexadecimal character from `0-9` and `A-F`
|
|
6972
7038
|
*/
|
|
6973
7039
|
function getRandomHex() {
|
|
6974
|
-
return RANDOM_HEX_CHARACTERS[getRandomInteger(0,
|
|
7040
|
+
return RANDOM_HEX_CHARACTERS[getRandomInteger(0, 15)];
|
|
6975
7041
|
}
|
|
6976
7042
|
/**
|
|
6977
7043
|
* Get a random item from an array
|
|
@@ -6989,10 +7055,6 @@ function getRandomItems(array, amount) {
|
|
|
6989
7055
|
if (amount === 1) return [array[getRandomInteger(0, array.length - 1)]];
|
|
6990
7056
|
return typeof amount !== "number" || amount <= 0 || amount >= array.length ? shuffle(array) : shuffle(array).slice(0, amount);
|
|
6991
7057
|
}
|
|
6992
|
-
const RANDOM_ALPHABET = "abcdefghijklmnopqrstuvwxyz";
|
|
6993
|
-
const RANDOM_BOOLEAN_MODIFIER = .5;
|
|
6994
|
-
const RANDOM_HEX_CHARACTERS = "0123456789ABCDEF";
|
|
6995
|
-
const RANDOM_HEX_MAXIMUM = 15;
|
|
6996
7058
|
//#endregion
|
|
6997
7059
|
//#region src/sized/set.ts
|
|
6998
7060
|
/**
|
|
@@ -7049,4 +7111,4 @@ var SizedSet = class extends Set {
|
|
|
7049
7111
|
}
|
|
7050
7112
|
};
|
|
7051
7113
|
//#endregion
|
|
7052
|
-
export { CancelablePromise, Logger, PromiseTimeoutError,
|
|
7114
|
+
export { CancelablePromise, Logger, PromiseTimeoutError, RetryError, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SizedMap, SizedSet, push as append, push, assert, assertCondition, assertDefined, assertInstanceOf, assertIs, assertProperty, assign, asyncAttempt, asyncAttemptRun, asyncDebounce, asyncFlow, asyncMatchResult, asyncOnce, asyncPipe, asyncRun, asyncThrottle, attempt, attemptAsyncFlow, attemptAsyncPipe, attemptFlow, attemptPipe, attemptPromise, attemptRun, attemptRunAsyncPlan, attemptRunPlan, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, copy, count, debounce, deburr, dedent, delay, deregisterCloner, deregisterComparator, deregisterEqualizer, diff, difference, drop, endsWith, endsWithArray, equal, error, exclude, exists, fail, filter, filterAndMap, filterAndMap as select, find, findLast, first, firstOrDefault, flatFreeze, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getSortedIndex, getString, getTimedPromise, getUuid, getValue, groupArraysBy, groupBy, handleResult, hasValue, hasValueResult, herald, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, ignoreKey, inMap, inSet, includes, includesArray, indexOf, indexOfArray, initializeAssigner, initializeCloner, initializeEqualizer, initializeMerger, initializeNormalizer, initializeSorter, initializeTemplater, initializeTransformer, insert, interpolate, intersection, isArrayOrPlainObject, isAsyncGenerator, isAsyncOnce, isAsyncPlan, isBeacon, isBeaconSubscription, isColor, isConstructor, isEmpty, isError, isFrozen, isFulfilled, isFuzzy, isGenerator, isHerald, isHeraldEvents, isHeraldSubscription, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isInstanceOf, isKey, isKeyedQueue, isLogger, isNonArrayOrPlainObject, isNonConstructor, isNonEmpty, isNonInstanceOf, isNonKey, isNonNullable, isNonNullableOrEmpty, isNonNullableOrWhitespace, isNonNumber, isNonNumerical, isNonObject, isNonPlainObject, isNonPrimitive, isNonTemplateStringsArray, isNonTypedArray, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isObservable, isOk, isOnce, isPlainObject, isPlan, isPrimitive, isQueue, isQueueInstance, isRejected, isResult, isRgbColor, isRgbaColor, isSorted, isSubscription, isSubscriptions, isTemplateStringsArray, isTimeLogger, isTypedArray, join, kebabCase, keyedQueue, last, lastIndexOf, lastOrDefault, lowerCase, mapAndFilter, mapAndFilter as reverseSelect, matchResult, max, median, memoize, merge, min, move, moveIndices, moveToIndex, noop, normalize, ok, omit, once, parse, partition, pascalCase, pick, pipe, plan, promises, queue, range, registerCloner, registerComparator, registerEqualizer, resultPromises, retry, reverse, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba, round, run, runAsyncPlan, runPlan, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, subscriptions, succeed, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toResult, toSet, toggle, transform, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };
|