@oscarpalmer/atoms 0.221.0 → 0.223.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 -3
- package/dist/array/difference.mjs +2 -3
- package/dist/array/exists.d.mts +1 -3
- package/dist/array/exists.mjs +11 -6
- package/dist/array/filter.d.mts +1 -3
- package/dist/array/filter.mjs +15 -6
- package/dist/array/find.d.mts +1 -3
- package/dist/array/find.mjs +9 -5
- package/dist/array/first.d.mts +1 -3
- package/dist/array/first.mjs +10 -5
- package/dist/array/flatten.d.mts +1 -3
- package/dist/array/flatten.mjs +1 -2
- package/dist/array/from.d.mts +1 -3
- package/dist/array/from.mjs +1 -2
- package/dist/array/group-by.d.mts +1 -3
- package/dist/array/group-by.mjs +1 -2
- package/dist/array/index.d.mts +4 -4
- package/dist/array/insert.d.mts +1 -3
- package/dist/array/insert.mjs +2 -3
- package/dist/array/intersection.d.mts +1 -3
- package/dist/array/intersection.mjs +2 -3
- package/dist/array/last.d.mts +1 -3
- package/dist/array/last.mjs +12 -5
- package/dist/array/move.d.mts +1 -3
- package/dist/array/move.mjs +1 -2
- package/dist/array/partition.d.mts +1 -3
- package/dist/array/partition.mjs +24 -5
- package/dist/array/push.d.mts +0 -2
- package/dist/array/push.mjs +2 -3
- package/dist/array/reverse.d.mts +1 -3
- package/dist/array/reverse.mjs +1 -2
- package/dist/array/select.d.mts +0 -2
- package/dist/array/select.mjs +40 -9
- package/dist/array/single.d.mts +1 -3
- package/dist/array/single.mjs +9 -7
- package/dist/array/slice.d.mts +1 -3
- package/dist/array/slice.mjs +1 -2
- package/dist/array/sort.d.mts +0 -2
- package/dist/array/sort.mjs +2 -3
- package/dist/array/splice.d.mts +1 -3
- package/dist/array/splice.mjs +2 -3
- package/dist/array/swap.d.mts +0 -2
- package/dist/array/swap.mjs +2 -3
- package/dist/array/to-map.d.mts +1 -3
- package/dist/array/to-map.mjs +1 -2
- package/dist/array/to-record.d.mts +1 -3
- package/dist/array/to-record.mjs +1 -2
- package/dist/array/to-set.d.mts +1 -3
- package/dist/array/to-set.mjs +1 -2
- package/dist/array/toggle.d.mts +1 -3
- package/dist/array/toggle.mjs +1 -2
- package/dist/array/union.d.mts +1 -3
- package/dist/array/union.mjs +2 -3
- package/dist/array/unique.d.mts +1 -3
- package/dist/array/unique.mjs +18 -5
- package/dist/array/update.d.mts +1 -3
- package/dist/array/update.mjs +1 -2
- package/dist/beacon.d.mts +3 -13
- package/dist/beacon.mjs +10 -21
- package/dist/color/constants.d.mts +1 -7
- package/dist/color/constants.mjs +3 -11
- package/dist/color/index.d.mts +0 -2
- package/dist/color/index.mjs +4 -5
- package/dist/color/instance.d.mts +1 -3
- package/dist/color/instance.mjs +5 -8
- package/dist/color/misc/alpha.d.mts +1 -3
- package/dist/color/misc/alpha.mjs +1 -2
- package/dist/color/misc/format.d.mts +1 -3
- package/dist/color/misc/format.mjs +1 -2
- package/dist/color/misc/get.d.mts +1 -3
- package/dist/color/misc/get.mjs +2 -3
- package/dist/color/misc/is.d.mts +1 -11
- package/dist/color/misc/is.mjs +4 -16
- package/dist/color/misc/state.d.mts +1 -3
- package/dist/color/misc/state.mjs +4 -5
- package/dist/color/space/hex.d.mts +1 -3
- package/dist/color/space/hex.mjs +2 -3
- package/dist/color/space/hsl.d.mts +1 -3
- package/dist/color/space/hsl.mjs +2 -3
- package/dist/color/space/hwb.d.mts +1 -3
- package/dist/color/space/hwb.mjs +3 -4
- package/dist/color/space/rgb.d.mts +1 -3
- package/dist/color/space/rgb.mjs +1 -2
- package/dist/function/limit.d.mts +1 -3
- package/dist/function/limit.mjs +2 -3
- package/dist/function/once.d.mts +1 -3
- package/dist/function/once.mjs +8 -9
- package/dist/function/retry.d.mts +1 -3
- package/dist/function/retry.mjs +11 -12
- package/dist/herald.d.mts +2 -2
- package/dist/herald.mjs +1 -1
- package/dist/index.d.mts +81 -359
- package/dist/index.mjs +514 -661
- package/dist/internal/aborter.d.mts +1 -3
- package/dist/internal/aborter.mjs +1 -2
- package/dist/internal/array/callbacks.d.mts +2 -4
- package/dist/internal/array/callbacks.mjs +1 -2
- package/dist/internal/array/chunk.d.mts +1 -3
- package/dist/internal/array/chunk.mjs +1 -2
- package/dist/internal/array/compact.d.mts +1 -3
- package/dist/internal/array/compact.mjs +1 -2
- package/dist/internal/array/find.d.mts +2 -8
- package/dist/internal/array/find.mjs +31 -124
- package/dist/internal/array/get.d.mts +1 -3
- package/dist/internal/array/get.mjs +1 -2
- package/dist/internal/array/group.d.mts +1 -3
- package/dist/internal/array/group.mjs +1 -2
- package/dist/internal/array/index-of.d.mts +1 -3
- package/dist/internal/array/index-of.mjs +10 -5
- package/dist/internal/array/insert.d.mts +1 -3
- package/dist/internal/array/insert.mjs +2 -3
- package/dist/internal/array/match.d.mts +2 -4
- package/dist/internal/array/match.mjs +2 -3
- package/dist/internal/array/overlap.d.mts +1 -3
- package/dist/internal/array/overlap.mjs +1 -2
- package/dist/internal/array/sets.d.mts +1 -3
- package/dist/internal/array/sets.mjs +5 -6
- package/dist/internal/array/shuffle.d.mts +1 -3
- package/dist/internal/array/shuffle.mjs +1 -2
- package/dist/internal/array/update.d.mts +1 -3
- package/dist/internal/array/update.mjs +1 -2
- package/dist/internal/defaults.d.mts +1 -3
- package/dist/internal/defaults.mjs +1 -2
- package/dist/internal/function/assert.d.mts +1 -3
- package/dist/internal/function/assert.mjs +1 -2
- package/dist/internal/function/limit.d.mts +2 -4
- package/dist/internal/function/limit.mjs +8 -9
- package/dist/internal/function/memoize.d.mts +1 -3
- package/dist/internal/function/memoize.mjs +4 -5
- package/dist/internal/function/misc.d.mts +1 -2
- package/dist/internal/function/misc.mjs +7 -3
- package/dist/internal/function/work.d.mts +1 -3
- package/dist/internal/function/work.mjs +5 -13
- package/dist/internal/herald.d.mts +2 -12
- package/dist/internal/herald.mjs +9 -33
- package/dist/internal/is.d.mts +1 -3
- package/dist/internal/is.mjs +1 -2
- package/dist/internal/math/aggregate.d.mts +1 -3
- package/dist/internal/math/aggregate.mjs +2 -3
- package/dist/internal/math/misc.d.mts +1 -3
- package/dist/internal/math/misc.mjs +1 -2
- package/dist/internal/number.d.mts +1 -3
- package/dist/internal/number.mjs +2 -3
- package/dist/internal/plan/index.d.mts +1 -3
- package/dist/internal/plan/index.mjs +2 -3
- package/dist/internal/plan/plan.generate.d.mts +1 -3
- package/dist/internal/plan/plan.generate.mjs +67 -22
- package/dist/internal/random.d.mts +1 -3
- package/dist/internal/random.mjs +1 -2
- package/dist/internal/result/attempt.d.mts +1 -3
- package/dist/internal/result/attempt.mjs +1 -2
- package/dist/internal/result/misc.d.mts +1 -3
- package/dist/internal/result/misc.mjs +1 -2
- package/dist/internal/sized/map.d.mts +4 -3
- package/dist/internal/sized/map.mjs +4 -2
- package/dist/internal/sized/misc.d.mts +1 -3
- package/dist/internal/sized/misc.mjs +1 -2
- package/dist/internal/string/case.d.mts +1 -3
- package/dist/internal/string/case.mjs +3 -4
- package/dist/internal/string/misc.d.mts +1 -3
- package/dist/internal/string/misc.mjs +1 -2
- package/dist/internal/subscription.d.mts +1 -3
- package/dist/internal/subscription.mjs +16 -29
- package/dist/internal/value/compare.d.mts +1 -3
- package/dist/internal/value/compare.mjs +2 -3
- package/dist/internal/value/equal.d.mts +1 -3
- package/dist/internal/value/equal.mjs +3 -4
- package/dist/internal/value/get.d.mts +1 -3
- package/dist/internal/value/get.mjs +1 -2
- package/dist/internal/value/handlers.d.mts +1 -3
- package/dist/internal/value/handlers.mjs +1 -2
- package/dist/internal/value/has.d.mts +1 -3
- package/dist/internal/value/has.mjs +1 -2
- package/dist/internal/value/misc.d.mts +1 -3
- package/dist/internal/value/misc.mjs +2 -3
- package/dist/internal/value/partial.d.mts +1 -3
- package/dist/internal/value/partial.mjs +1 -2
- package/dist/internal/value/set.d.mts +1 -3
- package/dist/internal/value/set.mjs +2 -3
- package/dist/is.d.mts +0 -2
- package/dist/is.mjs +2 -3
- package/dist/logger.d.mts +0 -2
- package/dist/logger.mjs +7 -7
- package/dist/math.d.mts +0 -2
- package/dist/math.mjs +2 -3
- package/dist/models/aborter.model.d.mts +1 -3
- package/dist/models/aborter.model.mjs +1 -2
- package/dist/models/array/array.match.model.d.mts +1 -3
- package/dist/models/array/array.match.model.mjs +1 -2
- package/dist/models/array/array.misc.model.d.mts +11 -2
- package/dist/models/array/array.misc.model.mjs +3 -3
- package/dist/models/array/array.sort.model.d.mts +1 -3
- package/dist/models/array/array.sort.model.mjs +1 -2
- package/dist/models/beacon.model.d.mts +4 -6
- package/dist/models/beacon.model.mjs +3 -10
- package/dist/models/color.model.d.mts +2 -4
- package/dist/models/function/assert.model.d.mts +1 -3
- package/dist/models/function/assert.model.mjs +1 -2
- package/dist/models/function/limiter.model.d.mts +2 -4
- package/dist/models/function/limiter.model.mjs +2 -4
- package/dist/models/function/memoize.model.d.mts +2 -4
- package/dist/models/function/memoize.model.mjs +1 -2
- package/dist/models/function/once.model.d.mts +0 -3
- package/dist/models/function/once.model.mjs +3 -5
- package/dist/models/function/retry.model.d.mts +1 -3
- package/dist/models/function/retry.model.mjs +1 -2
- package/dist/models/function/work.model.d.mts +2 -4
- package/dist/models/function/work.model.mjs +1 -2
- package/dist/models/herald.model.d.mts +8 -7
- package/dist/models/herald.model.mjs +3 -10
- package/dist/models/index.d.mts +0 -2
- package/dist/models/logger.model.d.mts +1 -4
- package/dist/models/logger.model.mjs +3 -5
- package/dist/models/math.model.d.mts +1 -3
- package/dist/models/math.model.mjs +1 -2
- package/dist/models/misc.model.d.mts +1 -3
- package/dist/models/misc.model.mjs +1 -2
- package/dist/models/plan.model.d.mts +35 -37
- package/dist/models/plan.model.mjs +1 -2
- package/dist/models/promise.model.d.mts +8 -10
- package/dist/models/promise.model.mjs +4 -5
- package/dist/models/query.model.d.mts +1 -3
- package/dist/models/query.model.mjs +1 -2
- package/dist/models/queue.model.d.mts +0 -3
- package/dist/models/queue.model.mjs +3 -5
- package/dist/models/random.model.d.mts +1 -3
- package/dist/models/random.model.mjs +1 -2
- package/dist/models/result.model.d.mts +0 -2
- package/dist/models/string/string.case.model.d.mts +1 -3
- package/dist/models/string/string.case.model.mjs +1 -2
- package/dist/models/string/string.fuzzy.model.d.mts +0 -3
- package/dist/models/string/string.fuzzy.model.mjs +3 -5
- package/dist/models/string/string.misc.model.d.mts +1 -3
- package/dist/models/string/string.misc.model.mjs +1 -2
- package/dist/models/string/string.normalize.model.d.mts +1 -3
- package/dist/models/string/string.normalize.model.mjs +1 -2
- package/dist/models/string/string.template.model.d.mts +1 -3
- package/dist/models/string/string.template.model.mjs +1 -2
- package/dist/models/subscription.model.d.mts +4 -23
- package/dist/models/subscription.model.mjs +3 -5
- package/dist/models/value/value.clone.model.d.mts +1 -3
- package/dist/models/value/value.clone.model.mjs +1 -2
- package/dist/models/value/value.diff.model.d.mts +1 -3
- package/dist/models/value/value.diff.model.mjs +1 -2
- package/dist/models/value/value.equal.model.d.mts +0 -2
- package/dist/models/value/value.equal.model.mjs +1 -2
- package/dist/models/value/value.handler.model.d.mts +1 -3
- package/dist/models/value/value.merge.model.d.mts +0 -2
- package/dist/models/value/value.merge.model.mjs +1 -2
- package/dist/models/value/value.misc.model.d.mts +0 -2
- package/dist/models/value/value.misc.model.mjs +1 -2
- package/dist/models/value/value.transform.model.d.mts +1 -3
- package/dist/models/value/value.transform.model.mjs +1 -2
- package/dist/plan/index.d.mts +1 -3
- package/dist/plan/index.mjs +2 -3
- package/dist/plan/is.d.mts +1 -3
- package/dist/plan/is.mjs +1 -2
- package/dist/plan/misc.d.mts +1 -3
- package/dist/plan/misc.mjs +2 -3
- package/dist/plan/models.d.mts +2 -2
- package/dist/plan/result.d.mts +8 -10
- package/dist/plan/result.mjs +2 -3
- package/dist/plan/run.d.mts +8 -10
- package/dist/plan/run.mjs +2 -3
- package/dist/plan/use.d.mts +1 -3
- package/dist/plan/use.mjs +14 -9
- package/dist/promise/delay.d.mts +1 -3
- package/dist/promise/delay.mjs +2 -3
- package/dist/promise/helpers.d.mts +1 -3
- package/dist/promise/helpers.mjs +2 -3
- package/dist/promise/index.d.mts +0 -2
- package/dist/promise/index.mjs +5 -6
- package/dist/promise/misc.d.mts +1 -3
- package/dist/promise/misc.mjs +2 -3
- package/dist/promise/models.d.mts +2 -2
- package/dist/promise/models.mjs +1 -1
- package/dist/promise/timed.d.mts +1 -3
- package/dist/promise/timed.mjs +4 -5
- package/dist/query.d.mts +1 -3
- package/dist/query.mjs +2 -3
- package/dist/queue.d.mts +0 -2
- package/dist/queue.mjs +11 -12
- package/dist/random.d.mts +0 -2
- package/dist/random.mjs +2 -3
- package/dist/result/match.d.mts +1 -3
- package/dist/result/match.mjs +1 -2
- package/dist/result/misc.d.mts +0 -2
- package/dist/result/misc.mjs +1 -2
- package/dist/result/work/flow.d.mts +1 -3
- package/dist/result/work/flow.mjs +5 -12
- package/dist/result/work/pipe.d.mts +0 -2
- package/dist/result/work/pipe.mjs +2 -3
- package/dist/sized/set.d.mts +4 -3
- package/dist/sized/set.mjs +4 -2
- package/dist/string/fuzzy.d.mts +0 -2
- package/dist/string/fuzzy.mjs +5 -7
- package/dist/string/index.d.mts +0 -2
- package/dist/string/index.mjs +2 -3
- package/dist/string/match.d.mts +1 -3
- package/dist/string/match.mjs +2 -3
- package/dist/string/normalize.d.mts +0 -2
- package/dist/string/normalize.mjs +3 -4
- package/dist/string/template.d.mts +0 -2
- package/dist/string/template.mjs +1 -2
- package/dist/subscription.d.mts +2 -2
- package/dist/value/clone.d.mts +1 -3
- package/dist/value/clone.mjs +2 -3
- package/dist/value/collection.d.mts +1 -3
- package/dist/value/collection.mjs +1 -2
- package/dist/value/diff.d.mts +0 -2
- package/dist/value/diff.mjs +1 -2
- package/dist/value/freeze.d.mts +1 -3
- package/dist/value/freeze.mjs +1 -2
- package/dist/value/handle.mjs +1 -1
- package/dist/value/merge.d.mts +0 -2
- package/dist/value/merge.mjs +1 -2
- package/dist/value/omit.d.mts +1 -3
- package/dist/value/omit.mjs +1 -2
- package/dist/value/pick.d.mts +1 -3
- package/dist/value/pick.mjs +1 -2
- package/dist/value/shake.d.mts +0 -2
- package/dist/value/shake.mjs +1 -2
- package/dist/value/smush.d.mts +0 -2
- package/dist/value/smush.mjs +2 -3
- package/dist/value/transform.d.mts +0 -2
- package/dist/value/transform.mjs +1 -2
- package/dist/value/unsmush.d.mts +0 -2
- package/dist/value/unsmush.mjs +1 -2
- package/package.json +6 -6
- package/dist/models/array/array.find.model.d.mts +0 -48
- package/dist/models/array/array.find.model.mjs +0 -8
package/dist/index.mjs
CHANGED
|
@@ -1,182 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const ARRAY_FIND_VALUES_UNIQUE = "unique";
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/internal/array/callbacks.ts
|
|
7
|
-
function getArrayCallback(value) {
|
|
8
|
-
switch (typeof value) {
|
|
9
|
-
case "function": return value;
|
|
10
|
-
case "number":
|
|
11
|
-
case "string": return (obj) => obj?.[value];
|
|
12
|
-
default: return;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function getArrayCallbacks(bool, key, value) {
|
|
16
|
-
if (typeof bool === "function") return { bool };
|
|
17
|
-
return {
|
|
18
|
-
keyed: getArrayCallback(key),
|
|
19
|
-
value: getArrayCallback(value)
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/internal/array/find.ts
|
|
24
|
-
function addResult(result, mapped, flat) {
|
|
25
|
-
if (!flat) {
|
|
26
|
-
result.matched.push(mapped);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const array = Array.isArray(mapped) ? mapped : [mapped];
|
|
30
|
-
const { length } = array;
|
|
31
|
-
for (let index = 0; index < length; index += 1) result.matched.push(array[index]);
|
|
32
|
-
}
|
|
33
|
-
function createFindParameters(original) {
|
|
34
|
-
const { length } = original;
|
|
35
|
-
return {
|
|
36
|
-
bool: length === 1 && typeof original[0] === "function" ? original[0] : void 0,
|
|
37
|
-
key: length === 2 ? original[0] : void 0,
|
|
38
|
-
value: length === 1 && typeof original[0] !== "function" ? original[0] : original[1]
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function findAbsoluteValueOrDefault(array, parameters, defaultValue, useDefaultValue, reversed) {
|
|
42
|
-
if (parameters.length === 0) {
|
|
43
|
-
if (Array.isArray(array) && array.length > 0) return reversed ? array.at(-1) : array[0];
|
|
44
|
-
return useDefaultValue ? defaultValue : void 0;
|
|
45
|
-
}
|
|
46
|
-
const index = findValue(ARRAY_FIND_VALUE_INDEX, array, parameters, reversed);
|
|
47
|
-
if (index === -1) return useDefaultValue ? defaultValue : void 0;
|
|
48
|
-
return array[index];
|
|
1
|
+
// src/array/filter.ts
|
|
2
|
+
function exclude(array, ...parameters) {
|
|
3
|
+
return filterValues(array, parameters, false);
|
|
49
4
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
const keys = /* @__PURE__ */ new Set();
|
|
53
|
-
for (let arrayIndex = 0; arrayIndex < arrayLength; arrayIndex += 1) {
|
|
54
|
-
const arrayItem = array[arrayIndex];
|
|
55
|
-
const keyed = callback == null ? arrayItem : callback(arrayItem, arrayIndex, array);
|
|
56
|
-
const mapped = arrayItem;
|
|
57
|
-
if (type === "all" && Object.is(keyed, value) || type === "unique" && !keys.has(keyed)) {
|
|
58
|
-
keys.add(keyed);
|
|
59
|
-
result.matched.push(mapped);
|
|
60
|
-
if (result.matched.length >= limit) return result;
|
|
61
|
-
} else result.notMatched.push(arrayItem);
|
|
62
|
-
}
|
|
63
|
-
return result;
|
|
5
|
+
function filter(array, ...parameters) {
|
|
6
|
+
return filterValues(array, parameters, true);
|
|
64
7
|
}
|
|
65
|
-
function
|
|
66
|
-
if (
|
|
67
|
-
|
|
8
|
+
function filterValues(array, parameters, include) {
|
|
9
|
+
if (!Array.isArray(array)) return [];
|
|
10
|
+
if (array.length === 0) return [];
|
|
11
|
+
const [first, second] = parameters;
|
|
12
|
+
const { length } = parameters;
|
|
13
|
+
if (length === 1) return typeof first === "function" ? array.filter((item, index, array) => first(item, index, array) === include) : array.filter((item) => Object.is(item, first) === include);
|
|
14
|
+
let callback;
|
|
15
|
+
if (typeof first === "function") callback = first;
|
|
16
|
+
else if (typeof first === "number" || typeof first === "string") callback = (item) => item[first];
|
|
17
|
+
if (callback == null) return [];
|
|
18
|
+
return array.filter((item, index, array) => Object.is(callback(item, index, array), second) === include);
|
|
68
19
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
for (let
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
addResult(result, mapped, flat);
|
|
80
|
-
if (result.matched.length >= limit) return result;
|
|
81
|
-
} else result.notMatched.push(arrayItem);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
const flatItems = Array.isArray(mapped) ? mapped : [mapped];
|
|
85
|
-
const flatLength = flatItems.length;
|
|
86
|
-
for (let flatIndex = 0; flatIndex < flatLength; flatIndex += 1) {
|
|
87
|
-
const flatItem = flatItems[flatIndex];
|
|
88
|
-
if (handler(flatItem, arrayIndex, array)) result.matched.push(flatItem);
|
|
89
|
-
else result.notMatched.push(flatItem);
|
|
90
|
-
}
|
|
20
|
+
filter.remove = exclude;
|
|
21
|
+
// src/internal/array/find.ts
|
|
22
|
+
function findComplexValues(array, length, parameters, callback) {
|
|
23
|
+
let result;
|
|
24
|
+
for (let index = 0; index < length; index += 1) {
|
|
25
|
+
const item = array[parameters.reverse ? length - 1 - index : index];
|
|
26
|
+
if (!callback(item, index, array)) continue;
|
|
27
|
+
result ??= { values: [] };
|
|
28
|
+
result.values.push(parameters.indiced ? index : item);
|
|
29
|
+
if (parameters.limit == null || result.values.length === parameters.limit) return result;
|
|
91
30
|
}
|
|
92
31
|
return result;
|
|
93
32
|
}
|
|
94
|
-
function
|
|
95
|
-
|
|
96
|
-
if (!Array.isArray(array) || array.length === 0) return findIndex ? -1 : void 0;
|
|
97
|
-
const { bool, key, value } = createFindParameters(parameters);
|
|
98
|
-
const callbacks = getArrayCallbacks(bool, key);
|
|
99
|
-
if (callbacks?.bool == null && callbacks?.keyed == null) return findSimpleValue(array, value, findIndex, reversed);
|
|
100
|
-
if (callbacks.bool != null) {
|
|
101
|
-
const index = reversed ? array.findLastIndex(callbacks.bool) : array.findIndex(callbacks.bool);
|
|
102
|
-
return findIndex ? index : array[index];
|
|
103
|
-
}
|
|
104
|
-
return findValueInArray(array, callbacks.keyed, value, findIndex, reversed);
|
|
33
|
+
function findBareValue(array, reverse) {
|
|
34
|
+
return { values: [array[reverse ? array.length - 1 : 0]] };
|
|
105
35
|
}
|
|
106
|
-
function
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (Object.is(callback?.(item, index, array), value)) return findIndex ? index : item;
|
|
111
|
-
}
|
|
112
|
-
return findIndex ? -1 : void 0;
|
|
36
|
+
function findSimpleValue(array, first, indiced, reverse) {
|
|
37
|
+
const method = reverse ? "findLastIndex" : "findIndex";
|
|
38
|
+
const index = typeof first === "function" ? array[method](first) : array[method]((item) => Object.is(item, first));
|
|
39
|
+
return index === -1 ? void 0 : { values: [indiced ? index : array[index]] };
|
|
113
40
|
}
|
|
114
|
-
function
|
|
115
|
-
|
|
116
|
-
matched: [],
|
|
117
|
-
notMatched: []
|
|
118
|
-
};
|
|
119
|
-
if (!Array.isArray(array)) return result;
|
|
41
|
+
function findValue(array, parameters) {
|
|
42
|
+
if (!Array.isArray(array)) return;
|
|
120
43
|
const arrayLength = array.length;
|
|
121
|
-
if (arrayLength === 0) return
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
after: mapReverse ? void 0 : mapCallback
|
|
136
|
-
};
|
|
137
|
-
const simple = callbacks?.bool != null || type === "all" && key == null;
|
|
138
|
-
const findParameters = {
|
|
139
|
-
array,
|
|
140
|
-
arrayLength,
|
|
141
|
-
flat,
|
|
142
|
-
limit,
|
|
143
|
-
map,
|
|
144
|
-
result,
|
|
145
|
-
type,
|
|
146
|
-
value,
|
|
147
|
-
callback: simple ? callbacks?.bool : callbacks?.keyed
|
|
148
|
-
};
|
|
149
|
-
return simple ? findSimpleValues(findParameters) : findComplexValues(findParameters);
|
|
150
|
-
}
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region src/array/filter.ts
|
|
153
|
-
function exclude(array, ...parameters) {
|
|
154
|
-
return findValues("all", array, parameters).notMatched;
|
|
155
|
-
}
|
|
156
|
-
function filter(array, ...parameters) {
|
|
157
|
-
return findValues("all", array, parameters).matched;
|
|
44
|
+
if (arrayLength === 0) return;
|
|
45
|
+
const inputLength = parameters.input.length;
|
|
46
|
+
if (inputLength === 0 && parameters.bare) return findBareValue(array, parameters.reverse ?? false);
|
|
47
|
+
const [first, second] = parameters.input;
|
|
48
|
+
if (inputLength === 1 && !parameters.limit) return findSimpleValue(array, first, parameters.indiced ?? false, parameters.reverse ?? false);
|
|
49
|
+
const callback = inputLength === 1 && typeof first === "function" ? first : getCallback$1(first, second);
|
|
50
|
+
return callback == null ? void 0 : findComplexValues(array, arrayLength, parameters, callback);
|
|
51
|
+
}
|
|
52
|
+
function getCallback$1(first, second) {
|
|
53
|
+
switch (true) {
|
|
54
|
+
case typeof first === "function": return (item, index, array) => Object.is(first(item, index, array), second);
|
|
55
|
+
case typeof first === "number" || typeof first === "string": return (item) => Object.is(item[first], second);
|
|
56
|
+
default: return;
|
|
57
|
+
}
|
|
158
58
|
}
|
|
159
|
-
|
|
160
|
-
//#endregion
|
|
161
|
-
//#region src/array/find.ts
|
|
59
|
+
// src/array/find.ts
|
|
162
60
|
function find(array, ...parameters) {
|
|
163
|
-
return findValue(
|
|
61
|
+
return findValue(array, {
|
|
62
|
+
input: parameters,
|
|
63
|
+
reverse: false
|
|
64
|
+
})?.values[0];
|
|
164
65
|
}
|
|
165
66
|
function findLast(array, ...parameters) {
|
|
166
|
-
return findValue(
|
|
67
|
+
return findValue(array, {
|
|
68
|
+
input: parameters,
|
|
69
|
+
reverse: true
|
|
70
|
+
})?.values[0];
|
|
167
71
|
}
|
|
168
72
|
find.last = findLast;
|
|
169
|
-
|
|
170
|
-
//#region src/array/first.ts
|
|
73
|
+
// src/array/first.ts
|
|
171
74
|
function first(array, ...parameters) {
|
|
172
|
-
return
|
|
75
|
+
return findValue(array, {
|
|
76
|
+
bare: true,
|
|
77
|
+
input: parameters
|
|
78
|
+
})?.values[0];
|
|
173
79
|
}
|
|
174
80
|
function firstOrDefault(array, defaultValue, ...parameters) {
|
|
175
|
-
return
|
|
81
|
+
return findValue(array, {
|
|
82
|
+
bare: true,
|
|
83
|
+
input: parameters
|
|
84
|
+
})?.values[0] ?? defaultValue;
|
|
176
85
|
}
|
|
177
86
|
first.defaulted = firstOrDefault;
|
|
178
|
-
|
|
179
|
-
|
|
87
|
+
// src/internal/array/callbacks.ts
|
|
88
|
+
function getArrayCallback(value) {
|
|
89
|
+
switch (typeof value) {
|
|
90
|
+
case "function": return value;
|
|
91
|
+
case "number":
|
|
92
|
+
case "string": return (obj) => obj?.[value];
|
|
93
|
+
default: return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function getArrayCallbacks(bool, key, value) {
|
|
97
|
+
if (typeof bool === "function") return { bool };
|
|
98
|
+
return {
|
|
99
|
+
keyed: getArrayCallback(key),
|
|
100
|
+
value: getArrayCallback(value)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
// src/internal/array/group.ts
|
|
180
104
|
function groupValues(array, key, value, arrays) {
|
|
181
105
|
if (!Array.isArray(array) || array.length === 0) return {};
|
|
182
106
|
const { length } = array;
|
|
@@ -194,8 +118,7 @@ function groupValues(array, key, value, arrays) {
|
|
|
194
118
|
}
|
|
195
119
|
return record;
|
|
196
120
|
}
|
|
197
|
-
|
|
198
|
-
//#region src/array/group-by.ts
|
|
121
|
+
// src/array/group-by.ts
|
|
199
122
|
function groupBy(array, first, second) {
|
|
200
123
|
return groupValues(array, first, second, false);
|
|
201
124
|
}
|
|
@@ -203,8 +126,7 @@ function groupArraysBy(array, first, second) {
|
|
|
203
126
|
return groupValues(array, first, second, true);
|
|
204
127
|
}
|
|
205
128
|
groupBy.arrays = groupArraysBy;
|
|
206
|
-
|
|
207
|
-
//#region src/models/array/array.misc.model.ts
|
|
129
|
+
// src/models/array/array.misc.model.ts
|
|
208
130
|
const ARRAY_CHUNK_MAX_SIZE = 5e3;
|
|
209
131
|
const ARRAY_INSERT_TYPE_INSERT = "insert";
|
|
210
132
|
const ARRAY_INSERT_TYPE_PUSH = "push";
|
|
@@ -214,8 +136,7 @@ const ARRAY_SETS_COMPARE_INTERSECTION = "intersection";
|
|
|
214
136
|
const ARRAY_SETS_COMPARE_UNION = "union";
|
|
215
137
|
const ARRAY_SLICE_DROP = "drop";
|
|
216
138
|
const ARRAY_SLICE_TAKE = "take";
|
|
217
|
-
|
|
218
|
-
//#region src/internal/array/chunk.ts
|
|
139
|
+
// src/internal/array/chunk.ts
|
|
219
140
|
/**
|
|
220
141
|
* Chunk an array into smaller arrays
|
|
221
142
|
*
|
|
@@ -242,8 +163,7 @@ function chunk(array, size) {
|
|
|
242
163
|
}
|
|
243
164
|
return chunks;
|
|
244
165
|
}
|
|
245
|
-
|
|
246
|
-
//#region src/internal/array/compact.ts
|
|
166
|
+
// src/internal/array/compact.ts
|
|
247
167
|
function compact(array, strict) {
|
|
248
168
|
if (!Array.isArray(array)) return [];
|
|
249
169
|
if (strict === true) return array.filter(Boolean);
|
|
@@ -255,8 +175,7 @@ function compact(array, strict) {
|
|
|
255
175
|
}
|
|
256
176
|
return compacted;
|
|
257
177
|
}
|
|
258
|
-
|
|
259
|
-
//#region src/internal/is.ts
|
|
178
|
+
// src/internal/is.ts
|
|
260
179
|
/**
|
|
261
180
|
* Is the value an array or a plain object?
|
|
262
181
|
*
|
|
@@ -439,8 +358,7 @@ function isTypedArray(value) {
|
|
|
439
358
|
]);
|
|
440
359
|
return isTypedArray.types.has(value?.constructor);
|
|
441
360
|
}
|
|
442
|
-
|
|
443
|
-
//#region src/internal/array/get.ts
|
|
361
|
+
// src/internal/array/get.ts
|
|
444
362
|
function getArray(value, indiced) {
|
|
445
363
|
if (Array.isArray(value)) return value;
|
|
446
364
|
if (value instanceof Map) return [...value.entries()];
|
|
@@ -468,8 +386,7 @@ const arrayMatchInvalid = [-1, ARRAY_MATCH_COMPARISON_INVALID];
|
|
|
468
386
|
const arrayMatchOutside = [-1, ARRAY_MATCH_COMPARISON_OUTSIDE];
|
|
469
387
|
const arrayMatchOutsides = /* @__PURE__ */ new Set([ARRAY_MATCH_COMPARISON_INVALID, ARRAY_MATCH_COMPARISON_OUTSIDE]);
|
|
470
388
|
const arrayMatchStarts = /* @__PURE__ */ new Set([ARRAY_MATCH_COMPARISON_START, ARRAY_MATCH_COMPARISON_SAME]);
|
|
471
|
-
|
|
472
|
-
//#region src/internal/array/match.ts
|
|
389
|
+
// src/internal/array/match.ts
|
|
473
390
|
function endsWithArray(haystack, needle, key) {
|
|
474
391
|
return arrayMatchEndings.has(getPosition(haystack, needle, key)[1]);
|
|
475
392
|
}
|
|
@@ -517,8 +434,7 @@ function indexOfArray(haystack, needle, key) {
|
|
|
517
434
|
function startsWithArray(haystack, needle, key) {
|
|
518
435
|
return arrayMatchStarts.has(getPosition(haystack, needle, key)[1]);
|
|
519
436
|
}
|
|
520
|
-
|
|
521
|
-
//#region src/internal/math/misc.ts
|
|
437
|
+
// src/internal/math/misc.ts
|
|
522
438
|
/**
|
|
523
439
|
* Round a number down
|
|
524
440
|
*
|
|
@@ -559,8 +475,7 @@ function roundNumber(callback, value, decimals) {
|
|
|
559
475
|
const mod = 10 ** decimals;
|
|
560
476
|
return callback((value + Number.EPSILON) * mod) / mod;
|
|
561
477
|
}
|
|
562
|
-
|
|
563
|
-
//#region src/internal/random.ts
|
|
478
|
+
// src/internal/random.ts
|
|
564
479
|
/**
|
|
565
480
|
* Get a random number between 0 _(inclusive)_ and 1 _(exclusive)_
|
|
566
481
|
*
|
|
@@ -599,8 +514,7 @@ function getRandomInteger(minimum, maximum) {
|
|
|
599
514
|
return floor(getRandomFloatingNumberValue(true, minimum, maximum));
|
|
600
515
|
}
|
|
601
516
|
const RANDOM_DIVISOR = 2 ** 32;
|
|
602
|
-
|
|
603
|
-
//#region src/internal/array/shuffle.ts
|
|
517
|
+
// src/internal/array/shuffle.ts
|
|
604
518
|
/**
|
|
605
519
|
* Shuffle items in array
|
|
606
520
|
*
|
|
@@ -623,8 +537,7 @@ function shuffle(array) {
|
|
|
623
537
|
}
|
|
624
538
|
return shuffled;
|
|
625
539
|
}
|
|
626
|
-
|
|
627
|
-
//#region src/internal/array/sets.ts
|
|
540
|
+
// src/internal/array/sets.ts
|
|
628
541
|
function compareSets(type, first, second, key) {
|
|
629
542
|
if (!Array.isArray(first)) return [];
|
|
630
543
|
const isDifference = type === ARRAY_SETS_COMPARE_DIFFERENCE;
|
|
@@ -648,27 +561,32 @@ function getComparison(first, second, isIntersection, isUnion, key) {
|
|
|
648
561
|
}
|
|
649
562
|
const source = isUnion ? second : first;
|
|
650
563
|
length = source.length;
|
|
651
|
-
const
|
|
564
|
+
const compared = isUnion ? first.slice() : [];
|
|
652
565
|
for (let index = 0; index < length; index += 1) {
|
|
653
566
|
const item = source[index];
|
|
654
567
|
const value = callback?.(item, index, source) ?? item;
|
|
655
|
-
if (isIntersection ? set.has(value) : !set.has(value))
|
|
568
|
+
if (isIntersection ? set.has(value) : !set.has(value)) compared.push(item);
|
|
656
569
|
}
|
|
657
|
-
return
|
|
570
|
+
return compared;
|
|
658
571
|
}
|
|
659
|
-
|
|
660
|
-
//#region src/array/difference.ts
|
|
572
|
+
// src/array/difference.ts
|
|
661
573
|
function difference(first, second, key) {
|
|
662
574
|
return compareSets(ARRAY_SETS_COMPARE_DIFFERENCE, first, second, key);
|
|
663
575
|
}
|
|
664
|
-
|
|
665
|
-
//#region src/array/exists.ts
|
|
576
|
+
// src/array/exists.ts
|
|
666
577
|
function exists(array, ...parameters) {
|
|
667
|
-
if (
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
578
|
+
if (!Array.isArray(array)) return false;
|
|
579
|
+
if (array.length === 0) return false;
|
|
580
|
+
const [first, second] = parameters;
|
|
581
|
+
const { length } = parameters;
|
|
582
|
+
if (length === 1) return typeof first === "function" ? array.some((item, index, array) => first(item, index, array)) : array.includes(first);
|
|
583
|
+
let callback;
|
|
584
|
+
if (typeof first === "function") callback = first;
|
|
585
|
+
else if (typeof first === "number" || typeof first === "string") callback = (item) => item[first];
|
|
586
|
+
if (callback == null) return false;
|
|
587
|
+
return array.some((item, index, array) => Object.is(callback(item, index, array), second));
|
|
588
|
+
}
|
|
589
|
+
// src/array/flatten.ts
|
|
672
590
|
/**
|
|
673
591
|
* Flatten an array _(using native `flat` and maximum depth)_
|
|
674
592
|
*
|
|
@@ -683,8 +601,7 @@ function exists(array, ...parameters) {
|
|
|
683
601
|
function flatten(array) {
|
|
684
602
|
return Array.isArray(array) ? array.flat(Number.POSITIVE_INFINITY) : [];
|
|
685
603
|
}
|
|
686
|
-
|
|
687
|
-
//#region src/array/from.ts
|
|
604
|
+
// src/array/from.ts
|
|
688
605
|
function range(first, second, third) {
|
|
689
606
|
const start = typeof second === "number" ? first : 0;
|
|
690
607
|
const end = typeof second === "number" ? second : first;
|
|
@@ -702,11 +619,9 @@ function times(length, value) {
|
|
|
702
619
|
for (let index = 0; index < length; index += 1) values.push(isFunction ? value(index) : value ?? index);
|
|
703
620
|
return values;
|
|
704
621
|
}
|
|
705
|
-
|
|
706
|
-
//#region src/models/math.model.ts
|
|
622
|
+
// src/models/math.model.ts
|
|
707
623
|
const AGGREGATION_AVERAGE = "average";
|
|
708
|
-
|
|
709
|
-
//#region src/internal/math/aggregate.ts
|
|
624
|
+
// src/internal/math/aggregate.ts
|
|
710
625
|
function aggregate(type, array, key, first) {
|
|
711
626
|
const length = Array.isArray(array) ? array.length : 0;
|
|
712
627
|
const aggregation = {
|
|
@@ -778,8 +693,7 @@ const aggregators = {
|
|
|
778
693
|
min: getAbsoluteValue.bind(void 0, isMinValue),
|
|
779
694
|
sum: calculateSum
|
|
780
695
|
};
|
|
781
|
-
|
|
782
|
-
//#region src/internal/array/insert.ts
|
|
696
|
+
// src/internal/array/insert.ts
|
|
783
697
|
function insertChunkedValues(type, array, items, start, deleteCount) {
|
|
784
698
|
const actualDeleteCount = max([deleteCount, 0]);
|
|
785
699
|
const actualStart = min([max([0, start]), array.length]);
|
|
@@ -801,24 +715,42 @@ function insertValues(type, array, items, start, deleteCount) {
|
|
|
801
715
|
if (!Array.isArray(array) || typeof start !== "number" || !Array.isArray(items) || items.length === 0) return spliceArray ? [] : 0;
|
|
802
716
|
return insertChunkedValues(type, array, items, start, spliceArray ? deleteCount : 0);
|
|
803
717
|
}
|
|
804
|
-
|
|
805
|
-
//#region src/array/insert.ts
|
|
718
|
+
// src/array/insert.ts
|
|
806
719
|
function insert(array, indexOrItems, items) {
|
|
807
720
|
return insertValues(ARRAY_INSERT_TYPE_INSERT, array, items ?? indexOrItems, typeof indexOrItems === "number" ? indexOrItems : array?.length, 0);
|
|
808
721
|
}
|
|
809
|
-
|
|
810
|
-
//#region src/array/intersection.ts
|
|
722
|
+
// src/array/intersection.ts
|
|
811
723
|
function intersection(first, second, key) {
|
|
812
724
|
return compareSets(ARRAY_SETS_COMPARE_INTERSECTION, first, second, key);
|
|
813
725
|
}
|
|
814
|
-
|
|
815
|
-
|
|
726
|
+
// src/array/partition.ts
|
|
727
|
+
function getCallback(first, second, length) {
|
|
728
|
+
if (length === 1 && typeof first === "function") return first;
|
|
729
|
+
switch (true) {
|
|
730
|
+
case length === 1: return (item) => Object.is(item, first);
|
|
731
|
+
case typeof first === "function": return (item, index, array) => Object.is(first(item, index, array), second);
|
|
732
|
+
case typeof first === "number" || typeof first === "string": return (item) => Object.is(item[first], second);
|
|
733
|
+
default: return;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
816
736
|
function partition(array, ...parameters) {
|
|
817
|
-
|
|
737
|
+
if (!Array.isArray(array)) return [[], []];
|
|
738
|
+
const arrayLength = array.length;
|
|
739
|
+
if (arrayLength === 0) return [[], []];
|
|
740
|
+
const parametersLength = parameters.length;
|
|
741
|
+
const [first, second] = parameters;
|
|
742
|
+
const callback = getCallback(first, second, parametersLength);
|
|
743
|
+
if (callback == null) return [[], []];
|
|
744
|
+
const matched = [];
|
|
745
|
+
const notMatched = [];
|
|
746
|
+
for (let index = 0; index < arrayLength; index += 1) {
|
|
747
|
+
const item = array[index];
|
|
748
|
+
if (callback(item, index, array)) matched.push(item);
|
|
749
|
+
else notMatched.push(item);
|
|
750
|
+
}
|
|
818
751
|
return [matched, notMatched];
|
|
819
752
|
}
|
|
820
|
-
|
|
821
|
-
//#region src/array/push.ts
|
|
753
|
+
// src/array/push.ts
|
|
822
754
|
/**
|
|
823
755
|
* Push items into an array _(at the end)_
|
|
824
756
|
*
|
|
@@ -836,8 +768,7 @@ function partition(array, ...parameters) {
|
|
|
836
768
|
function push(array, pushed) {
|
|
837
769
|
return insertValues(ARRAY_INSERT_TYPE_PUSH, array, pushed, array.length, 0);
|
|
838
770
|
}
|
|
839
|
-
|
|
840
|
-
//#region src/array/reverse.ts
|
|
771
|
+
// src/array/reverse.ts
|
|
841
772
|
/**
|
|
842
773
|
* Reverse the order of items in an array
|
|
843
774
|
*
|
|
@@ -863,16 +794,18 @@ function reverse(array) {
|
|
|
863
794
|
}
|
|
864
795
|
return array;
|
|
865
796
|
}
|
|
866
|
-
|
|
867
|
-
//#region src/array/single.ts
|
|
797
|
+
// src/array/single.ts
|
|
868
798
|
function single(array, ...parameters) {
|
|
869
|
-
const
|
|
870
|
-
|
|
871
|
-
|
|
799
|
+
const result = findValue(array, {
|
|
800
|
+
input: parameters,
|
|
801
|
+
limit: 2
|
|
802
|
+
});
|
|
803
|
+
if (result == null) return;
|
|
804
|
+
if (result.values.length > 1) throw new Error(SINGLE_MESSAGE);
|
|
805
|
+
return result.values[0];
|
|
872
806
|
}
|
|
873
807
|
const SINGLE_MESSAGE = "Multiple items were found";
|
|
874
|
-
|
|
875
|
-
//#region src/array/slice.ts
|
|
808
|
+
// src/array/slice.ts
|
|
876
809
|
function drop(array, first, second) {
|
|
877
810
|
return extract(ARRAY_SLICE_DROP, array, first, second);
|
|
878
811
|
}
|
|
@@ -933,14 +866,12 @@ function slice(array, first, second) {
|
|
|
933
866
|
function take(array, first, second) {
|
|
934
867
|
return extract(ARRAY_SLICE_TAKE, array, first, second);
|
|
935
868
|
}
|
|
936
|
-
|
|
937
|
-
//#region src/array/splice.ts
|
|
869
|
+
// src/array/splice.ts
|
|
938
870
|
function splice(array, start, deleteCountOrItems, items) {
|
|
939
871
|
const deleteCountIsNumber = typeof deleteCountOrItems === "number";
|
|
940
872
|
return insertValues(ARRAY_INSERT_TYPE_SPLICE, array, deleteCountIsNumber ? items : deleteCountOrItems, start, deleteCountIsNumber ? deleteCountOrItems : 0);
|
|
941
873
|
}
|
|
942
|
-
|
|
943
|
-
//#region src/array/to-set.ts
|
|
874
|
+
// src/array/to-set.ts
|
|
944
875
|
function toSet(array, value) {
|
|
945
876
|
if (!Array.isArray(array)) return /* @__PURE__ */ new Set();
|
|
946
877
|
const callbacks = getArrayCallbacks(void 0, void 0, value);
|
|
@@ -950,8 +881,7 @@ function toSet(array, value) {
|
|
|
950
881
|
for (let index = 0; index < length; index += 1) set.add(callbacks.value(array[index], index, array));
|
|
951
882
|
return set;
|
|
952
883
|
}
|
|
953
|
-
|
|
954
|
-
//#region src/internal/array/update.ts
|
|
884
|
+
// src/internal/array/update.ts
|
|
955
885
|
function updateInArray(array, items, key, replace) {
|
|
956
886
|
if (!Array.isArray(array)) return [];
|
|
957
887
|
const itemsIsArray = Array.isArray(items);
|
|
@@ -972,38 +902,54 @@ function updateInArray(array, items, key, replace) {
|
|
|
972
902
|
}
|
|
973
903
|
return array;
|
|
974
904
|
}
|
|
975
|
-
|
|
976
|
-
//#region src/array/toggle.ts
|
|
905
|
+
// src/array/toggle.ts
|
|
977
906
|
function toggle(array, values, key) {
|
|
978
907
|
return updateInArray(array, values, key, false);
|
|
979
908
|
}
|
|
980
|
-
|
|
981
|
-
//#region src/array/union.ts
|
|
909
|
+
// src/array/union.ts
|
|
982
910
|
function union(first, second, key) {
|
|
983
911
|
return compareSets(ARRAY_SETS_COMPARE_UNION, first, second, key);
|
|
984
912
|
}
|
|
985
|
-
|
|
986
|
-
//#region src/array/unique.ts
|
|
913
|
+
// src/array/unique.ts
|
|
987
914
|
function unique(array, key) {
|
|
988
915
|
if (!Array.isArray(array)) return [];
|
|
989
|
-
|
|
916
|
+
const { length } = array;
|
|
917
|
+
if (length < 2) return array.slice();
|
|
918
|
+
const callback = getArrayCallback(key);
|
|
919
|
+
if (callback == null && length >= 100) return [...new Set(array)];
|
|
920
|
+
const keyed = /* @__PURE__ */ new Set();
|
|
921
|
+
const uniques = [];
|
|
922
|
+
for (let index = 0; index < length; index += 1) {
|
|
923
|
+
const item = array[index];
|
|
924
|
+
const value = callback == null ? item : callback(item, index, array);
|
|
925
|
+
if (!keyed.has(value)) {
|
|
926
|
+
keyed.add(value);
|
|
927
|
+
uniques.push(item);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
return uniques;
|
|
990
931
|
}
|
|
991
|
-
|
|
992
|
-
//#region src/array/update.ts
|
|
932
|
+
// src/array/update.ts
|
|
993
933
|
function update(array, values, key) {
|
|
994
934
|
return updateInArray(array, values, key, true);
|
|
995
935
|
}
|
|
996
|
-
|
|
997
|
-
//#region src/array/last.ts
|
|
936
|
+
// src/array/last.ts
|
|
998
937
|
function last(array, ...parameters) {
|
|
999
|
-
return
|
|
938
|
+
return findValue(array, {
|
|
939
|
+
bare: true,
|
|
940
|
+
input: parameters,
|
|
941
|
+
reverse: true
|
|
942
|
+
})?.values[0];
|
|
1000
943
|
}
|
|
1001
944
|
function lastOrDefault(array, defaultValue, ...parameters) {
|
|
1002
|
-
return
|
|
945
|
+
return findValue(array, {
|
|
946
|
+
bare: true,
|
|
947
|
+
input: parameters,
|
|
948
|
+
reverse: true
|
|
949
|
+
})?.values[0] ?? defaultValue;
|
|
1003
950
|
}
|
|
1004
951
|
last.defaulted = lastOrDefault;
|
|
1005
|
-
|
|
1006
|
-
//#region src/internal/array/overlap.ts
|
|
952
|
+
// src/internal/array/overlap.ts
|
|
1007
953
|
function arraysOverlap(first, second) {
|
|
1008
954
|
const firstArray = first.index < second.index ? first.array : second.array;
|
|
1009
955
|
const secondArray = first.index < second.index ? second.array : first.array;
|
|
@@ -1022,8 +968,7 @@ function arraysOverlap(first, second) {
|
|
|
1022
968
|
}
|
|
1023
969
|
};
|
|
1024
970
|
}
|
|
1025
|
-
|
|
1026
|
-
//#region src/array/move.ts
|
|
971
|
+
// src/array/move.ts
|
|
1027
972
|
function move(array, from, to, key) {
|
|
1028
973
|
if (!Array.isArray(array)) return [];
|
|
1029
974
|
const firstArray = Array.isArray(from) ? from : [from];
|
|
@@ -1095,8 +1040,7 @@ function moveToIndex(array, value, index, key) {
|
|
|
1095
1040
|
}
|
|
1096
1041
|
move.indices = moveIndices;
|
|
1097
1042
|
move.toIndex = moveToIndex;
|
|
1098
|
-
|
|
1099
|
-
//#region src/array/select.ts
|
|
1043
|
+
// src/array/select.ts
|
|
1100
1044
|
function filterAndFlatMap(array, filter, mapper) {
|
|
1101
1045
|
return selectValues(array, filter, mapper, true, false);
|
|
1102
1046
|
}
|
|
@@ -1109,18 +1053,51 @@ function flatMapAndFilter(array, mapper, filter) {
|
|
|
1109
1053
|
function mapAndFilter(array, mapper, filter) {
|
|
1110
1054
|
return selectValues(array, filter, mapper, false, true);
|
|
1111
1055
|
}
|
|
1056
|
+
function selectBareValues(array, length, filter, mapper, reverse) {
|
|
1057
|
+
const selected = [];
|
|
1058
|
+
for (let index = 0; index < length; index += 1) {
|
|
1059
|
+
const item = array[index];
|
|
1060
|
+
const mapped = reverse ? mapper(item, index, array) : item;
|
|
1061
|
+
if (filter(mapped, index, array)) selected.push(reverse ? mapped : mapper(item, index, array));
|
|
1062
|
+
}
|
|
1063
|
+
return selected;
|
|
1064
|
+
}
|
|
1065
|
+
function selectFlatValues(array, arrayLength, filter, mapper, reverse) {
|
|
1066
|
+
if (reverse) return selectFlatValuesReversed(array, arrayLength, filter, mapper);
|
|
1067
|
+
const selected = [];
|
|
1068
|
+
for (let arrayIndex = 0; arrayIndex < arrayLength; arrayIndex += 1) {
|
|
1069
|
+
const item = array[arrayIndex];
|
|
1070
|
+
if (!filter(item, arrayIndex, array)) continue;
|
|
1071
|
+
const mapped = mapper(item, arrayIndex, array);
|
|
1072
|
+
if (Array.isArray(mapped)) selected.push(...mapped);
|
|
1073
|
+
else selected.push(mapped);
|
|
1074
|
+
}
|
|
1075
|
+
return selected;
|
|
1076
|
+
}
|
|
1077
|
+
function selectFlatValuesReversed(array, arrayLength, filter, mapper) {
|
|
1078
|
+
const selected = [];
|
|
1079
|
+
for (let arrayIndex = 0; arrayIndex < arrayLength; arrayIndex += 1) {
|
|
1080
|
+
const item = array[arrayIndex];
|
|
1081
|
+
const mapped = mapper(item, arrayIndex, array);
|
|
1082
|
+
const items = Array.isArray(mapped) ? mapped : [mapped];
|
|
1083
|
+
const itemsLength = items.length;
|
|
1084
|
+
for (let itemsIndex = 0; itemsIndex < itemsLength; itemsIndex += 1) {
|
|
1085
|
+
const item = items[itemsIndex];
|
|
1086
|
+
if (filter(item, arrayIndex, array)) selected.push(item);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
return selected;
|
|
1090
|
+
}
|
|
1112
1091
|
function selectValues(array, filter, mapper, flat, reverse) {
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
} }).matched;
|
|
1092
|
+
if (!Array.isArray(array) || typeof filter !== "function" || typeof mapper !== "function") return [];
|
|
1093
|
+
const { length } = array;
|
|
1094
|
+
if (length === 0) return [];
|
|
1095
|
+
return flat ? selectFlatValues(array, length, filter, mapper, reverse) : selectBareValues(array, length, filter, mapper, reverse);
|
|
1118
1096
|
}
|
|
1119
1097
|
filterAndMap.flat = filterAndFlatMap;
|
|
1120
1098
|
filterAndMap.reverse = mapAndFilter;
|
|
1121
1099
|
mapAndFilter.flat = flatMapAndFilter;
|
|
1122
|
-
|
|
1123
|
-
//#region src/models/value/value.misc.model.ts
|
|
1100
|
+
// src/models/value/value.misc.model.ts
|
|
1124
1101
|
const COMPARE_NAME = "compare";
|
|
1125
1102
|
const VALUE_MISC_EXPRESSION_BRACKET = /\[(\w+)\]/g;
|
|
1126
1103
|
const VALUE_MISC_EXPRESSION_DOTS = /^\.|\.$/g;
|
|
@@ -1129,16 +1106,14 @@ const VALUE_MISC_NESTED_MESSAGE_INPUT = "Expected data to be an object";
|
|
|
1129
1106
|
const VALUE_MISC_NESTED_MESSAGE_MISSING = "Expected property to exist in object";
|
|
1130
1107
|
const VALUE_MISC_NESTED_MESSAGE_PATH = "Expected path to be a string";
|
|
1131
1108
|
const VALUE_MISC_NESTED_MESSAGE_UNSAFE = "Access to this property is not allowed";
|
|
1132
|
-
|
|
1133
|
-
//#region src/models/string/string.misc.model.ts
|
|
1109
|
+
// src/models/string/string.misc.model.ts
|
|
1134
1110
|
const STRING_EXPRESSION_IGNORED = /(^|\.)(__proto__|constructor|prototype)(\.|$)/i;
|
|
1135
1111
|
const STRING_EXPRESSION_WORDS = /[\dA-Za-z\P{ASCII}]+/gu;
|
|
1136
1112
|
const STRING_EXPRESSION_WHITESPACE_PREFIX = /^(\s+)/;
|
|
1137
1113
|
const STRING_MATCH_ENDS_WITH = "endsWith";
|
|
1138
1114
|
const STRING_MATCH_INCLUDES = "includes";
|
|
1139
1115
|
const STRING_MATCH_STARTS_WITH = "startsWith";
|
|
1140
|
-
|
|
1141
|
-
//#region src/internal/result/misc.ts
|
|
1116
|
+
// src/internal/result/misc.ts
|
|
1142
1117
|
function error(value, original) {
|
|
1143
1118
|
return getError(value, original);
|
|
1144
1119
|
}
|
|
@@ -1187,8 +1162,7 @@ const RESULT_PROPERTY_ERROR = "error";
|
|
|
1187
1162
|
const RESULT_PROPERTY_VALUE = "value";
|
|
1188
1163
|
error.is = isError;
|
|
1189
1164
|
ok.is = isOk;
|
|
1190
|
-
|
|
1191
|
-
//#region src/result/misc.ts
|
|
1165
|
+
// src/result/misc.ts
|
|
1192
1166
|
async function toPromise(result) {
|
|
1193
1167
|
const actual = typeof result === "function" ? result() : result;
|
|
1194
1168
|
if (!isResult(actual)) throw new TypeError(RESULT_MESSAGE_PROMISE);
|
|
@@ -1196,8 +1170,7 @@ async function toPromise(result) {
|
|
|
1196
1170
|
throw actual.error;
|
|
1197
1171
|
}
|
|
1198
1172
|
const RESULT_MESSAGE_PROMISE = "toPromise expected to receive a Result";
|
|
1199
|
-
|
|
1200
|
-
//#region src/internal/result/attempt.ts
|
|
1173
|
+
// src/internal/result/attempt.ts
|
|
1201
1174
|
async function asyncAttempt(value, err) {
|
|
1202
1175
|
try {
|
|
1203
1176
|
let result;
|
|
@@ -1217,8 +1190,7 @@ function attempt(callback, err) {
|
|
|
1217
1190
|
}
|
|
1218
1191
|
}
|
|
1219
1192
|
attempt.async = asyncAttempt;
|
|
1220
|
-
|
|
1221
|
-
//#region src/internal/string/misc.ts
|
|
1193
|
+
// src/internal/string/misc.ts
|
|
1222
1194
|
/**
|
|
1223
1195
|
* Get the string value from any value
|
|
1224
1196
|
*
|
|
@@ -1315,8 +1287,7 @@ function words(value) {
|
|
|
1315
1287
|
if (typeof value === "string") return value.match(STRING_EXPRESSION_WORDS) ?? [];
|
|
1316
1288
|
return [];
|
|
1317
1289
|
}
|
|
1318
|
-
|
|
1319
|
-
//#region src/internal/value/handlers.ts
|
|
1290
|
+
// src/internal/value/handlers.ts
|
|
1320
1291
|
function BaseHandler(owner, options) {
|
|
1321
1292
|
this.handlers = /* @__PURE__ */ new WeakMap();
|
|
1322
1293
|
this.owner = owner;
|
|
@@ -1368,8 +1339,7 @@ function handleValue$1(value, ...parameters) {
|
|
|
1368
1339
|
if (handler == null) return this.base.options.callback(value, ...parameters);
|
|
1369
1340
|
return typeof handler === "function" ? handler(value) : value[handler]();
|
|
1370
1341
|
}
|
|
1371
|
-
|
|
1372
|
-
//#region src/internal/value/compare.ts
|
|
1342
|
+
// src/internal/value/compare.ts
|
|
1373
1343
|
/**
|
|
1374
1344
|
* Compare two values _(for sorting purposes)_
|
|
1375
1345
|
*
|
|
@@ -1452,8 +1422,7 @@ const compareHandler = createCompareHandler(compare, {
|
|
|
1452
1422
|
compare.deregister = deregisterComparator;
|
|
1453
1423
|
compare.handler = compareHandler;
|
|
1454
1424
|
compare.register = registerComparator;
|
|
1455
|
-
|
|
1456
|
-
//#region src/models/array/array.sort.model.ts
|
|
1425
|
+
// src/models/array/array.sort.model.ts
|
|
1457
1426
|
const SORT_DIRECTION_ASCENDING = "ascending";
|
|
1458
1427
|
const SORT_DIRECTION_DESCENDING = "descending";
|
|
1459
1428
|
const SORTER_SYMBOL = Symbol("sorter");
|
|
@@ -1461,8 +1430,7 @@ const arrayModifiers = {
|
|
|
1461
1430
|
[SORT_DIRECTION_ASCENDING]: 1,
|
|
1462
1431
|
[SORT_DIRECTION_DESCENDING]: -1
|
|
1463
1432
|
};
|
|
1464
|
-
|
|
1465
|
-
//#region src/array/sort.ts
|
|
1433
|
+
// src/array/sort.ts
|
|
1466
1434
|
function Sorter(sorters) {
|
|
1467
1435
|
this[SORTER_SYMBOL] = sorters;
|
|
1468
1436
|
}
|
|
@@ -1594,17 +1562,22 @@ function sortArray(array) {
|
|
|
1594
1562
|
sort.getIndex = getSortedIndex;
|
|
1595
1563
|
sort.initialize = initializeSorter;
|
|
1596
1564
|
sort.is = isSorted;
|
|
1597
|
-
|
|
1598
|
-
//#region src/internal/array/index-of.ts
|
|
1565
|
+
// src/internal/array/index-of.ts
|
|
1599
1566
|
function indexOf(array, ...parameters) {
|
|
1600
|
-
return findValue(
|
|
1567
|
+
return findValue(array, {
|
|
1568
|
+
indiced: true,
|
|
1569
|
+
input: parameters
|
|
1570
|
+
})?.values[0] ?? -1;
|
|
1601
1571
|
}
|
|
1602
1572
|
function lastIndexOf(array, ...parameters) {
|
|
1603
|
-
return findValue(
|
|
1573
|
+
return findValue(array, {
|
|
1574
|
+
indiced: true,
|
|
1575
|
+
input: parameters,
|
|
1576
|
+
reverse: true
|
|
1577
|
+
})?.values[0] ?? -1;
|
|
1604
1578
|
}
|
|
1605
1579
|
indexOf.last = lastIndexOf;
|
|
1606
|
-
|
|
1607
|
-
//#region src/array/swap.ts
|
|
1580
|
+
// src/array/swap.ts
|
|
1608
1581
|
function swap(array, first, second, third) {
|
|
1609
1582
|
if (!Array.isArray(array)) return [];
|
|
1610
1583
|
if (array.length === 0) return array;
|
|
@@ -1660,8 +1633,7 @@ function swapValues(array, from, to, key) {
|
|
|
1660
1633
|
return swapIndices(array, first, second);
|
|
1661
1634
|
}
|
|
1662
1635
|
swap.indices = swapIndices;
|
|
1663
|
-
|
|
1664
|
-
//#region src/array/to-map.ts
|
|
1636
|
+
// src/array/to-map.ts
|
|
1665
1637
|
function getMapValues(array, first, second, arrays) {
|
|
1666
1638
|
if (!Array.isArray(array)) return /* @__PURE__ */ new Map();
|
|
1667
1639
|
const { length } = array;
|
|
@@ -1686,8 +1658,7 @@ function toMapArrays(array, first, second) {
|
|
|
1686
1658
|
return getMapValues(array, first, second, true);
|
|
1687
1659
|
}
|
|
1688
1660
|
toMap.arrays = toMapArrays;
|
|
1689
|
-
|
|
1690
|
-
//#region src/array/to-record.ts
|
|
1661
|
+
// src/array/to-record.ts
|
|
1691
1662
|
function toRecord(array, first, second) {
|
|
1692
1663
|
return groupValues(array, first, second, false);
|
|
1693
1664
|
}
|
|
@@ -1695,18 +1666,19 @@ function toRecordArrays(array, first, second) {
|
|
|
1695
1666
|
return groupValues(array, first, second, true);
|
|
1696
1667
|
}
|
|
1697
1668
|
toRecord.arrays = toRecordArrays;
|
|
1698
|
-
|
|
1699
|
-
//#region src/internal/function/misc.ts
|
|
1669
|
+
// src/internal/function/misc.ts
|
|
1700
1670
|
/**
|
|
1701
1671
|
* A function that does nothing, which can be useful, I guess…
|
|
1702
1672
|
*/
|
|
1703
1673
|
function noop() {}
|
|
1704
|
-
|
|
1705
|
-
|
|
1674
|
+
function unwrapWork(value) {
|
|
1675
|
+
if (isError(value)) throw value.error;
|
|
1676
|
+
return isOk(value) ? value.value : value;
|
|
1677
|
+
}
|
|
1678
|
+
// src/models/function/limiter.model.ts
|
|
1706
1679
|
const LIMITER_DEBOUNCE = "debounce";
|
|
1707
1680
|
const LIMITER_NAME_ASYNC = "asyncLimiter";
|
|
1708
1681
|
const LIMITER_NAME_SYNC = "limiter";
|
|
1709
|
-
const LIMITER_PROPERTY = "$limiter";
|
|
1710
1682
|
const LIMITER_SYMBOL = Symbol("limiter");
|
|
1711
1683
|
const LIMITER_THROTTLE = "throttle";
|
|
1712
1684
|
const LIMITER_WAIT = "wait";
|
|
@@ -1714,26 +1686,24 @@ const LIMITER_WAIT = "wait";
|
|
|
1714
1686
|
const clearTimer = typeof cancelAnimationFrame === "function" ? cancelAnimationFrame : clearTimeout;
|
|
1715
1687
|
// istanbul ignore next
|
|
1716
1688
|
const startTimer = typeof requestAnimationFrame === "function" ? requestAnimationFrame : setTimeout;
|
|
1717
|
-
|
|
1718
|
-
//#region src/internal/defaults.ts
|
|
1689
|
+
// src/internal/defaults.ts
|
|
1719
1690
|
function getBooleanOrDefault(value, defaultValue) {
|
|
1720
1691
|
return typeof value === "boolean" ? value : defaultValue;
|
|
1721
1692
|
}
|
|
1722
1693
|
function getNumberOrDefault(value, defaultValue, minimum) {
|
|
1723
1694
|
return typeof value === "number" && !Number.isNaN(value) && value >= (minimum ?? 0) ? value : defaultValue;
|
|
1724
1695
|
}
|
|
1725
|
-
|
|
1726
|
-
//#region src/internal/function/limit.ts
|
|
1696
|
+
// src/internal/function/limit.ts
|
|
1727
1697
|
function AsyncLimiter(type, callback, time) {
|
|
1728
1698
|
this[LIMITER_SYMBOL] = {
|
|
1729
1699
|
callback,
|
|
1730
1700
|
type,
|
|
1731
1701
|
interval: getNumberOrDefault(time, 0),
|
|
1702
|
+
name: LIMITER_NAME_ASYNC,
|
|
1732
1703
|
parameters: [],
|
|
1733
1704
|
throttle: type === LIMITER_THROTTLE
|
|
1734
1705
|
};
|
|
1735
1706
|
}
|
|
1736
|
-
AsyncLimiter.prototype[LIMITER_PROPERTY] = LIMITER_NAME_ASYNC;
|
|
1737
1707
|
AsyncLimiter.prototype.cancel = cancelAsyncLimiter;
|
|
1738
1708
|
AsyncLimiter.prototype.run = runAsyncLimiter;
|
|
1739
1709
|
function Limiter(type, callback, time) {
|
|
@@ -1741,11 +1711,11 @@ function Limiter(type, callback, time) {
|
|
|
1741
1711
|
callback,
|
|
1742
1712
|
type,
|
|
1743
1713
|
interval: getNumberOrDefault(time, 0),
|
|
1714
|
+
name: LIMITER_NAME_SYNC,
|
|
1744
1715
|
parameters: [],
|
|
1745
1716
|
throttle: type === LIMITER_THROTTLE
|
|
1746
1717
|
};
|
|
1747
1718
|
}
|
|
1748
|
-
Limiter.prototype[LIMITER_PROPERTY] = LIMITER_NAME_SYNC;
|
|
1749
1719
|
Limiter.prototype.cancel = cancelLimiter;
|
|
1750
1720
|
Limiter.prototype.run = runLimiter;
|
|
1751
1721
|
function cancelAsyncLimiter() {
|
|
@@ -1772,13 +1742,13 @@ async function handleAsyncLimiter(state, item) {
|
|
|
1772
1742
|
if (state.interval === 0 || now - state.start >= state.interval - 5) {
|
|
1773
1743
|
state.start = state.throttle ? now : void 0;
|
|
1774
1744
|
item.running = true;
|
|
1775
|
-
const
|
|
1745
|
+
const attempted = await asyncAttempt(async () => {
|
|
1776
1746
|
let value = state.callback(...item.parameters);
|
|
1777
1747
|
if (value instanceof Promise) value = await value;
|
|
1778
1748
|
return value;
|
|
1779
1749
|
});
|
|
1780
|
-
if (
|
|
1781
|
-
else item.reject(
|
|
1750
|
+
if (attempted.ok) item.resolve(attempted.value);
|
|
1751
|
+
else item.reject(attempted.error);
|
|
1782
1752
|
item.running = false;
|
|
1783
1753
|
} else state.timer = startTimer(() => handleAsyncLimiter(state, item));
|
|
1784
1754
|
}
|
|
@@ -1813,8 +1783,7 @@ function runLimiter(...parameters) {
|
|
|
1813
1783
|
if (state.throttle) handleLimiter(state);
|
|
1814
1784
|
else state.timer = startTimer(() => handleLimiter(state));
|
|
1815
1785
|
}
|
|
1816
|
-
|
|
1817
|
-
//#region src/function/limit.ts
|
|
1786
|
+
// src/function/limit.ts
|
|
1818
1787
|
/**
|
|
1819
1788
|
* Debounce a function, ensuring it is only called after `time` milliseconds have passed
|
|
1820
1789
|
*
|
|
@@ -1869,8 +1838,7 @@ function throttle(callback, time) {
|
|
|
1869
1838
|
}
|
|
1870
1839
|
debounce.async = asyncDebounce;
|
|
1871
1840
|
throttle.async = asyncThrottle;
|
|
1872
|
-
|
|
1873
|
-
//#region src/internal/value/misc.ts
|
|
1841
|
+
// src/internal/value/misc.ts
|
|
1874
1842
|
function findKey(needle, haystack) {
|
|
1875
1843
|
const keys = Object.keys(haystack);
|
|
1876
1844
|
const index = keys.map((key) => key.toLowerCase()).indexOf(needle.toLowerCase());
|
|
@@ -1907,8 +1875,7 @@ function handleValue(data, path, value, get, ignoreCase) {
|
|
|
1907
1875
|
}
|
|
1908
1876
|
if (get) return error(VALUE_MISC_NESTED_MESSAGE_MISSING);
|
|
1909
1877
|
}
|
|
1910
|
-
|
|
1911
|
-
//#region src/internal/value/has.ts
|
|
1878
|
+
// src/internal/value/has.ts
|
|
1912
1879
|
function hasValue(data, path, ignoreCase) {
|
|
1913
1880
|
return getNestedValue(data, path, ignoreCase === true).ok;
|
|
1914
1881
|
}
|
|
@@ -1916,8 +1883,7 @@ function hasValueResult(data, path, ignoreCase) {
|
|
|
1916
1883
|
return getNestedValue(data, path, ignoreCase === true);
|
|
1917
1884
|
}
|
|
1918
1885
|
hasValue.get = hasValueResult;
|
|
1919
|
-
|
|
1920
|
-
//#region src/internal/function/assert.ts
|
|
1886
|
+
// src/internal/function/assert.ts
|
|
1921
1887
|
/**
|
|
1922
1888
|
* Asserts that a condition is true, throwing an error if it is not
|
|
1923
1889
|
*
|
|
@@ -2007,16 +1973,13 @@ assert.defined = assertDefined;
|
|
|
2007
1973
|
assert.instanceOf = assertInstanceOf;
|
|
2008
1974
|
assert.is = assertIs;
|
|
2009
1975
|
assert.property = assertProperty;
|
|
2010
|
-
|
|
2011
|
-
//#region src/models/function/once.model.ts
|
|
1976
|
+
// src/models/function/once.model.ts
|
|
2012
1977
|
const ONCE_NAME_ASYNC = "asyncOnce";
|
|
2013
1978
|
const ONCE_NAME_SYNC = "once";
|
|
2014
|
-
const ONCE_PROPERTY = "$once";
|
|
2015
1979
|
const ONCE_MESSAGE_CLEARED = "Once has been cleared";
|
|
2016
1980
|
const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
|
|
2017
|
-
const ONCE_SYMBOL = Symbol(
|
|
2018
|
-
|
|
2019
|
-
//#region src/function/once.ts
|
|
1981
|
+
const ONCE_SYMBOL = Symbol("once");
|
|
1982
|
+
// src/function/once.ts
|
|
2020
1983
|
function AsyncOnce(callback) {
|
|
2021
1984
|
this[ONCE_SYMBOL] = {
|
|
2022
1985
|
callback,
|
|
@@ -2025,10 +1988,10 @@ function AsyncOnce(callback) {
|
|
|
2025
1988
|
error: false,
|
|
2026
1989
|
finished: false,
|
|
2027
1990
|
items: [],
|
|
1991
|
+
type: ONCE_NAME_ASYNC,
|
|
2028
1992
|
value: void 0
|
|
2029
1993
|
};
|
|
2030
1994
|
}
|
|
2031
|
-
AsyncOnce.prototype[ONCE_PROPERTY] = ONCE_NAME_ASYNC;
|
|
2032
1995
|
AsyncOnce.prototype.clear = clearOnce;
|
|
2033
1996
|
AsyncOnce.prototype.run = runOnceAsync;
|
|
2034
1997
|
Object.defineProperties(AsyncOnce.prototype, {
|
|
@@ -2054,10 +2017,10 @@ function Once(callback) {
|
|
|
2054
2017
|
callback,
|
|
2055
2018
|
called: false,
|
|
2056
2019
|
cleared: false,
|
|
2020
|
+
type: ONCE_NAME_SYNC,
|
|
2057
2021
|
value: void 0
|
|
2058
2022
|
};
|
|
2059
2023
|
}
|
|
2060
|
-
Once.prototype[ONCE_PROPERTY] = ONCE_NAME_SYNC;
|
|
2061
2024
|
Once.prototype.clear = clearOnce;
|
|
2062
2025
|
Once.prototype.run = runOnce;
|
|
2063
2026
|
Object.defineProperties(Once.prototype, {
|
|
@@ -2120,7 +2083,7 @@ function handleOnceResult(state, value, error) {
|
|
|
2120
2083
|
* @returns `true` if the value is an asynchronous once callback, otherwise `false`
|
|
2121
2084
|
*/
|
|
2122
2085
|
function isAsyncOnce(value) {
|
|
2123
|
-
return isOnceInstance(
|
|
2086
|
+
return isOnceInstance(ONCE_NAME_ASYNC, value);
|
|
2124
2087
|
}
|
|
2125
2088
|
/**
|
|
2126
2089
|
* Is the value a once callback?
|
|
@@ -2129,10 +2092,10 @@ function isAsyncOnce(value) {
|
|
|
2129
2092
|
* @returns `true` if the value is a once callback, otherwise `false`
|
|
2130
2093
|
*/
|
|
2131
2094
|
function isOnce(value) {
|
|
2132
|
-
return isOnceInstance(
|
|
2095
|
+
return isOnceInstance(ONCE_NAME_SYNC, value);
|
|
2133
2096
|
}
|
|
2134
|
-
function isOnceInstance(
|
|
2135
|
-
return typeof value === "object" && value !== null &&
|
|
2097
|
+
function isOnceInstance(type, value) {
|
|
2098
|
+
return typeof value === "object" && value !== null && ONCE_SYMBOL in value && value[ONCE_SYMBOL].type === type;
|
|
2136
2099
|
}
|
|
2137
2100
|
/**
|
|
2138
2101
|
* Create a function that can only be called once, returning the same value on subsequent calls
|
|
@@ -2179,8 +2142,7 @@ asyncOnce.is = isAsyncOnce;
|
|
|
2179
2142
|
once.async = asyncOnce;
|
|
2180
2143
|
once.is = isOnce;
|
|
2181
2144
|
once.isAsync = isAsyncOnce;
|
|
2182
|
-
|
|
2183
|
-
//#region src/models/function/retry.model.ts
|
|
2145
|
+
// src/models/function/retry.model.ts
|
|
2184
2146
|
/**
|
|
2185
2147
|
* An error thrown when a retry fails
|
|
2186
2148
|
*/
|
|
@@ -2195,8 +2157,7 @@ var RetryError = class extends Error {
|
|
|
2195
2157
|
const RETRY_ERROR_NAME = "RetryError";
|
|
2196
2158
|
const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
|
|
2197
2159
|
const RETRY_MESSAGE_FAILED = "Retry failed";
|
|
2198
|
-
|
|
2199
|
-
//#region src/function/retry.ts
|
|
2160
|
+
// src/function/retry.ts
|
|
2200
2161
|
/**
|
|
2201
2162
|
* Retry a callback a specified number of times, with a delay between attempts
|
|
2202
2163
|
*
|
|
@@ -2209,12 +2170,12 @@ const RETRY_MESSAGE_FAILED = "Retry failed";
|
|
|
2209
2170
|
async function asyncRetry(callback, options) {
|
|
2210
2171
|
if (typeof callback !== "function") throw new TypeError(RETRY_MESSAGE_EXPECTATION);
|
|
2211
2172
|
async function handle() {
|
|
2212
|
-
const
|
|
2213
|
-
if (
|
|
2214
|
-
resolver(
|
|
2173
|
+
const attempted = await asyncAttempt(async () => callback());
|
|
2174
|
+
if (attempted.ok) {
|
|
2175
|
+
resolver(attempted.value);
|
|
2215
2176
|
return;
|
|
2216
2177
|
}
|
|
2217
|
-
if (attempts >= times || !when(
|
|
2178
|
+
if (attempts >= times || !when(attempted.error)) rejector(new RetryError(RETRY_MESSAGE_FAILED, attempted.error));
|
|
2218
2179
|
else {
|
|
2219
2180
|
attempts += 1;
|
|
2220
2181
|
limiter.run();
|
|
@@ -2251,10 +2212,10 @@ function retry(callback, options) {
|
|
|
2251
2212
|
const { times, when } = createRetryOptions(options);
|
|
2252
2213
|
let last;
|
|
2253
2214
|
for (let index = 0; index <= times; index += 1) {
|
|
2254
|
-
const
|
|
2255
|
-
if (
|
|
2256
|
-
if (index >= times || !when(
|
|
2257
|
-
last =
|
|
2215
|
+
const attempted = attempt(callback);
|
|
2216
|
+
if (attempted.ok) return attempted.value;
|
|
2217
|
+
if (index >= times || !when(attempted.error)) {
|
|
2218
|
+
last = attempted.error;
|
|
2258
2219
|
break;
|
|
2259
2220
|
}
|
|
2260
2221
|
}
|
|
@@ -2264,13 +2225,11 @@ function shouldRetry() {
|
|
|
2264
2225
|
return true;
|
|
2265
2226
|
}
|
|
2266
2227
|
retry.async = asyncRetry;
|
|
2267
|
-
|
|
2268
|
-
//#region src/models/function/memoize.model.ts
|
|
2228
|
+
// src/models/function/memoize.model.ts
|
|
2269
2229
|
const MEMOIZED_CACHE_SIZE_DEFAULT = 1024;
|
|
2270
2230
|
const MEMOIZED_CALLBACK = "Memoized requires a callback function";
|
|
2271
2231
|
const MEMOIZED_SYMBOL = Symbol("memoized");
|
|
2272
|
-
|
|
2273
|
-
//#region src/models/misc.model.ts
|
|
2232
|
+
// src/models/misc.model.ts
|
|
2274
2233
|
const EXPRESSION_INTEGER = /^\d+$/;
|
|
2275
2234
|
const EXPRESSION_NUMBER_BINARY = /^0b[01]+$/i;
|
|
2276
2235
|
const EXPRESSION_NUMBER_OCTAL = /^0o[0-7]+$/i;
|
|
@@ -2278,8 +2237,7 @@ const EXPRESSION_NUMBER_ZEROISH = /^\s*0+\s*$/;
|
|
|
2278
2237
|
const EXPRESSION_NUMERICAL_PREFIX = /^\d/;
|
|
2279
2238
|
const EXPRESSION_WHITESPACE_MULTIPLE = /\s+/g;
|
|
2280
2239
|
const EXPRESSION_WHITESPACE_ONLY = /^\s*$/;
|
|
2281
|
-
|
|
2282
|
-
//#region src/internal/number.ts
|
|
2240
|
+
// src/internal/number.ts
|
|
2283
2241
|
/**
|
|
2284
2242
|
* Is the number between a minimum and maximum value?
|
|
2285
2243
|
*
|
|
@@ -2363,8 +2321,7 @@ function getNumber(value) {
|
|
|
2363
2321
|
if (isBinary || EXPRESSION_NUMBER_OCTAL.test(trimmed)) return Number.parseInt(trimmed.slice(2), isBinary ? 2 : 8);
|
|
2364
2322
|
return Number(trimmed);
|
|
2365
2323
|
}
|
|
2366
|
-
|
|
2367
|
-
//#region src/internal/sized/misc.ts
|
|
2324
|
+
// src/internal/sized/misc.ts
|
|
2368
2325
|
function getSizedMaximum(first, second) {
|
|
2369
2326
|
let actual;
|
|
2370
2327
|
if (typeof first === "number") actual = first;
|
|
@@ -2373,8 +2330,7 @@ function getSizedMaximum(first, second) {
|
|
|
2373
2330
|
}
|
|
2374
2331
|
const SIZED_MAXIMUM_ABSOLUTE = 16777216;
|
|
2375
2332
|
const SIZED_MAXIMUM_DEFAULT = 1048576;
|
|
2376
|
-
|
|
2377
|
-
//#region src/internal/sized/map.ts
|
|
2333
|
+
// src/internal/sized/map.ts
|
|
2378
2334
|
/**
|
|
2379
2335
|
* A _Map_ with a maximum size
|
|
2380
2336
|
*
|
|
@@ -2391,6 +2347,9 @@ var SizedMap = class extends Map {
|
|
|
2391
2347
|
get full() {
|
|
2392
2348
|
return super.size >= this.#maximumSize;
|
|
2393
2349
|
}
|
|
2350
|
+
/**
|
|
2351
|
+
* The maximum size of the _Map_
|
|
2352
|
+
*/
|
|
2394
2353
|
get maximum() {
|
|
2395
2354
|
return this.#maximumSize;
|
|
2396
2355
|
}
|
|
@@ -2428,8 +2387,7 @@ var SizedMap = class extends Map {
|
|
|
2428
2387
|
return this;
|
|
2429
2388
|
}
|
|
2430
2389
|
};
|
|
2431
|
-
|
|
2432
|
-
//#region src/internal/function/memoize.ts
|
|
2390
|
+
// src/internal/function/memoize.ts
|
|
2433
2391
|
function Memoized(callback, options) {
|
|
2434
2392
|
this[MEMOIZED_SYMBOL] = {
|
|
2435
2393
|
options,
|
|
@@ -2501,8 +2459,7 @@ function memoize(callback, options) {
|
|
|
2501
2459
|
function runMemoized(...parameters) {
|
|
2502
2460
|
return this[MEMOIZED_SYMBOL].getter(...parameters);
|
|
2503
2461
|
}
|
|
2504
|
-
|
|
2505
|
-
//#region src/models/function/work.model.ts
|
|
2462
|
+
// src/models/function/work.model.ts
|
|
2506
2463
|
const WORK_MESSAGE_FLOW_ARRAY = "Flow expected to receive an array of functions";
|
|
2507
2464
|
const WORK_MESSAGE_FLOW_PROMISE = "Synchronous Flow received a promise. Use `flow.async` instead.";
|
|
2508
2465
|
const WORK_MESSAGE_NESTING = "Return values are too deeply nested.";
|
|
@@ -2510,21 +2467,14 @@ const WORK_MESSAGE_PIPE_ARRAY = "Pipe expected to receive an array of functions"
|
|
|
2510
2467
|
const WORK_MESSAGE_PIPE_PROMISE = "Synchronous Pipe received a promise. Use `pipe.async` instead.";
|
|
2511
2468
|
const assertFlowFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_FLOW_ARRAY, TypeError);
|
|
2512
2469
|
const assertPipeFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_PIPE_ARRAY, TypeError);
|
|
2513
|
-
|
|
2514
|
-
//#region src/internal/function/work.ts
|
|
2470
|
+
// src/internal/function/work.ts
|
|
2515
2471
|
function asyncFlow(...fns) {
|
|
2516
2472
|
assertFlowFunctions(fns);
|
|
2517
|
-
return (...args) => asyncWork(args.map(
|
|
2518
|
-
if (isError(value)) throw value.error;
|
|
2519
|
-
return isOk(value) ? value.value : value;
|
|
2520
|
-
}), fns, true);
|
|
2473
|
+
return (...args) => asyncWork(args.map(unwrapWork), fns, true);
|
|
2521
2474
|
}
|
|
2522
2475
|
function flow(...fns) {
|
|
2523
2476
|
assertFlowFunctions(fns);
|
|
2524
|
-
return (...args) => work(args.map(
|
|
2525
|
-
if (isError(value)) throw value.error;
|
|
2526
|
-
return isOk(value) ? value.value : value;
|
|
2527
|
-
}), fns, true);
|
|
2477
|
+
return (...args) => work(args.map(unwrapWork), fns, true);
|
|
2528
2478
|
}
|
|
2529
2479
|
async function asyncPipe(value, ...pipes) {
|
|
2530
2480
|
assertPipeFunctions(pipes);
|
|
@@ -2549,8 +2499,7 @@ function unwrapValue(value, flow, nested) {
|
|
|
2549
2499
|
return unwrapValue(value(), flow, true);
|
|
2550
2500
|
}
|
|
2551
2501
|
if (flow != null && value instanceof Promise) throw new TypeError(flow ? WORK_MESSAGE_FLOW_PROMISE : WORK_MESSAGE_PIPE_PROMISE);
|
|
2552
|
-
|
|
2553
|
-
return isOk(value) ? value.value : value;
|
|
2502
|
+
return unwrapWork(value);
|
|
2554
2503
|
}
|
|
2555
2504
|
function work(initial, functions, flow) {
|
|
2556
2505
|
const { length } = functions;
|
|
@@ -2563,8 +2512,7 @@ function work(initial, functions, flow) {
|
|
|
2563
2512
|
}
|
|
2564
2513
|
flow.async = asyncFlow;
|
|
2565
2514
|
pipe.async = asyncPipe;
|
|
2566
|
-
|
|
2567
|
-
//#region src/models/string/string.case.model.ts
|
|
2515
|
+
// src/models/string/string.case.model.ts
|
|
2568
2516
|
const STRING_CASE_CAMEL = "camel";
|
|
2569
2517
|
const STRING_CASE_CAPITALIZE = "capitalize";
|
|
2570
2518
|
const STRING_CASE_KEBAB = "kebab";
|
|
@@ -2577,8 +2525,7 @@ const STRING_EXPRESSION_CAMEL_CASE = /(\p{Ll})(\p{Lu})/gu;
|
|
|
2577
2525
|
const STRING_EXPRESSION_ACRONYM = /(?<=\p{Lu})(?=\p{Lu}\p{Ll})(?!\p{Lu}s(?!\p{Ll}))/gu;
|
|
2578
2526
|
const STRING_REPLACEMENT_CAMEL_CASE = "$1-$2";
|
|
2579
2527
|
const ignoreCachingCases = /* @__PURE__ */ new Set(["lower", "upper"]);
|
|
2580
|
-
|
|
2581
|
-
//#region src/internal/string/case.ts
|
|
2528
|
+
// src/internal/string/case.ts
|
|
2582
2529
|
/**
|
|
2583
2530
|
* Convert a string to camel case _(thisIsCamelCase)_
|
|
2584
2531
|
*
|
|
@@ -2771,13 +2718,11 @@ const delimiters = {
|
|
|
2771
2718
|
[STRING_CASE_SNAKE]: "_"
|
|
2772
2719
|
};
|
|
2773
2720
|
const simpleMemoizers = {};
|
|
2774
|
-
|
|
2775
|
-
//#region src/models/value/value.equal.model.ts
|
|
2721
|
+
// src/models/value/value.equal.model.ts
|
|
2776
2722
|
const EQUAL_ERROR_PROPERTIES = ["name", "message"];
|
|
2777
2723
|
const EQUAL_EXPRESSION_PROPERTIES = ["source", "flags"];
|
|
2778
2724
|
const EQUAL_SYMBOL = Symbol("equal");
|
|
2779
|
-
|
|
2780
|
-
//#region src/internal/value/equal.ts
|
|
2725
|
+
// src/internal/value/equal.ts
|
|
2781
2726
|
function Equalizer(options) {
|
|
2782
2727
|
this[EQUAL_SYMBOL] = options;
|
|
2783
2728
|
}
|
|
@@ -2950,13 +2895,11 @@ equal.deregister = deregisterEqualizer;
|
|
|
2950
2895
|
equal.handler = equalHandler;
|
|
2951
2896
|
equal.initialize = initializeEqualizer;
|
|
2952
2897
|
equal.register = registerEqualizer;
|
|
2953
|
-
|
|
2954
|
-
//#region src/internal/value/get.ts
|
|
2898
|
+
// src/internal/value/get.ts
|
|
2955
2899
|
function getValue(data, path, ignoreCase) {
|
|
2956
2900
|
return getNestedValue(data, path, ignoreCase === true).value;
|
|
2957
2901
|
}
|
|
2958
|
-
|
|
2959
|
-
//#region src/internal/value/set.ts
|
|
2902
|
+
// src/internal/value/set.ts
|
|
2960
2903
|
function setValue(data, path, value, ignoreCase) {
|
|
2961
2904
|
if (typeof data !== "object" || data === null || typeof path !== "string" || path.trim().length === 0) return data;
|
|
2962
2905
|
const shouldIgnoreCase = ignoreCase === true;
|
|
@@ -2985,8 +2928,7 @@ function setValue(data, path, value, ignoreCase) {
|
|
|
2985
2928
|
}
|
|
2986
2929
|
return data;
|
|
2987
2930
|
}
|
|
2988
|
-
|
|
2989
|
-
//#region src/models/plan.model.ts
|
|
2931
|
+
// src/models/plan.model.ts
|
|
2990
2932
|
const GENERATOR_FUNCTION_TYPE_ASYNC = "[object AsyncGeneratorFunction]";
|
|
2991
2933
|
const GENERATOR_FUNCTION_TYPE_SYNC = "[object GeneratorFunction]";
|
|
2992
2934
|
const GENERATOR_TYPE_ASYNC = "[object AsyncGenerator]";
|
|
@@ -3004,12 +2946,10 @@ const PLAN_SUCCESS_SYNC = "success";
|
|
|
3004
2946
|
const PLAN_SYMBOL = Symbol("plan");
|
|
3005
2947
|
const PLAN_TYPE_ASYNC = "asyncPlan";
|
|
3006
2948
|
const PLAN_TYPE_SYNC = "plan";
|
|
3007
|
-
|
|
3008
|
-
//#region src/models/aborter.model.ts
|
|
2949
|
+
// src/models/aborter.model.ts
|
|
3009
2950
|
const ABORTER_EVENT = "abort";
|
|
3010
2951
|
const ABORTER_OPTIONS = { once: true };
|
|
3011
|
-
|
|
3012
|
-
//#region src/internal/aborter.ts
|
|
2952
|
+
// src/internal/aborter.ts
|
|
3013
2953
|
function createAborter(value, onAbort) {
|
|
3014
2954
|
if (!(value instanceof AbortSignal)) return;
|
|
3015
2955
|
value.addEventListener(ABORTER_EVENT, onAbort, ABORTER_OPTIONS);
|
|
@@ -3019,8 +2959,19 @@ function createAborter(value, onAbort) {
|
|
|
3019
2959
|
cancel: () => value.removeEventListener(ABORTER_EVENT, onAbort)
|
|
3020
2960
|
};
|
|
3021
2961
|
}
|
|
3022
|
-
|
|
3023
|
-
|
|
2962
|
+
// src/internal/plan/plan.generate.ts
|
|
2963
|
+
async function asyncCleanup(generator, input) {
|
|
2964
|
+
try {
|
|
2965
|
+
const returned = await generator.return(input);
|
|
2966
|
+
if (returned.done) return;
|
|
2967
|
+
let cleanupValue = returned.value;
|
|
2968
|
+
while (true) {
|
|
2969
|
+
const { done, value } = await generator.next(cleanupValue);
|
|
2970
|
+
if (done) break;
|
|
2971
|
+
cleanupValue = value;
|
|
2972
|
+
}
|
|
2973
|
+
} catch {}
|
|
2974
|
+
}
|
|
3024
2975
|
async function asyncGenerate(input, unwrap, first, second) {
|
|
3025
2976
|
const aborter = createAborter(second ?? first, noop);
|
|
3026
2977
|
if (aborter?.signal.aborted) throw aborter.signal.reason;
|
|
@@ -3028,57 +2979,90 @@ async function asyncGenerate(input, unwrap, first, second) {
|
|
|
3028
2979
|
let generator;
|
|
3029
2980
|
if (typeof input === "function") generator = input(...parameters);
|
|
3030
2981
|
else generator = input.generator(...parameters);
|
|
2982
|
+
let aborted = false;
|
|
3031
2983
|
let success = true;
|
|
2984
|
+
let throwing = false;
|
|
2985
|
+
let lastError;
|
|
3032
2986
|
let lastValue;
|
|
3033
2987
|
try {
|
|
3034
2988
|
while (true) {
|
|
3035
|
-
if (aborter?.signal.aborted)
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
2989
|
+
if (aborter?.signal.aborted) {
|
|
2990
|
+
if (aborted) break;
|
|
2991
|
+
aborted = true;
|
|
2992
|
+
lastError = aborter.signal.reason;
|
|
2993
|
+
throwing = true;
|
|
2994
|
+
}
|
|
2995
|
+
const { done, value } = await asyncResume(generator, throwing ? lastError : lastValue, throwing);
|
|
2996
|
+
if (value instanceof Error || isError(value)) {
|
|
2997
|
+
const errorValue = value instanceof Error ? value : value.error;
|
|
2998
|
+
if (done) throw errorValue;
|
|
2999
|
+
lastError = errorValue;
|
|
3000
|
+
lastValue = void 0;
|
|
3001
|
+
throwing = true;
|
|
3002
|
+
continue;
|
|
3003
|
+
}
|
|
3004
|
+
lastError = void 0;
|
|
3041
3005
|
lastValue = value;
|
|
3042
|
-
|
|
3006
|
+
throwing = false;
|
|
3007
|
+
if (done) break;
|
|
3043
3008
|
}
|
|
3044
3009
|
} catch (error) {
|
|
3045
|
-
|
|
3010
|
+
lastError = error;
|
|
3046
3011
|
success = false;
|
|
3047
3012
|
} finally {
|
|
3048
3013
|
aborter?.cancel();
|
|
3049
|
-
await generator
|
|
3014
|
+
await asyncCleanup(generator, lastValue);
|
|
3050
3015
|
}
|
|
3051
3016
|
if (aborter?.signal.aborted) throw aborter.signal.reason;
|
|
3052
3017
|
if (success) return unwrap && isOk(lastValue) ? lastValue.value : lastValue;
|
|
3053
|
-
throw
|
|
3018
|
+
throw lastError;
|
|
3019
|
+
}
|
|
3020
|
+
async function asyncResume(generator, input, throwing) {
|
|
3021
|
+
const { done, value } = await (throwing ? generator.throw(input) : generator.next(input));
|
|
3022
|
+
return {
|
|
3023
|
+
value,
|
|
3024
|
+
done: done === true
|
|
3025
|
+
};
|
|
3054
3026
|
}
|
|
3055
3027
|
function generate(input, parameters, unwrap) {
|
|
3056
3028
|
let generator;
|
|
3057
3029
|
if (typeof input === "function") generator = input(...parameters);
|
|
3058
3030
|
else generator = input.generator(...parameters);
|
|
3059
3031
|
let success = true;
|
|
3032
|
+
let throwing = false;
|
|
3033
|
+
let lastError;
|
|
3060
3034
|
let lastValue;
|
|
3061
3035
|
try {
|
|
3062
3036
|
while (true) {
|
|
3063
|
-
const
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3037
|
+
const { done, value } = resume(generator, throwing ? lastError : lastValue, throwing);
|
|
3038
|
+
if (value instanceof Error || isError(value)) {
|
|
3039
|
+
const errorValue = value instanceof Error ? value : value.error;
|
|
3040
|
+
if (done) throw errorValue;
|
|
3041
|
+
lastError = errorValue;
|
|
3042
|
+
lastValue = void 0;
|
|
3043
|
+
throwing = true;
|
|
3044
|
+
continue;
|
|
3045
|
+
}
|
|
3046
|
+
lastError = void 0;
|
|
3068
3047
|
lastValue = value;
|
|
3048
|
+
throwing = false;
|
|
3069
3049
|
if (done) break;
|
|
3070
3050
|
}
|
|
3071
3051
|
} catch (error) {
|
|
3072
|
-
|
|
3052
|
+
lastError = error;
|
|
3073
3053
|
success = false;
|
|
3074
|
-
} finally {
|
|
3075
|
-
generator.return(lastValue);
|
|
3076
3054
|
}
|
|
3077
3055
|
if (success) return unwrap && isOk(lastValue) ? lastValue.value : lastValue;
|
|
3078
|
-
throw
|
|
3056
|
+
throw lastError;
|
|
3079
3057
|
}
|
|
3080
|
-
|
|
3081
|
-
|
|
3058
|
+
function resume(generator, input, throwing) {
|
|
3059
|
+
const { done, value } = throwing ? generator.throw(input) : generator.next(input);
|
|
3060
|
+
return {
|
|
3061
|
+
value,
|
|
3062
|
+
done: done === true
|
|
3063
|
+
};
|
|
3064
|
+
}
|
|
3065
|
+
// src/internal/plan/index.ts
|
|
3082
3066
|
function attemptRunPlan(...parameters) {
|
|
3083
3067
|
return attempt(() => generate(this[PLAN_SYMBOL], parameters, true));
|
|
3084
3068
|
}
|
|
@@ -3091,8 +3075,7 @@ function runAsyncPlan(first, second) {
|
|
|
3091
3075
|
function runPlan(...parameters) {
|
|
3092
3076
|
return generate(this[PLAN_SYMBOL], parameters, false);
|
|
3093
3077
|
}
|
|
3094
|
-
|
|
3095
|
-
//#region src/plan/is.ts
|
|
3078
|
+
// src/plan/is.ts
|
|
3096
3079
|
/**
|
|
3097
3080
|
* Is the value an asynchronous, immediately failing plan?
|
|
3098
3081
|
*
|
|
@@ -3207,8 +3190,7 @@ function isStep(value) {
|
|
|
3207
3190
|
function isSuccess(value) {
|
|
3208
3191
|
return isPlanInstance(PLAN_SUCCESS_SYNC, value);
|
|
3209
3192
|
}
|
|
3210
|
-
|
|
3211
|
-
//#region src/plan/result.ts
|
|
3193
|
+
// src/plan/result.ts
|
|
3212
3194
|
function asyncAttemptRun(input, first, second) {
|
|
3213
3195
|
let generator;
|
|
3214
3196
|
if (isAsyncPlan(input)) generator = input[PLAN_SYMBOL];
|
|
@@ -3224,8 +3206,7 @@ function attemptRun(input, ...parameters) {
|
|
|
3224
3206
|
return attempt(() => generate(generator, parameters, true));
|
|
3225
3207
|
}
|
|
3226
3208
|
attemptRun.async = asyncAttemptRun;
|
|
3227
|
-
|
|
3228
|
-
//#region src/plan/index.ts
|
|
3209
|
+
// src/plan/index.ts
|
|
3229
3210
|
function AsyncPlan(generator) {
|
|
3230
3211
|
this[PLAN_SYMBOL] = {
|
|
3231
3212
|
generator,
|
|
@@ -3252,8 +3233,7 @@ function plan(generator) {
|
|
|
3252
3233
|
if (isGeneratorFunction(generator)) return new Plan(generator);
|
|
3253
3234
|
throw new Error(PLAN_MESSAGE_PLAN_INPUT);
|
|
3254
3235
|
}
|
|
3255
|
-
|
|
3256
|
-
//#region src/plan/misc.ts
|
|
3236
|
+
// src/plan/misc.ts
|
|
3257
3237
|
function AsyncFailure(generator) {
|
|
3258
3238
|
this[PLAN_SYMBOL] = {
|
|
3259
3239
|
generator,
|
|
@@ -3304,8 +3284,7 @@ function succeed(value) {
|
|
|
3304
3284
|
}
|
|
3305
3285
|
fail.async = asyncFail;
|
|
3306
3286
|
succeed.async = asyncSucceed;
|
|
3307
|
-
|
|
3308
|
-
//#region src/plan/run.ts
|
|
3287
|
+
// src/plan/run.ts
|
|
3309
3288
|
function asyncRun(input, first, second) {
|
|
3310
3289
|
if (isAsyncPlan(input)) return asyncGenerate(input[PLAN_SYMBOL], false, first, second);
|
|
3311
3290
|
if (isAsyncGeneratorFunction(input)) return asyncGenerate(input, false, first, second);
|
|
@@ -3319,8 +3298,7 @@ function run(input, ...parameters) {
|
|
|
3319
3298
|
asyncRun.attempt = asyncAttemptRun;
|
|
3320
3299
|
run.async = asyncRun;
|
|
3321
3300
|
run.attempt = attemptRun;
|
|
3322
|
-
|
|
3323
|
-
//#region src/plan/use.ts
|
|
3301
|
+
// src/plan/use.ts
|
|
3324
3302
|
function AsyncStep(generator) {
|
|
3325
3303
|
this[PLAN_SYMBOL] = {
|
|
3326
3304
|
generator,
|
|
@@ -3336,7 +3314,10 @@ function Step(generator) {
|
|
|
3336
3314
|
}
|
|
3337
3315
|
Step.prototype[Symbol.iterator] = getGenerator;
|
|
3338
3316
|
function asyncUse(value) {
|
|
3339
|
-
return new AsyncStep(
|
|
3317
|
+
return new AsyncStep(getAsyncUseStep(value));
|
|
3318
|
+
}
|
|
3319
|
+
function getAsyncUseStep(value) {
|
|
3320
|
+
return async function* () {
|
|
3340
3321
|
let actual = value;
|
|
3341
3322
|
if (typeof actual === "function") actual = actual();
|
|
3342
3323
|
actual = await actual;
|
|
@@ -3353,11 +3334,10 @@ function asyncUse(value) {
|
|
|
3353
3334
|
return;
|
|
3354
3335
|
}
|
|
3355
3336
|
return actual;
|
|
3356
|
-
}
|
|
3337
|
+
};
|
|
3357
3338
|
}
|
|
3358
|
-
function
|
|
3359
|
-
|
|
3360
|
-
return new Step(function* () {
|
|
3339
|
+
function getUseStep(value) {
|
|
3340
|
+
return function* () {
|
|
3361
3341
|
let actual = value;
|
|
3362
3342
|
if (typeof actual === "function") {
|
|
3363
3343
|
actual = actual();
|
|
@@ -3375,15 +3355,18 @@ function use(value) {
|
|
|
3375
3355
|
return;
|
|
3376
3356
|
}
|
|
3377
3357
|
return actual;
|
|
3378
|
-
}
|
|
3358
|
+
};
|
|
3359
|
+
}
|
|
3360
|
+
function use(value) {
|
|
3361
|
+
validateUseInput(value, false);
|
|
3362
|
+
return new Step(getUseStep(value));
|
|
3379
3363
|
}
|
|
3380
3364
|
function validateUseInput(value, resolved) {
|
|
3381
3365
|
if (value instanceof Promise || isAsyncFailure(value) || isAsyncGenerator(value) || isAsyncGeneratorFunction(value) || isAsyncPlan(value) || isAsyncStep(value) || isAsyncSuccess(value)) throw new Error(PLAN_MESSAGE_USE_SYNC_ASYNC);
|
|
3382
3366
|
if (resolved && typeof value === "function") throw new Error(PLAN_MESSAGE_USE_NESTED_FN);
|
|
3383
3367
|
}
|
|
3384
3368
|
use.async = asyncUse;
|
|
3385
|
-
|
|
3386
|
-
//#region src/models/promise.model.ts
|
|
3369
|
+
// src/models/promise.model.ts
|
|
3387
3370
|
/**
|
|
3388
3371
|
* A _Promise_ that can be canceled
|
|
3389
3372
|
*/
|
|
@@ -3410,13 +3393,13 @@ var CancelablePromise = class extends Promise {
|
|
|
3410
3393
|
/**
|
|
3411
3394
|
* An error thrown when a promise times out
|
|
3412
3395
|
*/
|
|
3413
|
-
var
|
|
3396
|
+
var TimedError = class extends Error {
|
|
3414
3397
|
constructor() {
|
|
3415
3398
|
super(PROMISE_MESSAGE_TIMEOUT);
|
|
3416
3399
|
this.name = PROMISE_ERROR_NAME;
|
|
3417
3400
|
}
|
|
3418
3401
|
};
|
|
3419
|
-
const PROMISE_ERROR_NAME = "
|
|
3402
|
+
const PROMISE_ERROR_NAME = "TimedError";
|
|
3420
3403
|
const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
3421
3404
|
const PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE = "promises expected an array or object holding promise-functions or promises";
|
|
3422
3405
|
const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
@@ -3426,8 +3409,7 @@ const PROMISE_STRATEGY_ALL = /* @__PURE__ */ new Set(["complete", "first"]);
|
|
|
3426
3409
|
const PROMISE_STRATEGY_DEFAULT = "complete";
|
|
3427
3410
|
const PROMISE_TYPE_FULFILLED = "fulfilled";
|
|
3428
3411
|
const PROMISE_TYPE_REJECTED = "rejected";
|
|
3429
|
-
|
|
3430
|
-
//#region src/promise/helpers.ts
|
|
3412
|
+
// src/promise/helpers.ts
|
|
3431
3413
|
function createPromiseOptions(input) {
|
|
3432
3414
|
if (typeof input === "number") return { time: getNumberOrDefault(input, 0) };
|
|
3433
3415
|
if (input instanceof AbortSignal) return {
|
|
@@ -3487,8 +3469,7 @@ function isPromiseResult(value, type) {
|
|
|
3487
3469
|
function isRejected(value) {
|
|
3488
3470
|
return isPromiseResult(value, PROMISE_TYPE_REJECTED);
|
|
3489
3471
|
}
|
|
3490
|
-
|
|
3491
|
-
//#region src/promise/misc.ts
|
|
3472
|
+
// src/promise/misc.ts
|
|
3492
3473
|
/**
|
|
3493
3474
|
* Create a cancelable _Promise_
|
|
3494
3475
|
*
|
|
@@ -3536,8 +3517,7 @@ async function toResult(value) {
|
|
|
3536
3517
|
if (!(actual instanceof Promise)) throw new TypeError(PROMISE_MESSAGE_EXPECTATION_RESULT);
|
|
3537
3518
|
return actual.then((result) => ok(result)).catch((reason) => error(reason));
|
|
3538
3519
|
}
|
|
3539
|
-
|
|
3540
|
-
//#region src/promise/delay.ts
|
|
3520
|
+
// src/promise/delay.ts
|
|
3541
3521
|
function delay(options) {
|
|
3542
3522
|
const { signal, time } = createPromiseOptions(options);
|
|
3543
3523
|
if (signal?.aborted ?? false) return Promise.reject(signal?.reason);
|
|
@@ -3555,8 +3535,7 @@ function delay(options) {
|
|
|
3555
3535
|
else limiter.run();
|
|
3556
3536
|
});
|
|
3557
3537
|
}
|
|
3558
|
-
|
|
3559
|
-
//#region src/promise/timed.ts
|
|
3538
|
+
// src/promise/timed.ts
|
|
3560
3539
|
/**
|
|
3561
3540
|
* @internal
|
|
3562
3541
|
*/
|
|
@@ -3565,7 +3544,7 @@ async function getTimedPromise(promise, time, signal) {
|
|
|
3565
3544
|
limiter.cancel();
|
|
3566
3545
|
rejector(signal?.reason);
|
|
3567
3546
|
});
|
|
3568
|
-
const limiter = getLimiter(LIMITER_WAIT, () => settlePromise(rejector, new
|
|
3547
|
+
const limiter = getLimiter(LIMITER_WAIT, () => settlePromise(rejector, new TimedError(), aborter), time);
|
|
3569
3548
|
let rejector;
|
|
3570
3549
|
return Promise.race([promise, new Promise((_, reject) => {
|
|
3571
3550
|
rejector = reject;
|
|
@@ -3583,8 +3562,7 @@ async function timed(promise, options) {
|
|
|
3583
3562
|
if (signal?.aborted ?? false) throw signal?.reason;
|
|
3584
3563
|
return time > 0 ? getTimedPromise(promise, time, signal) : promise;
|
|
3585
3564
|
}
|
|
3586
|
-
|
|
3587
|
-
//#region src/promise/index.ts
|
|
3565
|
+
// src/promise/index.ts
|
|
3588
3566
|
async function attemptPromise(value, options) {
|
|
3589
3567
|
const isFunction = typeof value === "function";
|
|
3590
3568
|
if (!isFunction && !(value instanceof Promise)) throw new TypeError(PROMISE_MESSAGE_EXPECTATION_ATTEMPT);
|
|
@@ -3594,13 +3572,13 @@ async function attemptPromise(value, options) {
|
|
|
3594
3572
|
rejector(signal?.reason);
|
|
3595
3573
|
});
|
|
3596
3574
|
async function handler(resolve, reject) {
|
|
3597
|
-
const
|
|
3575
|
+
const attempted = await asyncAttempt(async () => {
|
|
3598
3576
|
let result = isFunction ? value() : await value;
|
|
3599
3577
|
if (result instanceof Promise) result = await result;
|
|
3600
3578
|
return result;
|
|
3601
3579
|
});
|
|
3602
|
-
if (
|
|
3603
|
-
else settlePromise(reject,
|
|
3580
|
+
if (attempted.ok) settlePromise(resolve, attempted.value, aborter);
|
|
3581
|
+
else settlePromise(reject, attempted.error, aborter);
|
|
3604
3582
|
}
|
|
3605
3583
|
let rejector;
|
|
3606
3584
|
const promise = new Promise((resolve, reject) => {
|
|
@@ -3654,8 +3632,7 @@ async function resultPromises(items, signal) {
|
|
|
3654
3632
|
return promises(items, signal).then(getResultsFromPromises);
|
|
3655
3633
|
}
|
|
3656
3634
|
promises.result = resultPromises;
|
|
3657
|
-
|
|
3658
|
-
//#region src/result/match.ts
|
|
3635
|
+
// src/result/match.ts
|
|
3659
3636
|
async function asyncMatchResult(result, first, second) {
|
|
3660
3637
|
let value;
|
|
3661
3638
|
if (typeof result === "function") value = await result();
|
|
@@ -3690,31 +3667,23 @@ const MATCH_MESSAGE_ERROR = "`result.match` expected an Error callback";
|
|
|
3690
3667
|
const MATCH_MESSAGE_OK = "`result.match` expected an Ok callback";
|
|
3691
3668
|
const MATCH_MESSAGE_RESULT = "`result.match` expected a Result or a function that returns a Result";
|
|
3692
3669
|
matchResult.async = asyncMatchResult;
|
|
3693
|
-
|
|
3694
|
-
//#region src/result/work/flow.ts
|
|
3670
|
+
// src/result/work/flow.ts
|
|
3695
3671
|
function attemptAsyncFlow(...fns) {
|
|
3696
3672
|
let Flow;
|
|
3697
3673
|
return (...args) => asyncAttempt(() => {
|
|
3698
3674
|
Flow ??= asyncFlow(...fns);
|
|
3699
|
-
return Flow(...args.map(
|
|
3700
|
-
if (isError(value)) throw value.error;
|
|
3701
|
-
return isOk(value) ? value.value : value;
|
|
3702
|
-
}));
|
|
3675
|
+
return Flow(...args.map(unwrapWork));
|
|
3703
3676
|
});
|
|
3704
3677
|
}
|
|
3705
3678
|
function attemptFlow(...fns) {
|
|
3706
3679
|
let Flow;
|
|
3707
3680
|
return (...args) => attempt(() => {
|
|
3708
3681
|
Flow ??= flow(...fns);
|
|
3709
|
-
return Flow(...args.map(
|
|
3710
|
-
if (isError(value)) throw value.error;
|
|
3711
|
-
return isOk(value) ? value.value : value;
|
|
3712
|
-
}));
|
|
3682
|
+
return Flow(...args.map(unwrapWork));
|
|
3713
3683
|
});
|
|
3714
3684
|
}
|
|
3715
3685
|
attemptFlow.async = attemptAsyncFlow;
|
|
3716
|
-
|
|
3717
|
-
//#region src/result/work/pipe.ts
|
|
3686
|
+
// src/result/work/pipe.ts
|
|
3718
3687
|
async function attemptAsyncPipe(initial, first, ...seconds) {
|
|
3719
3688
|
return asyncAttempt(async () => {
|
|
3720
3689
|
if (isError(initial)) throw initial.error;
|
|
@@ -3736,19 +3705,15 @@ function attemptPipe(initial, first, ...seconds) {
|
|
|
3736
3705
|
});
|
|
3737
3706
|
}
|
|
3738
3707
|
attemptPipe.async = attemptAsyncPipe;
|
|
3739
|
-
|
|
3740
|
-
//#region src/models/string/string.fuzzy.model.ts
|
|
3708
|
+
// src/models/string/string.fuzzy.model.ts
|
|
3741
3709
|
const FUZZY_BOUNDARY_SEPARATOR = /[\s./:\\_-]/;
|
|
3742
3710
|
const FUZZY_MESSAGE_ARRAY = "Fuzzy requires an array of items";
|
|
3743
3711
|
const FUZZY_MESSAGE_HANDLER = "Fuzzy requires a key or function to stringify items";
|
|
3744
|
-
const
|
|
3745
|
-
|
|
3746
|
-
//#endregion
|
|
3747
|
-
//#region src/string/fuzzy.ts
|
|
3712
|
+
const FUZZY_SYMBOL = Symbol("fuzzy");
|
|
3713
|
+
// src/string/fuzzy.ts
|
|
3748
3714
|
function Fuzzy(state) {
|
|
3749
3715
|
this[FUZZY_SYMBOL] = state;
|
|
3750
3716
|
}
|
|
3751
|
-
Fuzzy.prototype[FUZZY_PROPERTY] = true;
|
|
3752
3717
|
Fuzzy.prototype.search = search;
|
|
3753
3718
|
Object.defineProperties(Fuzzy.prototype, {
|
|
3754
3719
|
items: {
|
|
@@ -3956,7 +3921,7 @@ function isBoundary(string, index) {
|
|
|
3956
3921
|
* @returns `true` if the value is a fuzzy searcher, otherwise `false`
|
|
3957
3922
|
*/
|
|
3958
3923
|
function isFuzzy(value) {
|
|
3959
|
-
return typeof value === "object" && value !== null &&
|
|
3924
|
+
return typeof value === "object" && value !== null && FUZZY_SYMBOL in value;
|
|
3960
3925
|
}
|
|
3961
3926
|
function search(input, option) {
|
|
3962
3927
|
const state = this[FUZZY_SYMBOL];
|
|
@@ -4002,8 +3967,7 @@ function setItems(value) {
|
|
|
4002
3967
|
let defaultSorter;
|
|
4003
3968
|
fuzzy.is = isFuzzy;
|
|
4004
3969
|
fuzzy.match = fuzzyMatch;
|
|
4005
|
-
|
|
4006
|
-
//#region src/string/index.ts
|
|
3970
|
+
// src/string/index.ts
|
|
4007
3971
|
function dedent(value, ...values) {
|
|
4008
3972
|
let actual;
|
|
4009
3973
|
if (isTemplateStringsArray(value)) actual = interpolate(value, values);
|
|
@@ -4106,8 +4070,7 @@ function truncate(value, length, suffix) {
|
|
|
4106
4070
|
const truncatedLength = length - actualSuffixLength;
|
|
4107
4071
|
return `${value.slice(0, truncatedLength)}${actualSuffix}`;
|
|
4108
4072
|
}
|
|
4109
|
-
|
|
4110
|
-
//#region src/string/match.ts
|
|
4073
|
+
// src/string/match.ts
|
|
4111
4074
|
/**
|
|
4112
4075
|
* Check if a string ends with a specified substring
|
|
4113
4076
|
*
|
|
@@ -4174,8 +4137,7 @@ function startsWith(haystack, needle, ignoreCase) {
|
|
|
4174
4137
|
return match(STRING_MATCH_STARTS_WITH, haystack, needle, ignoreCase === true);
|
|
4175
4138
|
}
|
|
4176
4139
|
const matchMemoizers = {};
|
|
4177
|
-
|
|
4178
|
-
//#region src/models/string/string.normalize.model.ts
|
|
4140
|
+
// src/models/string/string.normalize.model.ts
|
|
4179
4141
|
const NORMALIZE_DEBURR_CHARACTERS = {
|
|
4180
4142
|
Æ: "AE",
|
|
4181
4143
|
æ: "ae",
|
|
@@ -4212,8 +4174,7 @@ const NORMALIZE_DEBURR_PATTERN_CHARACTERS = new RegExp(`(${Object.keys(NORMALIZE
|
|
|
4212
4174
|
const NORMALIZE_DEBURR_PATTERN_SIMPLE = /[\u0300-\u036f]/g;
|
|
4213
4175
|
const NORMALIZE_SPECIAL_PATTERN = /[\p{P}\p{S}]/gu;
|
|
4214
4176
|
const NORMALIZE_SYMBOL = Symbol("normalize");
|
|
4215
|
-
|
|
4216
|
-
//#region src/string/normalize.ts
|
|
4177
|
+
// src/string/normalize.ts
|
|
4217
4178
|
function Normalizer(options) {
|
|
4218
4179
|
this[NORMALIZE_SYMBOL] = options;
|
|
4219
4180
|
}
|
|
@@ -4279,12 +4240,10 @@ function normalizeString(value) {
|
|
|
4279
4240
|
}
|
|
4280
4241
|
let deburrMemoizer;
|
|
4281
4242
|
normalize.initialize = initializeNormalizer;
|
|
4282
|
-
|
|
4283
|
-
//#region src/models/string/string.template.model.ts
|
|
4243
|
+
// src/models/string/string.template.model.ts
|
|
4284
4244
|
const TEMPLATE_EXPRESSION_VARIABLE = /{{([^{}]+)}}/g;
|
|
4285
4245
|
const TEMPLATE_SYMBOL = Symbol("template");
|
|
4286
|
-
|
|
4287
|
-
//#region src/string/template.ts
|
|
4246
|
+
// src/string/template.ts
|
|
4288
4247
|
function Templater(options) {
|
|
4289
4248
|
this[TEMPLATE_SYMBOL] = options;
|
|
4290
4249
|
}
|
|
@@ -4335,8 +4294,7 @@ function template(value, ...parameters) {
|
|
|
4335
4294
|
return handleTemplate(value, pattern, ignoreCase, parameters[0]);
|
|
4336
4295
|
}
|
|
4337
4296
|
template.initialize = initializeTemplater;
|
|
4338
|
-
|
|
4339
|
-
//#region src/models/value/value.clone.model.ts
|
|
4297
|
+
// src/models/value/value.clone.model.ts
|
|
4340
4298
|
const CLONE_NAME = "clone";
|
|
4341
4299
|
const CLONE_COPY_OPTIONS = {
|
|
4342
4300
|
copyFunctions: true,
|
|
@@ -4357,8 +4315,7 @@ const CLONE_PRIMITIVES = {
|
|
|
4357
4315
|
undefined: true
|
|
4358
4316
|
};
|
|
4359
4317
|
const CLONE_SYMBOL = Symbol(CLONE_NAME);
|
|
4360
|
-
|
|
4361
|
-
//#region src/value/clone.ts
|
|
4318
|
+
// src/value/clone.ts
|
|
4362
4319
|
function Cloner(options) {
|
|
4363
4320
|
this[CLONE_SYMBOL] = options;
|
|
4364
4321
|
}
|
|
@@ -4523,8 +4480,7 @@ clone.deregister = deregisterCloner;
|
|
|
4523
4480
|
clone.handlers = cloneHandler;
|
|
4524
4481
|
clone.initialize = initializeCloner;
|
|
4525
4482
|
clone.register = registerCloner;
|
|
4526
|
-
|
|
4527
|
-
//#region src/value/collection.ts
|
|
4483
|
+
// src/value/collection.ts
|
|
4528
4484
|
function inMap(map, value, key) {
|
|
4529
4485
|
const getKey = key === true;
|
|
4530
4486
|
if (!(map instanceof Map)) return getKey ? void 0 : false;
|
|
@@ -4547,13 +4503,11 @@ function inSet(set, value) {
|
|
|
4547
4503
|
for (const item of set) if (equal(item, value)) return true;
|
|
4548
4504
|
return false;
|
|
4549
4505
|
}
|
|
4550
|
-
|
|
4551
|
-
//#region src/models/value/value.diff.model.ts
|
|
4506
|
+
// src/models/value/value.diff.model.ts
|
|
4552
4507
|
const DIFF_FULL = "full";
|
|
4553
4508
|
const DIFF_NONE = "none";
|
|
4554
4509
|
const DIFF_PARTIAL = "partial";
|
|
4555
|
-
|
|
4556
|
-
//#region src/value/diff.ts
|
|
4510
|
+
// src/value/diff.ts
|
|
4557
4511
|
/**
|
|
4558
4512
|
* Find the differences between two values
|
|
4559
4513
|
*
|
|
@@ -4652,8 +4606,7 @@ function setChanges(parameters) {
|
|
|
4652
4606
|
const diffsLength = diffs.length;
|
|
4653
4607
|
for (let diffIndex = 0; diffIndex < diffsLength; diffIndex += 1) changes.push(diffs[diffIndex]);
|
|
4654
4608
|
}
|
|
4655
|
-
|
|
4656
|
-
//#region src/value/freeze.ts
|
|
4609
|
+
// src/value/freeze.ts
|
|
4657
4610
|
function fakeDelete() {
|
|
4658
4611
|
return false;
|
|
4659
4612
|
}
|
|
@@ -4731,8 +4684,7 @@ function isFrozen(value) {
|
|
|
4731
4684
|
const frozenValues = /* @__PURE__ */ new WeakSet();
|
|
4732
4685
|
freeze.flat = flatFreeze;
|
|
4733
4686
|
freeze.is = isFrozen;
|
|
4734
|
-
|
|
4735
|
-
//#region src/internal/value/partial.ts
|
|
4687
|
+
// src/internal/value/partial.ts
|
|
4736
4688
|
function partial(value, providedKeys, omit) {
|
|
4737
4689
|
if (!isPlainObject(value)) return {};
|
|
4738
4690
|
let keys;
|
|
@@ -4748,8 +4700,7 @@ function partial(value, providedKeys, omit) {
|
|
|
4748
4700
|
}
|
|
4749
4701
|
return partials;
|
|
4750
4702
|
}
|
|
4751
|
-
|
|
4752
|
-
//#region src/value/omit.ts
|
|
4703
|
+
// src/value/omit.ts
|
|
4753
4704
|
/**
|
|
4754
4705
|
* Create a new object without the specified keys
|
|
4755
4706
|
*
|
|
@@ -4760,8 +4711,7 @@ function partial(value, providedKeys, omit) {
|
|
|
4760
4711
|
function omit(value, keys) {
|
|
4761
4712
|
return partial(value, keys, true);
|
|
4762
4713
|
}
|
|
4763
|
-
|
|
4764
|
-
//#region src/value/pick.ts
|
|
4714
|
+
// src/value/pick.ts
|
|
4765
4715
|
/**
|
|
4766
4716
|
* Create a new object with only the specified keys
|
|
4767
4717
|
*
|
|
@@ -4772,8 +4722,7 @@ function omit(value, keys) {
|
|
|
4772
4722
|
function pick(value, keys) {
|
|
4773
4723
|
return partial(value, keys, false);
|
|
4774
4724
|
}
|
|
4775
|
-
|
|
4776
|
-
//#region src/value/shake.ts
|
|
4725
|
+
// src/value/shake.ts
|
|
4777
4726
|
/**
|
|
4778
4727
|
* Shake an object, removing all keys with `undefined` values
|
|
4779
4728
|
*
|
|
@@ -4792,8 +4741,7 @@ function shake(value) {
|
|
|
4792
4741
|
}
|
|
4793
4742
|
return shaken;
|
|
4794
4743
|
}
|
|
4795
|
-
|
|
4796
|
-
//#region src/value/smush.ts
|
|
4744
|
+
// src/value/smush.ts
|
|
4797
4745
|
function flattenObject(value, depth, smushed, prefix) {
|
|
4798
4746
|
if (depth >= 100) return {};
|
|
4799
4747
|
if (smushed.has(value)) return smushed.get(value);
|
|
@@ -4827,8 +4775,7 @@ function flattenObject(value, depth, smushed, prefix) {
|
|
|
4827
4775
|
function smush(value) {
|
|
4828
4776
|
return typeof value === "object" && value !== null ? flattenObject(value, 0, /* @__PURE__ */ new WeakMap()) : {};
|
|
4829
4777
|
}
|
|
4830
|
-
|
|
4831
|
-
//#region src/value/unsmush.ts
|
|
4778
|
+
// src/value/unsmush.ts
|
|
4832
4779
|
function getKeys(value) {
|
|
4833
4780
|
const keys = Object.keys(value);
|
|
4834
4781
|
const { length } = keys;
|
|
@@ -4862,12 +4809,10 @@ function unsmush(value) {
|
|
|
4862
4809
|
}
|
|
4863
4810
|
return unsmushed;
|
|
4864
4811
|
}
|
|
4865
|
-
|
|
4866
|
-
//#region src/models/value/value.merge.model.ts
|
|
4812
|
+
// src/models/value/value.merge.model.ts
|
|
4867
4813
|
const MERGE_SYMBOL_ASSIGN = Symbol("assign");
|
|
4868
4814
|
const MERGE_SYMBOL_MERGE = Symbol("merge");
|
|
4869
|
-
|
|
4870
|
-
//#region src/value/merge.ts
|
|
4815
|
+
// src/value/merge.ts
|
|
4871
4816
|
function Assigner(options) {
|
|
4872
4817
|
this[MERGE_SYMBOL_ASSIGN] = {
|
|
4873
4818
|
...options,
|
|
@@ -4994,11 +4939,9 @@ function skipMerge(next, options, isArray) {
|
|
|
4994
4939
|
}
|
|
4995
4940
|
assign.initialize = initializeAssigner;
|
|
4996
4941
|
merge.initialize = initializeMerger;
|
|
4997
|
-
|
|
4998
|
-
//#region src/models/value/value.transform.model.ts
|
|
4942
|
+
// src/models/value/value.transform.model.ts
|
|
4999
4943
|
const TRANSFORM_SYMBOL = Symbol("transform");
|
|
5000
|
-
|
|
5001
|
-
//#region src/value/transform.ts
|
|
4944
|
+
// src/value/transform.ts
|
|
5002
4945
|
function Transformer(transformer) {
|
|
5003
4946
|
this[TRANSFORM_SYMBOL] = transformer;
|
|
5004
4947
|
}
|
|
@@ -5037,34 +4980,28 @@ function transformValue(value) {
|
|
|
5037
4980
|
return value;
|
|
5038
4981
|
}
|
|
5039
4982
|
transform.initialize = initializeTransformer;
|
|
5040
|
-
|
|
5041
|
-
//#region src/models/subscription.model.ts
|
|
4983
|
+
// src/models/subscription.model.ts
|
|
5042
4984
|
const SUBSCRIPTION_DISALLOWED_KEY = "Disallowed key for subscription";
|
|
5043
4985
|
const SUBSCRIPTION_INVALID_KEY = "Invalid key for subscription";
|
|
5044
4986
|
const SUBSCRIPTION_INVALID_VALUE = "A subscription requires a non-null value to identify it";
|
|
5045
4987
|
const SUBSCRIPTION_NAME = "subscription";
|
|
5046
|
-
const SUBSCRIPTION_PROPERTY = "$subscription";
|
|
5047
4988
|
const SUBSCRIPTION_STORE = "subscriptions";
|
|
5048
|
-
const SUBSCRIPTION_SYMBOL = Symbol(
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
function Subscription(state, property, parameters) {
|
|
4989
|
+
const SUBSCRIPTION_SYMBOL = Symbol("subscription");
|
|
4990
|
+
// src/internal/subscription.ts
|
|
4991
|
+
function Subscription(state, parameters) {
|
|
5052
4992
|
this[SUBSCRIPTION_SYMBOL] = state;
|
|
5053
|
-
this[property.key] = property.value;
|
|
5054
4993
|
state.aborter = createAborter(parameters.signal, () => this.unsubscribe(subscriptions, this, state));
|
|
5055
4994
|
addSubscription(this);
|
|
5056
4995
|
}
|
|
5057
|
-
Subscription.prototype[SUBSCRIPTION_PROPERTY] = SUBSCRIPTION_NAME;
|
|
5058
4996
|
Subscription.prototype.unsubscribe = removeSubscription;
|
|
5059
4997
|
Object.defineProperty(Subscription.prototype, "active", {
|
|
5060
4998
|
enumerable: true,
|
|
5061
4999
|
get: getSubscriptionActive
|
|
5062
5000
|
});
|
|
5063
5001
|
function Subscriptions(parameters) {
|
|
5064
|
-
const { keys
|
|
5065
|
-
this[SUBSCRIPTION_SYMBOL] = createSubscriptionsState(
|
|
5002
|
+
const { keys } = createSubscriptionsParameters(parameters);
|
|
5003
|
+
this[SUBSCRIPTION_SYMBOL] = createSubscriptionsState(keys);
|
|
5066
5004
|
}
|
|
5067
|
-
Subscriptions.prototype[SUBSCRIPTION_PROPERTY] = SUBSCRIPTION_STORE;
|
|
5068
5005
|
Subscriptions.prototype.clear = clearSubscriptions;
|
|
5069
5006
|
Subscriptions.prototype.create = createSubscription;
|
|
5070
5007
|
Object.defineProperties(Subscriptions.prototype, {
|
|
@@ -5120,7 +5057,8 @@ function createSubscription(params) {
|
|
|
5120
5057
|
const state = {
|
|
5121
5058
|
parameters,
|
|
5122
5059
|
subscriptions,
|
|
5123
|
-
active: true
|
|
5060
|
+
active: true,
|
|
5061
|
+
name: SUBSCRIPTION_NAME
|
|
5124
5062
|
};
|
|
5125
5063
|
const existing = getExistingSubscription(subscriptions, state);
|
|
5126
5064
|
if (existing != null) return [existing, true];
|
|
@@ -5128,7 +5066,7 @@ function createSubscription(params) {
|
|
|
5128
5066
|
if (subscriptions.keys === false) throw new Error(SUBSCRIPTION_DISALLOWED_KEY);
|
|
5129
5067
|
else if (subscriptions.keys !== true && !subscriptions.keys.has(parameters.key)) throw new Error(SUBSCRIPTION_INVALID_KEY);
|
|
5130
5068
|
}
|
|
5131
|
-
return [new Subscription(state,
|
|
5069
|
+
return [new Subscription(state, parameters), false];
|
|
5132
5070
|
}
|
|
5133
5071
|
function getExistingSubscription(subscriptions, state) {
|
|
5134
5072
|
const { values } = subscriptions;
|
|
@@ -5160,26 +5098,16 @@ function createSubscriptionsParameters(input) {
|
|
|
5160
5098
|
let keys;
|
|
5161
5099
|
if (values.keys instanceof Set) keys = values.keys;
|
|
5162
5100
|
else keys = typeof values.keys === "boolean" ? values.keys : false;
|
|
5163
|
-
return {
|
|
5164
|
-
keys,
|
|
5165
|
-
property: createSubscriptionsProperty(values.property)
|
|
5166
|
-
};
|
|
5101
|
+
return { keys };
|
|
5167
5102
|
}
|
|
5168
|
-
function
|
|
5169
|
-
const values = isPlainObject(input) ? input : {};
|
|
5170
|
-
return {
|
|
5171
|
-
key: typeof values.key === "string" ? values.key : SUBSCRIPTION_PROPERTY,
|
|
5172
|
-
value: values.value ?? "subscription"
|
|
5173
|
-
};
|
|
5174
|
-
}
|
|
5175
|
-
function createSubscriptionsState(property, keys) {
|
|
5103
|
+
function createSubscriptionsState(keys) {
|
|
5176
5104
|
return {
|
|
5177
5105
|
keys,
|
|
5178
|
-
property,
|
|
5179
5106
|
items: {
|
|
5180
5107
|
any: /* @__PURE__ */ new Set(),
|
|
5181
5108
|
keyed: keys === false ? void 0 : /* @__PURE__ */ new Map()
|
|
5182
5109
|
},
|
|
5110
|
+
name: SUBSCRIPTION_STORE,
|
|
5183
5111
|
values: {
|
|
5184
5112
|
from: {
|
|
5185
5113
|
any: /* @__PURE__ */ new Map(),
|
|
@@ -5199,10 +5127,10 @@ function createSubscriptionsState(property, keys) {
|
|
|
5199
5127
|
* @returns `true` if the value is a subscription, otherwise `false`
|
|
5200
5128
|
*/
|
|
5201
5129
|
function isSubscription(value) {
|
|
5202
|
-
return isSubscriptionInstance(
|
|
5130
|
+
return isSubscriptionInstance(SUBSCRIPTION_NAME, value);
|
|
5203
5131
|
}
|
|
5204
|
-
function isSubscriptionInstance(
|
|
5205
|
-
return typeof value === "object" && value !== null &&
|
|
5132
|
+
function isSubscriptionInstance(type, value) {
|
|
5133
|
+
return typeof value === "object" && value !== null && SUBSCRIPTION_SYMBOL in value && value[SUBSCRIPTION_SYMBOL].name === type;
|
|
5206
5134
|
}
|
|
5207
5135
|
/**
|
|
5208
5136
|
* Is the value a subscriptions store?
|
|
@@ -5211,7 +5139,7 @@ function isSubscriptionInstance(value, name) {
|
|
|
5211
5139
|
* @returns `true` if the value is a subscriptions store, otherwise `false`
|
|
5212
5140
|
*/
|
|
5213
5141
|
function isSubscriptions(value) {
|
|
5214
|
-
return isSubscriptionInstance(
|
|
5142
|
+
return isSubscriptionInstance(SUBSCRIPTION_STORE, value);
|
|
5215
5143
|
}
|
|
5216
5144
|
function removeFromStore(items, values, subscription, value, key) {
|
|
5217
5145
|
items.delete(subscription);
|
|
@@ -5251,30 +5179,23 @@ function removeSubscription() {
|
|
|
5251
5179
|
function subscriptions(parameters) {
|
|
5252
5180
|
return new Subscriptions(parameters);
|
|
5253
5181
|
}
|
|
5254
|
-
|
|
5255
|
-
//#region src/models/beacon.model.ts
|
|
5182
|
+
// src/models/beacon.model.ts
|
|
5256
5183
|
const BEACON_MESSAGE_RETRIEVE = "Cannot retrieve observable from a closed beacon";
|
|
5257
5184
|
const BEACON_MESSAGE_SUBSCRIBE = "Cannot subscribe to a closed observable";
|
|
5258
|
-
const BEACON_PROPERTY = "$beacon";
|
|
5259
5185
|
const BEACON_NAME = "beacon";
|
|
5260
5186
|
const BEACON_OBSERVABLE = "observable";
|
|
5261
|
-
const BEACON_SYMBOL = Symbol(
|
|
5187
|
+
const BEACON_SYMBOL = Symbol("beacon");
|
|
5262
5188
|
const BEACON_TYPE_ERROR = "error";
|
|
5263
5189
|
const BEACON_TYPE_NEXT = "next";
|
|
5264
|
-
|
|
5265
|
-
key: BEACON_PROPERTY,
|
|
5266
|
-
value: SUBSCRIPTION_NAME
|
|
5267
|
-
};
|
|
5268
|
-
//#endregion
|
|
5269
|
-
//#region src/beacon.ts
|
|
5190
|
+
// src/beacon.ts
|
|
5270
5191
|
function Beacon(value, options) {
|
|
5271
5192
|
this[BEACON_SYMBOL] = {
|
|
5272
5193
|
value,
|
|
5273
5194
|
active: true,
|
|
5274
|
-
options: createBeaconOptions(options)
|
|
5195
|
+
options: createBeaconOptions(options),
|
|
5196
|
+
name: BEACON_NAME
|
|
5275
5197
|
};
|
|
5276
5198
|
}
|
|
5277
|
-
Beacon.prototype[BEACON_PROPERTY] = BEACON_NAME;
|
|
5278
5199
|
Beacon.prototype.deactivate = deactivateBeacon;
|
|
5279
5200
|
Beacon.prototype.emit = emitBeaconValue;
|
|
5280
5201
|
Beacon.prototype.error = emitBeaconError;
|
|
@@ -5296,10 +5217,10 @@ Object.defineProperties(Beacon.prototype, {
|
|
|
5296
5217
|
function Observable(beacon) {
|
|
5297
5218
|
this[BEACON_SYMBOL] = {
|
|
5298
5219
|
beacon,
|
|
5299
|
-
active: beacon.active
|
|
5220
|
+
active: beacon.active,
|
|
5221
|
+
name: BEACON_OBSERVABLE
|
|
5300
5222
|
};
|
|
5301
5223
|
}
|
|
5302
|
-
Observable.prototype[BEACON_PROPERTY] = BEACON_OBSERVABLE;
|
|
5303
5224
|
Observable.prototype.deactivate = deactivateObservable;
|
|
5304
5225
|
Observable.prototype.subscribe = subscribeToObservable;
|
|
5305
5226
|
Object.defineProperty(Observable.prototype, "active", {
|
|
@@ -5390,16 +5311,7 @@ function isBeacon(value) {
|
|
|
5390
5311
|
return isBeaconInstance(BEACON_NAME, value);
|
|
5391
5312
|
}
|
|
5392
5313
|
function isBeaconInstance(name, value) {
|
|
5393
|
-
return typeof value === "object" && value !== null &&
|
|
5394
|
-
}
|
|
5395
|
-
/**
|
|
5396
|
-
* Is the value a beacon subscription?
|
|
5397
|
-
*
|
|
5398
|
-
* @param value Value to check
|
|
5399
|
-
* @returns `true` if the value is a beacon subscription, otherwise `false`
|
|
5400
|
-
*/
|
|
5401
|
-
function isBeaconSubscription(value) {
|
|
5402
|
-
return isSubscription(value) && value["$beacon"] === "subscription";
|
|
5314
|
+
return typeof value === "object" && value !== null && BEACON_SYMBOL in value && value[BEACON_SYMBOL].name === name;
|
|
5403
5315
|
}
|
|
5404
5316
|
/**
|
|
5405
5317
|
* Is the value an observable?
|
|
@@ -5413,7 +5325,7 @@ function isObservable(value) {
|
|
|
5413
5325
|
function subscribeToObservable(first, second, third) {
|
|
5414
5326
|
const state = this[BEACON_SYMBOL];
|
|
5415
5327
|
if (!state.beacon.active || !state.active) throw new Error(BEACON_MESSAGE_SUBSCRIBE);
|
|
5416
|
-
state.beacon.subscriptions ??= subscriptions(
|
|
5328
|
+
state.beacon.subscriptions ??= subscriptions();
|
|
5417
5329
|
const observer = createObserver(first, second, third);
|
|
5418
5330
|
const [subscription] = state.beacon.subscriptions.create({
|
|
5419
5331
|
isActive: () => state.beacon.active && state.active,
|
|
@@ -5433,32 +5345,24 @@ function updateBeacon(instance, type, value, finish) {
|
|
|
5433
5345
|
if (subscriptions != null && subscriptions.size > 0) for (const [, observer] of subscriptions) observer[type]?.(value);
|
|
5434
5346
|
if (finish === true) closeBeacon(state, true);
|
|
5435
5347
|
}
|
|
5436
|
-
|
|
5437
|
-
//#region src/models/herald.model.ts
|
|
5348
|
+
// src/models/herald.model.ts
|
|
5438
5349
|
const HERALD_MESSAGE_ARRAY = "Herald requires an array of event names.";
|
|
5439
5350
|
const HERALD_MESSAGE_ONCREATE = `Herald requires a valid onCreate callback for subscription creation`;
|
|
5440
|
-
const HERALD_MESSAGE_PROPERTY = `Herald requires valid property information for subscription identification`;
|
|
5441
5351
|
const HERALD_NAME_EVENTS = "events";
|
|
5442
5352
|
const HERALD_NAME_HERALD = "herald";
|
|
5443
|
-
const
|
|
5444
|
-
|
|
5445
|
-
const heraldSubscription = {
|
|
5446
|
-
key: HERALD_PROPERTY,
|
|
5447
|
-
value: SUBSCRIPTION_NAME
|
|
5448
|
-
};
|
|
5449
|
-
//#endregion
|
|
5450
|
-
//#region src/internal/herald.ts
|
|
5353
|
+
const HERALD_SYMBOL = Symbol("herald");
|
|
5354
|
+
// src/internal/herald.ts
|
|
5451
5355
|
function Events(herald, state) {
|
|
5356
|
+
this[HERALD_SYMBOL] = { name: HERALD_NAME_EVENTS };
|
|
5452
5357
|
for (const key of state.keys) Object.defineProperty(this, key, { value: (callback, signal) => herald.subscribe(key, callback, signal) });
|
|
5453
5358
|
}
|
|
5454
|
-
Events.prototype[HERALD_PROPERTY] = HERALD_NAME_EVENTS;
|
|
5455
5359
|
function Herald(state) {
|
|
5456
5360
|
this[HERALD_SYMBOL] = {
|
|
5457
5361
|
state,
|
|
5458
|
-
events: new Events(this, state)
|
|
5362
|
+
events: new Events(this, state),
|
|
5363
|
+
name: HERALD_NAME_HERALD
|
|
5459
5364
|
};
|
|
5460
5365
|
}
|
|
5461
|
-
Herald.prototype[HERALD_PROPERTY] = HERALD_NAME_HERALD;
|
|
5462
5366
|
Herald.prototype.clear = clearHerald;
|
|
5463
5367
|
Herald.prototype.emit = emitForHerald;
|
|
5464
5368
|
Herald.prototype.observed = eventIsObserved;
|
|
@@ -5477,22 +5381,10 @@ function createHeraldState(input) {
|
|
|
5477
5381
|
const keys = new Set(options.names);
|
|
5478
5382
|
return {
|
|
5479
5383
|
keys,
|
|
5480
|
-
store: subscriptions({
|
|
5481
|
-
keys,
|
|
5482
|
-
property: createHeraldSubscriptionProperty(options.property)
|
|
5483
|
-
}),
|
|
5384
|
+
store: subscriptions({ keys }),
|
|
5484
5385
|
onCreate: options.onCreate
|
|
5485
5386
|
};
|
|
5486
5387
|
}
|
|
5487
|
-
function createHeraldSubscriptionProperty(input) {
|
|
5488
|
-
if (input == null) return heraldSubscription;
|
|
5489
|
-
const property = isPlainObject(input) ? input : {};
|
|
5490
|
-
if (typeof property.key !== "string" || property.value != null && typeof property.value !== "string") throw new Error(HERALD_MESSAGE_PROPERTY);
|
|
5491
|
-
return {
|
|
5492
|
-
key: property.key,
|
|
5493
|
-
value: property.value
|
|
5494
|
-
};
|
|
5495
|
-
}
|
|
5496
5388
|
function emitForHerald(event, ...parameters) {
|
|
5497
5389
|
const { state } = this[HERALD_SYMBOL];
|
|
5498
5390
|
const items = state.store.values.from.keyed?.get(event);
|
|
@@ -5534,16 +5426,7 @@ function isHeraldEvents(value) {
|
|
|
5534
5426
|
return isHeraldInstance(HERALD_NAME_EVENTS, value);
|
|
5535
5427
|
}
|
|
5536
5428
|
function isHeraldInstance(name, value) {
|
|
5537
|
-
return typeof value === "object" && value !== null &&
|
|
5538
|
-
}
|
|
5539
|
-
/**
|
|
5540
|
-
* Is the value a herald subscription?
|
|
5541
|
-
*
|
|
5542
|
-
* @param value Value to check
|
|
5543
|
-
* @returns `true` if the value is a herald subscription, otherwise `false`
|
|
5544
|
-
*/
|
|
5545
|
-
function isHeraldSubscription(value) {
|
|
5546
|
-
return isSubscription(value) && "$herald" in value && value["$herald"] === "subscription";
|
|
5429
|
+
return typeof value === "object" && value !== null && HERALD_SYMBOL in value && value[HERALD_SYMBOL].name === name;
|
|
5547
5430
|
}
|
|
5548
5431
|
function subscribeToHerald(key, callback, signal) {
|
|
5549
5432
|
const { state } = this[HERALD_SYMBOL];
|
|
@@ -5555,8 +5438,7 @@ function subscribeToHerald(key, callback, signal) {
|
|
|
5555
5438
|
if (!existing) state.onCreate?.(key, callback, subscription);
|
|
5556
5439
|
return subscription;
|
|
5557
5440
|
}
|
|
5558
|
-
|
|
5559
|
-
//#region src/color/constants.ts
|
|
5441
|
+
// src/color/constants.ts
|
|
5560
5442
|
const COLOR_ALPHA = {
|
|
5561
5443
|
fullHexShort: "f",
|
|
5562
5444
|
fullHexLong: "ff",
|
|
@@ -5625,9 +5507,7 @@ const COLOR_MAX = {
|
|
|
5625
5507
|
hex: 255,
|
|
5626
5508
|
percent: 100
|
|
5627
5509
|
};
|
|
5628
|
-
const
|
|
5629
|
-
const COLOR_PROPERTY = "$color";
|
|
5630
|
-
const COLOR_SYMBOL = Symbol(COLOR_PROPERTY);
|
|
5510
|
+
const COLOR_SYMBOL = Symbol("color");
|
|
5631
5511
|
const COLOR_TYPE = {
|
|
5632
5512
|
all: void 0,
|
|
5633
5513
|
hex: "hex",
|
|
@@ -5662,12 +5542,7 @@ const COLOR_SRGB = {
|
|
|
5662
5542
|
luminanceRed: .2126,
|
|
5663
5543
|
luminanceThreshold: .625
|
|
5664
5544
|
};
|
|
5665
|
-
|
|
5666
|
-
key: COLOR_PROPERTY,
|
|
5667
|
-
value: SUBSCRIPTION_NAME
|
|
5668
|
-
};
|
|
5669
|
-
//#endregion
|
|
5670
|
-
//#region src/color/misc/alpha.ts
|
|
5545
|
+
// src/color/misc/alpha.ts
|
|
5671
5546
|
function getAlpha(value, hex) {
|
|
5672
5547
|
if (typeof value === "number") return getAlphaFromValue(value);
|
|
5673
5548
|
if (typeof value !== "string" || value.toLowerCase() === COLOR_ALPHA.fullHexLong) return { ...COLOR_DEFAULTS.alpha };
|
|
@@ -5699,8 +5574,7 @@ function getAlphaValue(original) {
|
|
|
5699
5574
|
function setColorAlpha(value) {
|
|
5700
5575
|
if (typeof value === "number" && !Number.isNaN(value)) this[COLOR_SYMBOL].values.alpha = getAlpha(value, false);
|
|
5701
5576
|
}
|
|
5702
|
-
|
|
5703
|
-
//#region src/color/misc/get.ts
|
|
5577
|
+
// src/color/misc/get.ts
|
|
5704
5578
|
function getClampedValue(value, minimum, maximum, rounding) {
|
|
5705
5579
|
if (typeof value !== "number" || Number.isNaN(value)) return minimum;
|
|
5706
5580
|
return clamp(rounding ?? false ? round(value) : value, minimum, maximum);
|
|
@@ -5839,8 +5713,7 @@ function getRgbaColor(value) {
|
|
|
5839
5713
|
function getRgbColor(value) {
|
|
5840
5714
|
return getColorFromState(getColorState(value), COLOR_TYPE.rgb);
|
|
5841
5715
|
}
|
|
5842
|
-
|
|
5843
|
-
//#region src/color/misc/is.ts
|
|
5716
|
+
// src/color/misc/is.ts
|
|
5844
5717
|
function hasKeys(value, keys) {
|
|
5845
5718
|
return typeof value === "object" && value !== null && keys.every((key) => key in value);
|
|
5846
5719
|
}
|
|
@@ -5857,7 +5730,7 @@ function isBytey(value) {
|
|
|
5857
5730
|
* @returns `true` if the value is a _Color_, otherwise `false`
|
|
5858
5731
|
*/
|
|
5859
5732
|
function isColor(value) {
|
|
5860
|
-
return typeof value === "object" && value !== null &&
|
|
5733
|
+
return typeof value === "object" && value !== null && COLOR_SYMBOL in value;
|
|
5861
5734
|
}
|
|
5862
5735
|
function isColorValue(value, properties) {
|
|
5863
5736
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -5976,8 +5849,7 @@ const validators = {
|
|
|
5976
5849
|
red: isBytey,
|
|
5977
5850
|
whiteness: isPercentage
|
|
5978
5851
|
};
|
|
5979
|
-
|
|
5980
|
-
//#region src/color/space/rgb.ts
|
|
5852
|
+
// src/color/space/rgb.ts
|
|
5981
5853
|
function convertRgbToHex(rgb, alpha) {
|
|
5982
5854
|
const hex = `${join([
|
|
5983
5855
|
rgb.red,
|
|
@@ -6168,8 +6040,7 @@ function setRgbColorValueInState(instance, value, alpha) {
|
|
|
6168
6040
|
function setRgbaValue(value) {
|
|
6169
6041
|
setRgbColorValueInState(this, value, true);
|
|
6170
6042
|
}
|
|
6171
|
-
|
|
6172
|
-
//#region src/color/space/hex.ts
|
|
6043
|
+
// src/color/space/hex.ts
|
|
6173
6044
|
function convertHexToRgba(value) {
|
|
6174
6045
|
const normalized = getNormalizedHex(value, true);
|
|
6175
6046
|
const pairs = COLOR_EXPRESSION.hexLong.exec(normalized);
|
|
@@ -6318,8 +6189,7 @@ function setHexValueInState(instance, value, alpha) {
|
|
|
6318
6189
|
function setHexaValue(value) {
|
|
6319
6190
|
setHexValueInState(this, value, true);
|
|
6320
6191
|
}
|
|
6321
|
-
|
|
6322
|
-
//#region src/color/space/hsl.ts
|
|
6192
|
+
// src/color/space/hsl.ts
|
|
6323
6193
|
function convertHslToHwba(input) {
|
|
6324
6194
|
let { hue, lightness, saturation } = isHslLike(input) ? getHslValues(input) : { ...COLOR_DEFAULTS.hsl };
|
|
6325
6195
|
lightness /= COLOR_MAX.percent;
|
|
@@ -6464,8 +6334,7 @@ function setHSLValueInState(instance, value, alpha) {
|
|
|
6464
6334
|
function setHslaValue(value) {
|
|
6465
6335
|
setHSLValueInState(this, value, true);
|
|
6466
6336
|
}
|
|
6467
|
-
|
|
6468
|
-
//#region src/color/space/hwb.ts
|
|
6337
|
+
// src/color/space/hwb.ts
|
|
6469
6338
|
function convertHwbToHsl(input) {
|
|
6470
6339
|
let { blackness, hue, whiteness } = isHwbLike(input) ? getHwbValues(input) : COLOR_DEFAULTS.hwb;
|
|
6471
6340
|
blackness /= COLOR_MAX.percent;
|
|
@@ -6588,8 +6457,7 @@ function setHwbColorValueInState(instance, value, alpha) {
|
|
|
6588
6457
|
function setHwbaValue(value) {
|
|
6589
6458
|
setHwbColorValueInState(this, value, true);
|
|
6590
6459
|
}
|
|
6591
|
-
|
|
6592
|
-
//#region src/color/misc/state.ts
|
|
6460
|
+
// src/color/misc/state.ts
|
|
6593
6461
|
function getColorFromState(state, type) {
|
|
6594
6462
|
const { origin } = state;
|
|
6595
6463
|
if (type === origin) return state[origin];
|
|
@@ -6669,8 +6537,7 @@ const getters = {
|
|
|
6669
6537
|
hwb: getColorFromHwb,
|
|
6670
6538
|
rgb: getColorFromRgb
|
|
6671
6539
|
};
|
|
6672
|
-
|
|
6673
|
-
//#region src/color/misc/format.ts
|
|
6540
|
+
// src/color/misc/format.ts
|
|
6674
6541
|
function formatHexColor(alpha) {
|
|
6675
6542
|
return `#${alpha === true ? this.hexa : this.hex}`;
|
|
6676
6543
|
}
|
|
@@ -6692,19 +6559,16 @@ function formatRgbColor(alpha) {
|
|
|
6692
6559
|
function getSuffix(state, alpha) {
|
|
6693
6560
|
return alpha === true ? ` / ${state.alpha.value}%` : "";
|
|
6694
6561
|
}
|
|
6695
|
-
|
|
6696
|
-
//#region src/color/instance.ts
|
|
6562
|
+
// src/color/instance.ts
|
|
6697
6563
|
function Color(value) {
|
|
6698
6564
|
this[COLOR_SYMBOL] = {
|
|
6699
6565
|
changes: herald({
|
|
6700
6566
|
names: [COLOR_TYPE.wildcard, ...COLOR_TYPE.all],
|
|
6701
|
-
property: colorSubscription,
|
|
6702
6567
|
onCreate: (event, callback) => onCreateSubscription(this, event, callback)
|
|
6703
6568
|
}),
|
|
6704
6569
|
values: getColorState(value)
|
|
6705
6570
|
};
|
|
6706
6571
|
}
|
|
6707
|
-
Color.prototype[COLOR_PROPERTY] = COLOR_NAME;
|
|
6708
6572
|
Color.prototype.subscribe = subscribeToColor;
|
|
6709
6573
|
Color.prototype.toHexString = formatHexColor;
|
|
6710
6574
|
Color.prototype.toHslString = formatHslColor;
|
|
@@ -6789,8 +6653,7 @@ function subscribeToColor(callback, signal) {
|
|
|
6789
6653
|
function unsubscribeFromColor() {
|
|
6790
6654
|
this[COLOR_SYMBOL].changes.clear();
|
|
6791
6655
|
}
|
|
6792
|
-
|
|
6793
|
-
//#region src/color/index.ts
|
|
6656
|
+
// src/color/index.ts
|
|
6794
6657
|
/**
|
|
6795
6658
|
* Get a _Color_ from any kind of value
|
|
6796
6659
|
*
|
|
@@ -6803,8 +6666,7 @@ function unsubscribeFromColor() {
|
|
|
6803
6666
|
function getColor(value) {
|
|
6804
6667
|
return isColor(value) ? value : color(value);
|
|
6805
6668
|
}
|
|
6806
|
-
|
|
6807
|
-
//#region src/is.ts
|
|
6669
|
+
// src/is.ts
|
|
6808
6670
|
/**
|
|
6809
6671
|
* Is the value empty, or only containing `null` or `undefined` values?
|
|
6810
6672
|
*
|
|
@@ -6921,16 +6783,14 @@ function isNumerical(value) {
|
|
|
6921
6783
|
function isObject(value) {
|
|
6922
6784
|
return typeof value === "object" && value !== null || typeof value === "function";
|
|
6923
6785
|
}
|
|
6924
|
-
|
|
6925
|
-
//#region src/models/logger.model.ts
|
|
6786
|
+
// src/models/logger.model.ts
|
|
6926
6787
|
const LOGGER_NAME = "Logger";
|
|
6927
6788
|
const LOGGER_NAME_TIMED = "TimedLogger";
|
|
6928
|
-
const
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
Lumberjack.prototype[LOGGER_PROPERTY] = LOGGER_NAME;
|
|
6789
|
+
const LOGGER_SYMBOL = Symbol("logger");
|
|
6790
|
+
// src/logger.ts
|
|
6791
|
+
function Lumberjack() {
|
|
6792
|
+
this[LOGGER_SYMBOL] = { name: LOGGER_NAME };
|
|
6793
|
+
}
|
|
6934
6794
|
Lumberjack.prototype.time = getTimeLogger;
|
|
6935
6795
|
Object.defineProperties(Lumberjack.prototype, {
|
|
6936
6796
|
debug: { get: getLoggerCallback.bind("debug") },
|
|
@@ -6950,6 +6810,7 @@ Object.defineProperties(Lumberjack.prototype, {
|
|
|
6950
6810
|
function TimeLogger(label) {
|
|
6951
6811
|
this[LOGGER_SYMBOL] = {
|
|
6952
6812
|
label,
|
|
6813
|
+
name: LOGGER_NAME_TIMED,
|
|
6953
6814
|
started: enabled,
|
|
6954
6815
|
stopped: false
|
|
6955
6816
|
};
|
|
@@ -6958,7 +6819,6 @@ function TimeLogger(label) {
|
|
|
6958
6819
|
};
|
|
6959
6820
|
if (this[LOGGER_SYMBOL].started) console.time(label);
|
|
6960
6821
|
}
|
|
6961
|
-
TimeLogger.prototype[LOGGER_PROPERTY] = LOGGER_NAME_TIMED;
|
|
6962
6822
|
Object.defineProperties(TimeLogger.prototype, {
|
|
6963
6823
|
active: {
|
|
6964
6824
|
enumerable: true,
|
|
@@ -7001,7 +6861,7 @@ function isLogger(value) {
|
|
|
7001
6861
|
return isLoggerInstance(LOGGER_NAME, value);
|
|
7002
6862
|
}
|
|
7003
6863
|
function isLoggerInstance(name, value) {
|
|
7004
|
-
return typeof value === "object" && value !== null &&
|
|
6864
|
+
return typeof value === "object" && value !== null && LOGGER_SYMBOL in value && value[LOGGER_SYMBOL].name === name;
|
|
7005
6865
|
}
|
|
7006
6866
|
/**
|
|
7007
6867
|
* Is the value a _TimeLogger_?
|
|
@@ -7022,8 +6882,7 @@ function setLoggerEnabled(value) {
|
|
|
7022
6882
|
*/
|
|
7023
6883
|
const Logger = new Lumberjack();
|
|
7024
6884
|
let enabled = true;
|
|
7025
|
-
|
|
7026
|
-
//#region src/math.ts
|
|
6885
|
+
// src/math.ts
|
|
7027
6886
|
function average(array, key) {
|
|
7028
6887
|
const aggregated = aggregate(AGGREGATION_AVERAGE, array, key);
|
|
7029
6888
|
return aggregated.count > 0 ? aggregated.value / aggregated.count : NaN;
|
|
@@ -7076,8 +6935,7 @@ function median(array, key) {
|
|
|
7076
6935
|
function sum(array, key) {
|
|
7077
6936
|
return getAggregated("sum", array, key);
|
|
7078
6937
|
}
|
|
7079
|
-
|
|
7080
|
-
//#region src/models/query.model.ts
|
|
6938
|
+
// src/models/query.model.ts
|
|
7081
6939
|
const QUERY_EXPRESSION_ARRAY_SUFFIX = /\[\]$/;
|
|
7082
6940
|
const QUERY_EXPRESSION_BOOLEAN = /^(false|true)$/;
|
|
7083
6941
|
const QUERY_TRUE = "true";
|
|
@@ -7086,8 +6944,7 @@ const QUERY_TYPES = /* @__PURE__ */ new Set([
|
|
|
7086
6944
|
"number",
|
|
7087
6945
|
"string"
|
|
7088
6946
|
]);
|
|
7089
|
-
|
|
7090
|
-
//#region src/query.ts
|
|
6947
|
+
// src/query.ts
|
|
7091
6948
|
/**
|
|
7092
6949
|
* Convert a query string to a plain _(nested)_ object
|
|
7093
6950
|
*
|
|
@@ -7157,8 +7014,7 @@ function isDecodable(value) {
|
|
|
7157
7014
|
function toQuery(parameters) {
|
|
7158
7015
|
return isPlainObject(parameters) ? join(getParts(parameters, false).filter((part) => part.length > 0), "&") : "";
|
|
7159
7016
|
}
|
|
7160
|
-
|
|
7161
|
-
//#region src/models/queue.model.ts
|
|
7017
|
+
// src/models/queue.model.ts
|
|
7162
7018
|
/**
|
|
7163
7019
|
* An error thrown by the Queue when an operation fails
|
|
7164
7020
|
*/
|
|
@@ -7179,22 +7035,20 @@ const QUEUE_MESSAGE_MAXIMUM = "Queue has reached its maximum size";
|
|
|
7179
7035
|
const QUEUE_MESSAGE_REMOVE = "Item removed from queue";
|
|
7180
7036
|
const QUEUE_NAME_KEYED = "keyedQueue";
|
|
7181
7037
|
const QUEUE_NAME_QUEUE = "queue";
|
|
7182
|
-
const QUEUE_PROPERTY = "$queue";
|
|
7183
7038
|
const QUEUE_STATUS_ACTIVE = "active";
|
|
7184
7039
|
const QUEUE_STATUS_EMPTY = "empty";
|
|
7185
7040
|
const QUEUE_STATUS_FULL = "full";
|
|
7186
7041
|
const QUEUE_STATUS_PAUSED = "paused";
|
|
7187
|
-
const QUEUE_SYMBOL = Symbol(
|
|
7188
|
-
|
|
7189
|
-
//#region src/queue.ts
|
|
7042
|
+
const QUEUE_SYMBOL = Symbol("queue");
|
|
7043
|
+
// src/queue.ts
|
|
7190
7044
|
function KeyedQueue(callback, options) {
|
|
7191
7045
|
this[QUEUE_SYMBOL] = {
|
|
7192
7046
|
callback,
|
|
7193
7047
|
options: createQueueOptions(options),
|
|
7194
|
-
queues: /* @__PURE__ */ new Map()
|
|
7048
|
+
queues: /* @__PURE__ */ new Map(),
|
|
7049
|
+
type: QUEUE_NAME_KEYED
|
|
7195
7050
|
};
|
|
7196
7051
|
}
|
|
7197
|
-
KeyedQueue.prototype[QUEUE_PROPERTY] = QUEUE_NAME_KEYED;
|
|
7198
7052
|
KeyedQueue.prototype.add = addKeyedQueue;
|
|
7199
7053
|
KeyedQueue.prototype.clear = clearQueues;
|
|
7200
7054
|
KeyedQueue.prototype.get = getQueue;
|
|
@@ -7252,10 +7106,10 @@ function Queue(callback, options, key) {
|
|
|
7252
7106
|
id: 0,
|
|
7253
7107
|
items: [],
|
|
7254
7108
|
paused: !options.autostart,
|
|
7255
|
-
runners: 0
|
|
7109
|
+
runners: 0,
|
|
7110
|
+
type: QUEUE_NAME_QUEUE
|
|
7256
7111
|
};
|
|
7257
7112
|
}
|
|
7258
|
-
Queue.prototype[QUEUE_PROPERTY] = QUEUE_NAME_QUEUE;
|
|
7259
7113
|
Queue.prototype.add = addToQueue;
|
|
7260
7114
|
Queue.prototype.clear = clearQueue;
|
|
7261
7115
|
Queue.prototype.pause = pauseQueue;
|
|
@@ -7412,9 +7266,9 @@ function getQueueSize() {
|
|
|
7412
7266
|
}
|
|
7413
7267
|
function getStatus(state, status) {
|
|
7414
7268
|
const queues = state.queues.entries();
|
|
7415
|
-
const
|
|
7416
|
-
for (const [key, queue] of queues) if (queue[status])
|
|
7417
|
-
return
|
|
7269
|
+
const queued = [];
|
|
7270
|
+
for (const [key, queue] of queues) if (queue[status]) queued.push(key);
|
|
7271
|
+
return queued;
|
|
7418
7272
|
}
|
|
7419
7273
|
function handleQueuedResult(item, error, result) {
|
|
7420
7274
|
item.aborter?.cancel();
|
|
@@ -7459,7 +7313,7 @@ function isQueue(value) {
|
|
|
7459
7313
|
return isQueueInstance(QUEUE_NAME_QUEUE, value);
|
|
7460
7314
|
}
|
|
7461
7315
|
function isQueueInstance(name, value) {
|
|
7462
|
-
return typeof value === "object" && value != null &&
|
|
7316
|
+
return typeof value === "object" && value != null && QUEUE_SYMBOL in value && value[QUEUE_SYMBOL].type === name;
|
|
7463
7317
|
}
|
|
7464
7318
|
function keyedQueue(callback, options) {
|
|
7465
7319
|
if (typeof callback !== "function") throw new TypeError(QUEUE_MESSAGE_CALLBACK);
|
|
@@ -7542,13 +7396,11 @@ async function run$1(state) {
|
|
|
7542
7396
|
state.runners -= 1;
|
|
7543
7397
|
}
|
|
7544
7398
|
queue.keyed = keyedQueue;
|
|
7545
|
-
|
|
7546
|
-
//#region src/models/random.model.ts
|
|
7399
|
+
// src/models/random.model.ts
|
|
7547
7400
|
const RANDOM_ALPHABET = "abcdefghijklmnopqrstuvwxyz";
|
|
7548
7401
|
const RANDOM_BOOLEAN_MODIFIER = .5;
|
|
7549
7402
|
const RANDOM_HEX_CHARACTERS = "0123456789ABCDEF";
|
|
7550
|
-
|
|
7551
|
-
//#region src/random.ts
|
|
7403
|
+
// src/random.ts
|
|
7552
7404
|
/**
|
|
7553
7405
|
* Get a random boolean
|
|
7554
7406
|
*
|
|
@@ -7604,8 +7456,7 @@ function getRandomItems(array, amount) {
|
|
|
7604
7456
|
if (amount === 1) return [array[getRandomInteger(0, array.length - 1)]];
|
|
7605
7457
|
return typeof amount !== "number" || amount <= 0 || amount >= array.length ? shuffle(array) : shuffle(array).slice(0, amount);
|
|
7606
7458
|
}
|
|
7607
|
-
|
|
7608
|
-
//#region src/sized/set.ts
|
|
7459
|
+
// src/sized/set.ts
|
|
7609
7460
|
/**
|
|
7610
7461
|
* A _Set_ with a maximum size
|
|
7611
7462
|
*
|
|
@@ -7622,6 +7473,9 @@ var SizedSet = class extends Set {
|
|
|
7622
7473
|
get full() {
|
|
7623
7474
|
return this.size >= this.#maximumSize;
|
|
7624
7475
|
}
|
|
7476
|
+
/**
|
|
7477
|
+
* The maximum size of the _Set_
|
|
7478
|
+
*/
|
|
7625
7479
|
get maximum() {
|
|
7626
7480
|
return this.#maximumSize;
|
|
7627
7481
|
}
|
|
@@ -7659,5 +7513,4 @@ var SizedSet = class extends Set {
|
|
|
7659
7513
|
return value;
|
|
7660
7514
|
}
|
|
7661
7515
|
};
|
|
7662
|
-
|
|
7663
|
-
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, asyncFail, asyncFlow, asyncMatchResult, asyncOnce, asyncPipe, asyncRun, asyncSucceed, asyncThrottle, asyncUse, attempt, attemptAsyncFlow, attemptAsyncPipe, attemptFlow, attemptPipe, attemptPromise, attemptRun, 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, filterAndFlatMap, filterAndMap, filterAndMap as select, find, findLast, first, firstOrDefault, flatFreeze, flatMapAndFilter, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getNumber, getRandom, 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, isAsyncFailure, isAsyncGenerator, isAsyncGeneratorFunction, isAsyncOnce, isAsyncPlan, isAsyncStep, isAsyncSuccess, isBeacon, isBeaconSubscription, isColor, isConstructor, isEmpty, isError, isFailure, isFrozen, isFulfilled, isFuzzy, isGenerator, isGeneratorFunction, 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, isRejected, isResult, isRgbColor, isRgbaColor, isSorted, isStep, isSubscription, isSubscriptions, isSuccess, 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, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, subscriptions, succeed, sum, swap, take, template, throttle, timed, times, titleCase, toCaseCallback, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toResult, toSet, toggle, transform, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, use, words };
|
|
7516
|
+
export { CancelablePromise, Logger, RetryError, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SizedMap, SizedSet, TimedError, push as append, push, assert, assertCondition, assertDefined, assertInstanceOf, assertIs, assertProperty, assign, asyncAttempt, asyncAttemptRun, asyncDebounce, asyncFail, asyncFlow, asyncMatchResult, asyncOnce, asyncPipe, asyncRun, asyncSucceed, asyncThrottle, asyncUse, attempt, attemptAsyncFlow, attemptAsyncPipe, attemptFlow, attemptPipe, attemptPromise, attemptRun, 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, filterAndFlatMap, filterAndMap, filterAndMap as select, find, findLast, first, firstOrDefault, flatFreeze, flatMapAndFilter, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getNumber, getRandom, 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, isAsyncFailure, isAsyncGenerator, isAsyncGeneratorFunction, isAsyncOnce, isAsyncPlan, isAsyncStep, isAsyncSuccess, isBeacon, isColor, isConstructor, isEmpty, isError, isFailure, isFrozen, isFulfilled, isFuzzy, isGenerator, isGeneratorFunction, isHerald, isHeraldEvents, 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, isRejected, isResult, isRgbColor, isRgbaColor, isSorted, isStep, isSubscription, isSubscriptions, isSuccess, 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, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, subscriptions, succeed, sum, swap, take, template, throttle, timed, times, titleCase, toCaseCallback, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toResult, toSet, toggle, transform, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, unwrapWork, update, upperCase, use, words };
|