@oscarpalmer/atoms 0.222.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.mjs +1 -1
- package/dist/array/exists.mjs +10 -4
- package/dist/array/filter.mjs +14 -4
- package/dist/array/find.mjs +8 -3
- package/dist/array/first.mjs +9 -3
- package/dist/array/index.d.mts +4 -4
- package/dist/array/insert.mjs +1 -1
- package/dist/array/intersection.mjs +1 -1
- package/dist/array/last.mjs +11 -3
- package/dist/array/partition.mjs +23 -3
- package/dist/array/push.mjs +1 -1
- package/dist/array/select.mjs +39 -7
- package/dist/array/single.mjs +8 -5
- package/dist/array/sort.mjs +1 -1
- package/dist/array/splice.mjs +1 -1
- package/dist/array/swap.mjs +1 -1
- package/dist/array/union.mjs +1 -1
- package/dist/array/unique.mjs +17 -3
- package/dist/beacon.d.mts +3 -11
- package/dist/beacon.mjs +10 -20
- package/dist/color/constants.d.mts +1 -5
- package/dist/color/constants.mjs +2 -9
- package/dist/color/index.mjs +3 -3
- package/dist/color/instance.mjs +4 -6
- package/dist/color/misc/get.mjs +1 -1
- package/dist/color/misc/is.d.mts +0 -8
- package/dist/color/misc/is.mjs +3 -14
- package/dist/color/misc/state.mjs +3 -3
- package/dist/color/space/hex.mjs +1 -1
- package/dist/color/space/hsl.mjs +1 -1
- package/dist/color/space/hwb.mjs +2 -2
- package/dist/function/limit.d.mts +1 -1
- package/dist/function/limit.mjs +1 -1
- package/dist/function/once.d.mts +1 -1
- package/dist/function/once.mjs +7 -7
- package/dist/function/retry.d.mts +1 -1
- package/dist/function/retry.mjs +10 -10
- package/dist/herald.d.mts +2 -2
- package/dist/herald.mjs +1 -1
- package/dist/index.d.mts +80 -91
- package/dist/index.mjs +352 -334
- package/dist/internal/array/callbacks.d.mts +1 -1
- package/dist/internal/array/find.d.mts +2 -6
- package/dist/internal/array/find.mjs +30 -122
- package/dist/internal/array/index-of.mjs +9 -3
- package/dist/internal/array/insert.mjs +1 -1
- package/dist/internal/array/match.d.mts +1 -1
- package/dist/internal/array/match.mjs +1 -1
- package/dist/internal/array/sets.mjs +4 -4
- package/dist/internal/function/assert.d.mts +1 -1
- package/dist/internal/function/limit.d.mts +1 -1
- package/dist/internal/function/limit.mjs +7 -7
- package/dist/internal/function/memoize.d.mts +1 -1
- package/dist/internal/function/memoize.mjs +3 -3
- package/dist/internal/function/work.d.mts +1 -1
- package/dist/internal/function/work.mjs +1 -1
- package/dist/internal/herald.d.mts +2 -10
- package/dist/internal/herald.mjs +8 -31
- package/dist/internal/math/aggregate.mjs +1 -1
- package/dist/internal/number.mjs +1 -1
- package/dist/internal/plan/index.mjs +1 -1
- package/dist/internal/plan/plan.generate.mjs +67 -21
- package/dist/internal/sized/map.d.mts +3 -0
- package/dist/internal/sized/map.mjs +3 -0
- package/dist/internal/string/case.mjs +2 -2
- package/dist/internal/string/misc.mjs +1 -1
- package/dist/internal/subscription.mjs +15 -27
- package/dist/internal/value/compare.mjs +1 -1
- package/dist/internal/value/equal.d.mts +1 -1
- package/dist/internal/value/equal.mjs +2 -2
- package/dist/internal/value/set.mjs +1 -1
- package/dist/is.mjs +1 -1
- package/dist/logger.mjs +6 -5
- package/dist/math.mjs +1 -1
- package/dist/models/array/array.misc.model.d.mts +12 -1
- package/dist/models/array/array.misc.model.mjs +2 -1
- package/dist/models/beacon.model.d.mts +4 -4
- package/dist/models/beacon.model.mjs +2 -8
- package/dist/models/color.model.d.mts +2 -2
- package/dist/models/function/limiter.model.d.mts +1 -1
- package/dist/models/function/limiter.model.mjs +1 -2
- package/dist/models/function/memoize.model.d.mts +1 -1
- package/dist/models/function/once.model.d.mts +0 -1
- package/dist/models/function/once.model.mjs +2 -3
- package/dist/models/function/work.model.d.mts +1 -1
- package/dist/models/herald.model.d.mts +8 -5
- package/dist/models/herald.model.mjs +2 -8
- package/dist/models/logger.model.d.mts +0 -1
- package/dist/models/logger.model.mjs +2 -3
- package/dist/models/plan.model.d.mts +35 -35
- package/dist/models/promise.model.d.mts +7 -7
- package/dist/models/promise.model.mjs +3 -3
- package/dist/models/queue.model.d.mts +0 -1
- package/dist/models/queue.model.mjs +2 -3
- package/dist/models/string/string.fuzzy.model.d.mts +0 -1
- package/dist/models/string/string.fuzzy.model.mjs +2 -3
- package/dist/models/subscription.model.d.mts +3 -20
- package/dist/models/subscription.model.mjs +2 -3
- package/dist/plan/index.mjs +1 -1
- package/dist/plan/misc.mjs +1 -1
- package/dist/plan/models.d.mts +2 -2
- package/dist/plan/result.d.mts +7 -7
- package/dist/plan/result.mjs +1 -1
- package/dist/plan/run.d.mts +7 -7
- package/dist/plan/run.mjs +1 -1
- package/dist/plan/use.mjs +13 -7
- package/dist/promise/delay.mjs +1 -1
- package/dist/promise/helpers.mjs +1 -1
- package/dist/promise/index.mjs +4 -4
- package/dist/promise/misc.d.mts +1 -1
- package/dist/promise/misc.mjs +1 -1
- package/dist/promise/models.d.mts +2 -2
- package/dist/promise/models.mjs +1 -1
- package/dist/promise/timed.mjs +3 -3
- package/dist/query.mjs +1 -1
- package/dist/queue.mjs +10 -10
- package/dist/random.mjs +1 -1
- package/dist/result/work/flow.mjs +1 -1
- package/dist/result/work/pipe.mjs +1 -1
- package/dist/sized/set.d.mts +3 -0
- package/dist/sized/set.mjs +3 -0
- package/dist/string/fuzzy.mjs +4 -5
- package/dist/string/index.mjs +1 -1
- package/dist/string/match.mjs +1 -1
- package/dist/string/normalize.mjs +2 -2
- package/dist/subscription.d.mts +2 -2
- package/dist/value/clone.d.mts +1 -1
- package/dist/value/clone.mjs +1 -1
- package/dist/value/freeze.mjs +1 -1
- package/dist/value/handle.mjs +1 -1
- package/dist/value/smush.mjs +1 -1
- package/package.json +6 -6
- package/dist/models/array/array.find.model.d.mts +0 -46
- package/dist/models/array/array.find.model.mjs +0 -7
package/dist/index.mjs
CHANGED
|
@@ -1,175 +1,105 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const ARRAY_FIND_VALUES_UNIQUE = "unique";
|
|
5
|
-
// src/internal/array/callbacks.ts
|
|
6
|
-
function getArrayCallback(value) {
|
|
7
|
-
switch (typeof value) {
|
|
8
|
-
case "function": return value;
|
|
9
|
-
case "number":
|
|
10
|
-
case "string": return (obj) => obj?.[value];
|
|
11
|
-
default: return;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function getArrayCallbacks(bool, key, value) {
|
|
15
|
-
if (typeof bool === "function") return { bool };
|
|
16
|
-
return {
|
|
17
|
-
keyed: getArrayCallback(key),
|
|
18
|
-
value: getArrayCallback(value)
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
// src/internal/array/find.ts
|
|
22
|
-
function addResult(result, mapped, flat) {
|
|
23
|
-
if (!flat) {
|
|
24
|
-
result.matched.push(mapped);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const array = Array.isArray(mapped) ? mapped : [mapped];
|
|
28
|
-
const { length } = array;
|
|
29
|
-
for (let index = 0; index < length; index += 1) result.matched.push(array[index]);
|
|
1
|
+
// src/array/filter.ts
|
|
2
|
+
function exclude(array, ...parameters) {
|
|
3
|
+
return filterValues(array, parameters, false);
|
|
30
4
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
bool: length === 1 && typeof original[0] === "function" ? original[0] : void 0,
|
|
35
|
-
key: length === 2 ? original[0] : void 0,
|
|
36
|
-
value: length === 1 && typeof original[0] !== "function" ? original[0] : original[1]
|
|
37
|
-
};
|
|
5
|
+
function filter(array, ...parameters) {
|
|
6
|
+
return filterValues(array, parameters, true);
|
|
38
7
|
}
|
|
39
|
-
function
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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);
|
|
47
19
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (result.matched.length >= limit) return result;
|
|
59
|
-
} else result.notMatched.push(arrayItem);
|
|
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;
|
|
60
30
|
}
|
|
61
31
|
return result;
|
|
62
32
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
return reversed ? array.findLast((item) => Object.is(item, value)) : array.find((item) => Object.is(item, value));
|
|
33
|
+
function findBareValue(array, reverse) {
|
|
34
|
+
return { values: [array[reverse ? array.length - 1 : 0]] };
|
|
66
35
|
}
|
|
67
|
-
function
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
for (let arrayIndex = 0; arrayIndex < arrayLength; arrayIndex += 1) {
|
|
72
|
-
const arrayItem = array[arrayIndex];
|
|
73
|
-
let mapped = before == null ? arrayItem : before(arrayItem, arrayIndex, array);
|
|
74
|
-
if (!flat || after != null) {
|
|
75
|
-
if (handler(mapped, arrayIndex, array)) {
|
|
76
|
-
mapped = after == null ? mapped : after(arrayItem, arrayIndex, array);
|
|
77
|
-
addResult(result, mapped, flat);
|
|
78
|
-
if (result.matched.length >= limit) return result;
|
|
79
|
-
} else result.notMatched.push(arrayItem);
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
const flatItems = Array.isArray(mapped) ? mapped : [mapped];
|
|
83
|
-
const flatLength = flatItems.length;
|
|
84
|
-
for (let flatIndex = 0; flatIndex < flatLength; flatIndex += 1) {
|
|
85
|
-
const flatItem = flatItems[flatIndex];
|
|
86
|
-
if (handler(flatItem, arrayIndex, array)) result.matched.push(flatItem);
|
|
87
|
-
else result.notMatched.push(flatItem);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return result;
|
|
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]] };
|
|
91
40
|
}
|
|
92
|
-
function findValue(
|
|
93
|
-
|
|
94
|
-
if (!Array.isArray(array) || array.length === 0) return findIndex ? -1 : void 0;
|
|
95
|
-
const { bool, key, value } = createFindParameters(parameters);
|
|
96
|
-
const callbacks = getArrayCallbacks(bool, key);
|
|
97
|
-
if (callbacks?.bool == null && callbacks?.keyed == null) return findSimpleValue(array, value, findIndex, reversed);
|
|
98
|
-
if (callbacks.bool != null) {
|
|
99
|
-
const index = reversed ? array.findLastIndex(callbacks.bool) : array.findIndex(callbacks.bool);
|
|
100
|
-
return findIndex ? index : array[index];
|
|
101
|
-
}
|
|
102
|
-
return findValueInArray(array, callbacks.keyed, value, findIndex, reversed);
|
|
103
|
-
}
|
|
104
|
-
function findValueInArray(array, callback, value, findIndex, reversed) {
|
|
105
|
-
const { length } = array;
|
|
106
|
-
for (let index = 0; index < length; index += 1) {
|
|
107
|
-
const item = reversed ? array.at(-(index + 1)) : array[index];
|
|
108
|
-
if (Object.is(callback?.(item, index, array), value)) return findIndex ? index : item;
|
|
109
|
-
}
|
|
110
|
-
return findIndex ? -1 : void 0;
|
|
111
|
-
}
|
|
112
|
-
function findValues(type, array, parameters, options) {
|
|
113
|
-
const result = {
|
|
114
|
-
matched: [],
|
|
115
|
-
notMatched: []
|
|
116
|
-
};
|
|
117
|
-
if (!Array.isArray(array)) return result;
|
|
41
|
+
function findValue(array, parameters) {
|
|
42
|
+
if (!Array.isArray(array)) return;
|
|
118
43
|
const arrayLength = array.length;
|
|
119
|
-
if (arrayLength === 0) return
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
after: mapReverse ? void 0 : mapCallback
|
|
134
|
-
};
|
|
135
|
-
const simple = callbacks?.bool != null || type === "all" && key == null;
|
|
136
|
-
const findParameters = {
|
|
137
|
-
array,
|
|
138
|
-
arrayLength,
|
|
139
|
-
flat,
|
|
140
|
-
limit,
|
|
141
|
-
map,
|
|
142
|
-
result,
|
|
143
|
-
type,
|
|
144
|
-
value,
|
|
145
|
-
callback: simple ? callbacks?.bool : callbacks?.keyed
|
|
146
|
-
};
|
|
147
|
-
return simple ? findSimpleValues(findParameters) : findComplexValues(findParameters);
|
|
148
|
-
}
|
|
149
|
-
// src/array/filter.ts
|
|
150
|
-
function exclude(array, ...parameters) {
|
|
151
|
-
return findValues("all", array, parameters).notMatched;
|
|
152
|
-
}
|
|
153
|
-
function filter(array, ...parameters) {
|
|
154
|
-
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
|
+
}
|
|
155
58
|
}
|
|
156
|
-
filter.remove = exclude;
|
|
157
59
|
// src/array/find.ts
|
|
158
60
|
function find(array, ...parameters) {
|
|
159
|
-
return findValue(
|
|
61
|
+
return findValue(array, {
|
|
62
|
+
input: parameters,
|
|
63
|
+
reverse: false
|
|
64
|
+
})?.values[0];
|
|
160
65
|
}
|
|
161
66
|
function findLast(array, ...parameters) {
|
|
162
|
-
return findValue(
|
|
67
|
+
return findValue(array, {
|
|
68
|
+
input: parameters,
|
|
69
|
+
reverse: true
|
|
70
|
+
})?.values[0];
|
|
163
71
|
}
|
|
164
72
|
find.last = findLast;
|
|
165
73
|
// src/array/first.ts
|
|
166
74
|
function first(array, ...parameters) {
|
|
167
|
-
return
|
|
75
|
+
return findValue(array, {
|
|
76
|
+
bare: true,
|
|
77
|
+
input: parameters
|
|
78
|
+
})?.values[0];
|
|
168
79
|
}
|
|
169
80
|
function firstOrDefault(array, defaultValue, ...parameters) {
|
|
170
|
-
return
|
|
81
|
+
return findValue(array, {
|
|
82
|
+
bare: true,
|
|
83
|
+
input: parameters
|
|
84
|
+
})?.values[0] ?? defaultValue;
|
|
171
85
|
}
|
|
172
86
|
first.defaulted = firstOrDefault;
|
|
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
|
+
}
|
|
173
103
|
// src/internal/array/group.ts
|
|
174
104
|
function groupValues(array, key, value, arrays) {
|
|
175
105
|
if (!Array.isArray(array) || array.length === 0) return {};
|
|
@@ -631,13 +561,13 @@ function getComparison(first, second, isIntersection, isUnion, key) {
|
|
|
631
561
|
}
|
|
632
562
|
const source = isUnion ? second : first;
|
|
633
563
|
length = source.length;
|
|
634
|
-
const
|
|
564
|
+
const compared = isUnion ? first.slice() : [];
|
|
635
565
|
for (let index = 0; index < length; index += 1) {
|
|
636
566
|
const item = source[index];
|
|
637
567
|
const value = callback?.(item, index, source) ?? item;
|
|
638
|
-
if (isIntersection ? set.has(value) : !set.has(value))
|
|
568
|
+
if (isIntersection ? set.has(value) : !set.has(value)) compared.push(item);
|
|
639
569
|
}
|
|
640
|
-
return
|
|
570
|
+
return compared;
|
|
641
571
|
}
|
|
642
572
|
// src/array/difference.ts
|
|
643
573
|
function difference(first, second, key) {
|
|
@@ -645,8 +575,16 @@ function difference(first, second, key) {
|
|
|
645
575
|
}
|
|
646
576
|
// src/array/exists.ts
|
|
647
577
|
function exists(array, ...parameters) {
|
|
648
|
-
if (
|
|
649
|
-
|
|
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));
|
|
650
588
|
}
|
|
651
589
|
// src/array/flatten.ts
|
|
652
590
|
/**
|
|
@@ -786,8 +724,30 @@ function intersection(first, second, key) {
|
|
|
786
724
|
return compareSets(ARRAY_SETS_COMPARE_INTERSECTION, first, second, key);
|
|
787
725
|
}
|
|
788
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
|
+
}
|
|
789
736
|
function partition(array, ...parameters) {
|
|
790
|
-
|
|
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
|
+
}
|
|
791
751
|
return [matched, notMatched];
|
|
792
752
|
}
|
|
793
753
|
// src/array/push.ts
|
|
@@ -836,9 +796,13 @@ function reverse(array) {
|
|
|
836
796
|
}
|
|
837
797
|
// src/array/single.ts
|
|
838
798
|
function single(array, ...parameters) {
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
-
|
|
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];
|
|
842
806
|
}
|
|
843
807
|
const SINGLE_MESSAGE = "Multiple items were found";
|
|
844
808
|
// src/array/slice.ts
|
|
@@ -949,7 +913,21 @@ function union(first, second, key) {
|
|
|
949
913
|
// src/array/unique.ts
|
|
950
914
|
function unique(array, key) {
|
|
951
915
|
if (!Array.isArray(array)) return [];
|
|
952
|
-
|
|
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;
|
|
953
931
|
}
|
|
954
932
|
// src/array/update.ts
|
|
955
933
|
function update(array, values, key) {
|
|
@@ -957,10 +935,18 @@ function update(array, values, key) {
|
|
|
957
935
|
}
|
|
958
936
|
// src/array/last.ts
|
|
959
937
|
function last(array, ...parameters) {
|
|
960
|
-
return
|
|
938
|
+
return findValue(array, {
|
|
939
|
+
bare: true,
|
|
940
|
+
input: parameters,
|
|
941
|
+
reverse: true
|
|
942
|
+
})?.values[0];
|
|
961
943
|
}
|
|
962
944
|
function lastOrDefault(array, defaultValue, ...parameters) {
|
|
963
|
-
return
|
|
945
|
+
return findValue(array, {
|
|
946
|
+
bare: true,
|
|
947
|
+
input: parameters,
|
|
948
|
+
reverse: true
|
|
949
|
+
})?.values[0] ?? defaultValue;
|
|
964
950
|
}
|
|
965
951
|
last.defaulted = lastOrDefault;
|
|
966
952
|
// src/internal/array/overlap.ts
|
|
@@ -1067,12 +1053,46 @@ function flatMapAndFilter(array, mapper, filter) {
|
|
|
1067
1053
|
function mapAndFilter(array, mapper, filter) {
|
|
1068
1054
|
return selectValues(array, filter, mapper, false, true);
|
|
1069
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
|
+
}
|
|
1070
1091
|
function selectValues(array, filter, mapper, flat, reverse) {
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
} }).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);
|
|
1076
1096
|
}
|
|
1077
1097
|
filterAndMap.flat = filterAndFlatMap;
|
|
1078
1098
|
filterAndMap.reverse = mapAndFilter;
|
|
@@ -1544,10 +1564,17 @@ sort.initialize = initializeSorter;
|
|
|
1544
1564
|
sort.is = isSorted;
|
|
1545
1565
|
// src/internal/array/index-of.ts
|
|
1546
1566
|
function indexOf(array, ...parameters) {
|
|
1547
|
-
return findValue(
|
|
1567
|
+
return findValue(array, {
|
|
1568
|
+
indiced: true,
|
|
1569
|
+
input: parameters
|
|
1570
|
+
})?.values[0] ?? -1;
|
|
1548
1571
|
}
|
|
1549
1572
|
function lastIndexOf(array, ...parameters) {
|
|
1550
|
-
return findValue(
|
|
1573
|
+
return findValue(array, {
|
|
1574
|
+
indiced: true,
|
|
1575
|
+
input: parameters,
|
|
1576
|
+
reverse: true
|
|
1577
|
+
})?.values[0] ?? -1;
|
|
1551
1578
|
}
|
|
1552
1579
|
indexOf.last = lastIndexOf;
|
|
1553
1580
|
// src/array/swap.ts
|
|
@@ -1652,7 +1679,6 @@ function unwrapWork(value) {
|
|
|
1652
1679
|
const LIMITER_DEBOUNCE = "debounce";
|
|
1653
1680
|
const LIMITER_NAME_ASYNC = "asyncLimiter";
|
|
1654
1681
|
const LIMITER_NAME_SYNC = "limiter";
|
|
1655
|
-
const LIMITER_PROPERTY = "$limiter";
|
|
1656
1682
|
const LIMITER_SYMBOL = Symbol("limiter");
|
|
1657
1683
|
const LIMITER_THROTTLE = "throttle";
|
|
1658
1684
|
const LIMITER_WAIT = "wait";
|
|
@@ -1673,11 +1699,11 @@ function AsyncLimiter(type, callback, time) {
|
|
|
1673
1699
|
callback,
|
|
1674
1700
|
type,
|
|
1675
1701
|
interval: getNumberOrDefault(time, 0),
|
|
1702
|
+
name: LIMITER_NAME_ASYNC,
|
|
1676
1703
|
parameters: [],
|
|
1677
1704
|
throttle: type === LIMITER_THROTTLE
|
|
1678
1705
|
};
|
|
1679
1706
|
}
|
|
1680
|
-
AsyncLimiter.prototype[LIMITER_PROPERTY] = LIMITER_NAME_ASYNC;
|
|
1681
1707
|
AsyncLimiter.prototype.cancel = cancelAsyncLimiter;
|
|
1682
1708
|
AsyncLimiter.prototype.run = runAsyncLimiter;
|
|
1683
1709
|
function Limiter(type, callback, time) {
|
|
@@ -1685,11 +1711,11 @@ function Limiter(type, callback, time) {
|
|
|
1685
1711
|
callback,
|
|
1686
1712
|
type,
|
|
1687
1713
|
interval: getNumberOrDefault(time, 0),
|
|
1714
|
+
name: LIMITER_NAME_SYNC,
|
|
1688
1715
|
parameters: [],
|
|
1689
1716
|
throttle: type === LIMITER_THROTTLE
|
|
1690
1717
|
};
|
|
1691
1718
|
}
|
|
1692
|
-
Limiter.prototype[LIMITER_PROPERTY] = LIMITER_NAME_SYNC;
|
|
1693
1719
|
Limiter.prototype.cancel = cancelLimiter;
|
|
1694
1720
|
Limiter.prototype.run = runLimiter;
|
|
1695
1721
|
function cancelAsyncLimiter() {
|
|
@@ -1716,13 +1742,13 @@ async function handleAsyncLimiter(state, item) {
|
|
|
1716
1742
|
if (state.interval === 0 || now - state.start >= state.interval - 5) {
|
|
1717
1743
|
state.start = state.throttle ? now : void 0;
|
|
1718
1744
|
item.running = true;
|
|
1719
|
-
const
|
|
1745
|
+
const attempted = await asyncAttempt(async () => {
|
|
1720
1746
|
let value = state.callback(...item.parameters);
|
|
1721
1747
|
if (value instanceof Promise) value = await value;
|
|
1722
1748
|
return value;
|
|
1723
1749
|
});
|
|
1724
|
-
if (
|
|
1725
|
-
else item.reject(
|
|
1750
|
+
if (attempted.ok) item.resolve(attempted.value);
|
|
1751
|
+
else item.reject(attempted.error);
|
|
1726
1752
|
item.running = false;
|
|
1727
1753
|
} else state.timer = startTimer(() => handleAsyncLimiter(state, item));
|
|
1728
1754
|
}
|
|
@@ -1950,10 +1976,9 @@ assert.property = assertProperty;
|
|
|
1950
1976
|
// src/models/function/once.model.ts
|
|
1951
1977
|
const ONCE_NAME_ASYNC = "asyncOnce";
|
|
1952
1978
|
const ONCE_NAME_SYNC = "once";
|
|
1953
|
-
const ONCE_PROPERTY = "$once";
|
|
1954
1979
|
const ONCE_MESSAGE_CLEARED = "Once has been cleared";
|
|
1955
1980
|
const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
|
|
1956
|
-
const ONCE_SYMBOL = Symbol(
|
|
1981
|
+
const ONCE_SYMBOL = Symbol("once");
|
|
1957
1982
|
// src/function/once.ts
|
|
1958
1983
|
function AsyncOnce(callback) {
|
|
1959
1984
|
this[ONCE_SYMBOL] = {
|
|
@@ -1963,10 +1988,10 @@ function AsyncOnce(callback) {
|
|
|
1963
1988
|
error: false,
|
|
1964
1989
|
finished: false,
|
|
1965
1990
|
items: [],
|
|
1991
|
+
type: ONCE_NAME_ASYNC,
|
|
1966
1992
|
value: void 0
|
|
1967
1993
|
};
|
|
1968
1994
|
}
|
|
1969
|
-
AsyncOnce.prototype[ONCE_PROPERTY] = ONCE_NAME_ASYNC;
|
|
1970
1995
|
AsyncOnce.prototype.clear = clearOnce;
|
|
1971
1996
|
AsyncOnce.prototype.run = runOnceAsync;
|
|
1972
1997
|
Object.defineProperties(AsyncOnce.prototype, {
|
|
@@ -1992,10 +2017,10 @@ function Once(callback) {
|
|
|
1992
2017
|
callback,
|
|
1993
2018
|
called: false,
|
|
1994
2019
|
cleared: false,
|
|
2020
|
+
type: ONCE_NAME_SYNC,
|
|
1995
2021
|
value: void 0
|
|
1996
2022
|
};
|
|
1997
2023
|
}
|
|
1998
|
-
Once.prototype[ONCE_PROPERTY] = ONCE_NAME_SYNC;
|
|
1999
2024
|
Once.prototype.clear = clearOnce;
|
|
2000
2025
|
Once.prototype.run = runOnce;
|
|
2001
2026
|
Object.defineProperties(Once.prototype, {
|
|
@@ -2058,7 +2083,7 @@ function handleOnceResult(state, value, error) {
|
|
|
2058
2083
|
* @returns `true` if the value is an asynchronous once callback, otherwise `false`
|
|
2059
2084
|
*/
|
|
2060
2085
|
function isAsyncOnce(value) {
|
|
2061
|
-
return isOnceInstance(
|
|
2086
|
+
return isOnceInstance(ONCE_NAME_ASYNC, value);
|
|
2062
2087
|
}
|
|
2063
2088
|
/**
|
|
2064
2089
|
* Is the value a once callback?
|
|
@@ -2067,10 +2092,10 @@ function isAsyncOnce(value) {
|
|
|
2067
2092
|
* @returns `true` if the value is a once callback, otherwise `false`
|
|
2068
2093
|
*/
|
|
2069
2094
|
function isOnce(value) {
|
|
2070
|
-
return isOnceInstance(
|
|
2095
|
+
return isOnceInstance(ONCE_NAME_SYNC, value);
|
|
2071
2096
|
}
|
|
2072
|
-
function isOnceInstance(
|
|
2073
|
-
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;
|
|
2074
2099
|
}
|
|
2075
2100
|
/**
|
|
2076
2101
|
* Create a function that can only be called once, returning the same value on subsequent calls
|
|
@@ -2145,12 +2170,12 @@ const RETRY_MESSAGE_FAILED = "Retry failed";
|
|
|
2145
2170
|
async function asyncRetry(callback, options) {
|
|
2146
2171
|
if (typeof callback !== "function") throw new TypeError(RETRY_MESSAGE_EXPECTATION);
|
|
2147
2172
|
async function handle() {
|
|
2148
|
-
const
|
|
2149
|
-
if (
|
|
2150
|
-
resolver(
|
|
2173
|
+
const attempted = await asyncAttempt(async () => callback());
|
|
2174
|
+
if (attempted.ok) {
|
|
2175
|
+
resolver(attempted.value);
|
|
2151
2176
|
return;
|
|
2152
2177
|
}
|
|
2153
|
-
if (attempts >= times || !when(
|
|
2178
|
+
if (attempts >= times || !when(attempted.error)) rejector(new RetryError(RETRY_MESSAGE_FAILED, attempted.error));
|
|
2154
2179
|
else {
|
|
2155
2180
|
attempts += 1;
|
|
2156
2181
|
limiter.run();
|
|
@@ -2187,10 +2212,10 @@ function retry(callback, options) {
|
|
|
2187
2212
|
const { times, when } = createRetryOptions(options);
|
|
2188
2213
|
let last;
|
|
2189
2214
|
for (let index = 0; index <= times; index += 1) {
|
|
2190
|
-
const
|
|
2191
|
-
if (
|
|
2192
|
-
if (index >= times || !when(
|
|
2193
|
-
last =
|
|
2215
|
+
const attempted = attempt(callback);
|
|
2216
|
+
if (attempted.ok) return attempted.value;
|
|
2217
|
+
if (index >= times || !when(attempted.error)) {
|
|
2218
|
+
last = attempted.error;
|
|
2194
2219
|
break;
|
|
2195
2220
|
}
|
|
2196
2221
|
}
|
|
@@ -2322,6 +2347,9 @@ var SizedMap = class extends Map {
|
|
|
2322
2347
|
get full() {
|
|
2323
2348
|
return super.size >= this.#maximumSize;
|
|
2324
2349
|
}
|
|
2350
|
+
/**
|
|
2351
|
+
* The maximum size of the _Map_
|
|
2352
|
+
*/
|
|
2325
2353
|
get maximum() {
|
|
2326
2354
|
return this.#maximumSize;
|
|
2327
2355
|
}
|
|
@@ -2932,6 +2960,18 @@ function createAborter(value, onAbort) {
|
|
|
2932
2960
|
};
|
|
2933
2961
|
}
|
|
2934
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
|
+
}
|
|
2935
2975
|
async function asyncGenerate(input, unwrap, first, second) {
|
|
2936
2976
|
const aborter = createAborter(second ?? first, noop);
|
|
2937
2977
|
if (aborter?.signal.aborted) throw aborter.signal.reason;
|
|
@@ -2939,54 +2979,88 @@ async function asyncGenerate(input, unwrap, first, second) {
|
|
|
2939
2979
|
let generator;
|
|
2940
2980
|
if (typeof input === "function") generator = input(...parameters);
|
|
2941
2981
|
else generator = input.generator(...parameters);
|
|
2982
|
+
let aborted = false;
|
|
2942
2983
|
let success = true;
|
|
2984
|
+
let throwing = false;
|
|
2985
|
+
let lastError;
|
|
2943
2986
|
let lastValue;
|
|
2944
2987
|
try {
|
|
2945
2988
|
while (true) {
|
|
2946
|
-
if (aborter?.signal.aborted)
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
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;
|
|
2952
3005
|
lastValue = value;
|
|
2953
|
-
|
|
3006
|
+
throwing = false;
|
|
3007
|
+
if (done) break;
|
|
2954
3008
|
}
|
|
2955
3009
|
} catch (error) {
|
|
2956
|
-
|
|
3010
|
+
lastError = error;
|
|
2957
3011
|
success = false;
|
|
2958
3012
|
} finally {
|
|
2959
3013
|
aborter?.cancel();
|
|
2960
|
-
await generator
|
|
3014
|
+
await asyncCleanup(generator, lastValue);
|
|
2961
3015
|
}
|
|
2962
3016
|
if (aborter?.signal.aborted) throw aborter.signal.reason;
|
|
2963
3017
|
if (success) return unwrap && isOk(lastValue) ? lastValue.value : lastValue;
|
|
2964
|
-
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
|
+
};
|
|
2965
3026
|
}
|
|
2966
3027
|
function generate(input, parameters, unwrap) {
|
|
2967
3028
|
let generator;
|
|
2968
3029
|
if (typeof input === "function") generator = input(...parameters);
|
|
2969
3030
|
else generator = input.generator(...parameters);
|
|
2970
3031
|
let success = true;
|
|
3032
|
+
let throwing = false;
|
|
3033
|
+
let lastError;
|
|
2971
3034
|
let lastValue;
|
|
2972
3035
|
try {
|
|
2973
3036
|
while (true) {
|
|
2974
|
-
const
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
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;
|
|
2979
3047
|
lastValue = value;
|
|
3048
|
+
throwing = false;
|
|
2980
3049
|
if (done) break;
|
|
2981
3050
|
}
|
|
2982
3051
|
} catch (error) {
|
|
2983
|
-
|
|
3052
|
+
lastError = error;
|
|
2984
3053
|
success = false;
|
|
2985
|
-
} finally {
|
|
2986
|
-
generator.return(lastValue);
|
|
2987
3054
|
}
|
|
2988
3055
|
if (success) return unwrap && isOk(lastValue) ? lastValue.value : lastValue;
|
|
2989
|
-
throw
|
|
3056
|
+
throw lastError;
|
|
3057
|
+
}
|
|
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
|
+
};
|
|
2990
3064
|
}
|
|
2991
3065
|
// src/internal/plan/index.ts
|
|
2992
3066
|
function attemptRunPlan(...parameters) {
|
|
@@ -3240,7 +3314,10 @@ function Step(generator) {
|
|
|
3240
3314
|
}
|
|
3241
3315
|
Step.prototype[Symbol.iterator] = getGenerator;
|
|
3242
3316
|
function asyncUse(value) {
|
|
3243
|
-
return new AsyncStep(
|
|
3317
|
+
return new AsyncStep(getAsyncUseStep(value));
|
|
3318
|
+
}
|
|
3319
|
+
function getAsyncUseStep(value) {
|
|
3320
|
+
return async function* () {
|
|
3244
3321
|
let actual = value;
|
|
3245
3322
|
if (typeof actual === "function") actual = actual();
|
|
3246
3323
|
actual = await actual;
|
|
@@ -3257,11 +3334,10 @@ function asyncUse(value) {
|
|
|
3257
3334
|
return;
|
|
3258
3335
|
}
|
|
3259
3336
|
return actual;
|
|
3260
|
-
}
|
|
3337
|
+
};
|
|
3261
3338
|
}
|
|
3262
|
-
function
|
|
3263
|
-
|
|
3264
|
-
return new Step(function* () {
|
|
3339
|
+
function getUseStep(value) {
|
|
3340
|
+
return function* () {
|
|
3265
3341
|
let actual = value;
|
|
3266
3342
|
if (typeof actual === "function") {
|
|
3267
3343
|
actual = actual();
|
|
@@ -3279,7 +3355,11 @@ function use(value) {
|
|
|
3279
3355
|
return;
|
|
3280
3356
|
}
|
|
3281
3357
|
return actual;
|
|
3282
|
-
}
|
|
3358
|
+
};
|
|
3359
|
+
}
|
|
3360
|
+
function use(value) {
|
|
3361
|
+
validateUseInput(value, false);
|
|
3362
|
+
return new Step(getUseStep(value));
|
|
3283
3363
|
}
|
|
3284
3364
|
function validateUseInput(value, resolved) {
|
|
3285
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);
|
|
@@ -3313,13 +3393,13 @@ var CancelablePromise = class extends Promise {
|
|
|
3313
3393
|
/**
|
|
3314
3394
|
* An error thrown when a promise times out
|
|
3315
3395
|
*/
|
|
3316
|
-
var
|
|
3396
|
+
var TimedError = class extends Error {
|
|
3317
3397
|
constructor() {
|
|
3318
3398
|
super(PROMISE_MESSAGE_TIMEOUT);
|
|
3319
3399
|
this.name = PROMISE_ERROR_NAME;
|
|
3320
3400
|
}
|
|
3321
3401
|
};
|
|
3322
|
-
const PROMISE_ERROR_NAME = "
|
|
3402
|
+
const PROMISE_ERROR_NAME = "TimedError";
|
|
3323
3403
|
const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
3324
3404
|
const PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE = "promises expected an array or object holding promise-functions or promises";
|
|
3325
3405
|
const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
@@ -3464,7 +3544,7 @@ async function getTimedPromise(promise, time, signal) {
|
|
|
3464
3544
|
limiter.cancel();
|
|
3465
3545
|
rejector(signal?.reason);
|
|
3466
3546
|
});
|
|
3467
|
-
const limiter = getLimiter(LIMITER_WAIT, () => settlePromise(rejector, new
|
|
3547
|
+
const limiter = getLimiter(LIMITER_WAIT, () => settlePromise(rejector, new TimedError(), aborter), time);
|
|
3468
3548
|
let rejector;
|
|
3469
3549
|
return Promise.race([promise, new Promise((_, reject) => {
|
|
3470
3550
|
rejector = reject;
|
|
@@ -3492,13 +3572,13 @@ async function attemptPromise(value, options) {
|
|
|
3492
3572
|
rejector(signal?.reason);
|
|
3493
3573
|
});
|
|
3494
3574
|
async function handler(resolve, reject) {
|
|
3495
|
-
const
|
|
3575
|
+
const attempted = await asyncAttempt(async () => {
|
|
3496
3576
|
let result = isFunction ? value() : await value;
|
|
3497
3577
|
if (result instanceof Promise) result = await result;
|
|
3498
3578
|
return result;
|
|
3499
3579
|
});
|
|
3500
|
-
if (
|
|
3501
|
-
else settlePromise(reject,
|
|
3580
|
+
if (attempted.ok) settlePromise(resolve, attempted.value, aborter);
|
|
3581
|
+
else settlePromise(reject, attempted.error, aborter);
|
|
3502
3582
|
}
|
|
3503
3583
|
let rejector;
|
|
3504
3584
|
const promise = new Promise((resolve, reject) => {
|
|
@@ -3629,13 +3709,11 @@ attemptPipe.async = attemptAsyncPipe;
|
|
|
3629
3709
|
const FUZZY_BOUNDARY_SEPARATOR = /[\s./:\\_-]/;
|
|
3630
3710
|
const FUZZY_MESSAGE_ARRAY = "Fuzzy requires an array of items";
|
|
3631
3711
|
const FUZZY_MESSAGE_HANDLER = "Fuzzy requires a key or function to stringify items";
|
|
3632
|
-
const
|
|
3633
|
-
const FUZZY_SYMBOL = Symbol(FUZZY_PROPERTY);
|
|
3712
|
+
const FUZZY_SYMBOL = Symbol("fuzzy");
|
|
3634
3713
|
// src/string/fuzzy.ts
|
|
3635
3714
|
function Fuzzy(state) {
|
|
3636
3715
|
this[FUZZY_SYMBOL] = state;
|
|
3637
3716
|
}
|
|
3638
|
-
Fuzzy.prototype[FUZZY_PROPERTY] = true;
|
|
3639
3717
|
Fuzzy.prototype.search = search;
|
|
3640
3718
|
Object.defineProperties(Fuzzy.prototype, {
|
|
3641
3719
|
items: {
|
|
@@ -3843,7 +3921,7 @@ function isBoundary(string, index) {
|
|
|
3843
3921
|
* @returns `true` if the value is a fuzzy searcher, otherwise `false`
|
|
3844
3922
|
*/
|
|
3845
3923
|
function isFuzzy(value) {
|
|
3846
|
-
return typeof value === "object" && value !== null &&
|
|
3924
|
+
return typeof value === "object" && value !== null && FUZZY_SYMBOL in value;
|
|
3847
3925
|
}
|
|
3848
3926
|
function search(input, option) {
|
|
3849
3927
|
const state = this[FUZZY_SYMBOL];
|
|
@@ -4907,27 +4985,23 @@ const SUBSCRIPTION_DISALLOWED_KEY = "Disallowed key for subscription";
|
|
|
4907
4985
|
const SUBSCRIPTION_INVALID_KEY = "Invalid key for subscription";
|
|
4908
4986
|
const SUBSCRIPTION_INVALID_VALUE = "A subscription requires a non-null value to identify it";
|
|
4909
4987
|
const SUBSCRIPTION_NAME = "subscription";
|
|
4910
|
-
const SUBSCRIPTION_PROPERTY = "$subscription";
|
|
4911
4988
|
const SUBSCRIPTION_STORE = "subscriptions";
|
|
4912
|
-
const SUBSCRIPTION_SYMBOL = Symbol(
|
|
4989
|
+
const SUBSCRIPTION_SYMBOL = Symbol("subscription");
|
|
4913
4990
|
// src/internal/subscription.ts
|
|
4914
|
-
function Subscription(state,
|
|
4991
|
+
function Subscription(state, parameters) {
|
|
4915
4992
|
this[SUBSCRIPTION_SYMBOL] = state;
|
|
4916
|
-
this[property.key] = property.value;
|
|
4917
4993
|
state.aborter = createAborter(parameters.signal, () => this.unsubscribe(subscriptions, this, state));
|
|
4918
4994
|
addSubscription(this);
|
|
4919
4995
|
}
|
|
4920
|
-
Subscription.prototype[SUBSCRIPTION_PROPERTY] = SUBSCRIPTION_NAME;
|
|
4921
4996
|
Subscription.prototype.unsubscribe = removeSubscription;
|
|
4922
4997
|
Object.defineProperty(Subscription.prototype, "active", {
|
|
4923
4998
|
enumerable: true,
|
|
4924
4999
|
get: getSubscriptionActive
|
|
4925
5000
|
});
|
|
4926
5001
|
function Subscriptions(parameters) {
|
|
4927
|
-
const { keys
|
|
4928
|
-
this[SUBSCRIPTION_SYMBOL] = createSubscriptionsState(
|
|
5002
|
+
const { keys } = createSubscriptionsParameters(parameters);
|
|
5003
|
+
this[SUBSCRIPTION_SYMBOL] = createSubscriptionsState(keys);
|
|
4929
5004
|
}
|
|
4930
|
-
Subscriptions.prototype[SUBSCRIPTION_PROPERTY] = SUBSCRIPTION_STORE;
|
|
4931
5005
|
Subscriptions.prototype.clear = clearSubscriptions;
|
|
4932
5006
|
Subscriptions.prototype.create = createSubscription;
|
|
4933
5007
|
Object.defineProperties(Subscriptions.prototype, {
|
|
@@ -4983,7 +5057,8 @@ function createSubscription(params) {
|
|
|
4983
5057
|
const state = {
|
|
4984
5058
|
parameters,
|
|
4985
5059
|
subscriptions,
|
|
4986
|
-
active: true
|
|
5060
|
+
active: true,
|
|
5061
|
+
name: SUBSCRIPTION_NAME
|
|
4987
5062
|
};
|
|
4988
5063
|
const existing = getExistingSubscription(subscriptions, state);
|
|
4989
5064
|
if (existing != null) return [existing, true];
|
|
@@ -4991,7 +5066,7 @@ function createSubscription(params) {
|
|
|
4991
5066
|
if (subscriptions.keys === false) throw new Error(SUBSCRIPTION_DISALLOWED_KEY);
|
|
4992
5067
|
else if (subscriptions.keys !== true && !subscriptions.keys.has(parameters.key)) throw new Error(SUBSCRIPTION_INVALID_KEY);
|
|
4993
5068
|
}
|
|
4994
|
-
return [new Subscription(state,
|
|
5069
|
+
return [new Subscription(state, parameters), false];
|
|
4995
5070
|
}
|
|
4996
5071
|
function getExistingSubscription(subscriptions, state) {
|
|
4997
5072
|
const { values } = subscriptions;
|
|
@@ -5023,26 +5098,16 @@ function createSubscriptionsParameters(input) {
|
|
|
5023
5098
|
let keys;
|
|
5024
5099
|
if (values.keys instanceof Set) keys = values.keys;
|
|
5025
5100
|
else keys = typeof values.keys === "boolean" ? values.keys : false;
|
|
5026
|
-
return {
|
|
5027
|
-
keys,
|
|
5028
|
-
property: createSubscriptionsProperty(values.property)
|
|
5029
|
-
};
|
|
5101
|
+
return { keys };
|
|
5030
5102
|
}
|
|
5031
|
-
function
|
|
5032
|
-
const values = isPlainObject(input) ? input : {};
|
|
5033
|
-
return {
|
|
5034
|
-
key: typeof values.key === "string" ? values.key : SUBSCRIPTION_PROPERTY,
|
|
5035
|
-
value: values.value ?? "subscription"
|
|
5036
|
-
};
|
|
5037
|
-
}
|
|
5038
|
-
function createSubscriptionsState(property, keys) {
|
|
5103
|
+
function createSubscriptionsState(keys) {
|
|
5039
5104
|
return {
|
|
5040
5105
|
keys,
|
|
5041
|
-
property,
|
|
5042
5106
|
items: {
|
|
5043
5107
|
any: /* @__PURE__ */ new Set(),
|
|
5044
5108
|
keyed: keys === false ? void 0 : /* @__PURE__ */ new Map()
|
|
5045
5109
|
},
|
|
5110
|
+
name: SUBSCRIPTION_STORE,
|
|
5046
5111
|
values: {
|
|
5047
5112
|
from: {
|
|
5048
5113
|
any: /* @__PURE__ */ new Map(),
|
|
@@ -5062,10 +5127,10 @@ function createSubscriptionsState(property, keys) {
|
|
|
5062
5127
|
* @returns `true` if the value is a subscription, otherwise `false`
|
|
5063
5128
|
*/
|
|
5064
5129
|
function isSubscription(value) {
|
|
5065
|
-
return isSubscriptionInstance(
|
|
5130
|
+
return isSubscriptionInstance(SUBSCRIPTION_NAME, value);
|
|
5066
5131
|
}
|
|
5067
|
-
function isSubscriptionInstance(
|
|
5068
|
-
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;
|
|
5069
5134
|
}
|
|
5070
5135
|
/**
|
|
5071
5136
|
* Is the value a subscriptions store?
|
|
@@ -5074,7 +5139,7 @@ function isSubscriptionInstance(value, name) {
|
|
|
5074
5139
|
* @returns `true` if the value is a subscriptions store, otherwise `false`
|
|
5075
5140
|
*/
|
|
5076
5141
|
function isSubscriptions(value) {
|
|
5077
|
-
return isSubscriptionInstance(
|
|
5142
|
+
return isSubscriptionInstance(SUBSCRIPTION_STORE, value);
|
|
5078
5143
|
}
|
|
5079
5144
|
function removeFromStore(items, values, subscription, value, key) {
|
|
5080
5145
|
items.delete(subscription);
|
|
@@ -5117,25 +5182,20 @@ function subscriptions(parameters) {
|
|
|
5117
5182
|
// src/models/beacon.model.ts
|
|
5118
5183
|
const BEACON_MESSAGE_RETRIEVE = "Cannot retrieve observable from a closed beacon";
|
|
5119
5184
|
const BEACON_MESSAGE_SUBSCRIBE = "Cannot subscribe to a closed observable";
|
|
5120
|
-
const BEACON_PROPERTY = "$beacon";
|
|
5121
5185
|
const BEACON_NAME = "beacon";
|
|
5122
5186
|
const BEACON_OBSERVABLE = "observable";
|
|
5123
|
-
const BEACON_SYMBOL = Symbol(
|
|
5187
|
+
const BEACON_SYMBOL = Symbol("beacon");
|
|
5124
5188
|
const BEACON_TYPE_ERROR = "error";
|
|
5125
5189
|
const BEACON_TYPE_NEXT = "next";
|
|
5126
|
-
const beaconSubscription = {
|
|
5127
|
-
key: BEACON_PROPERTY,
|
|
5128
|
-
value: SUBSCRIPTION_NAME
|
|
5129
|
-
};
|
|
5130
5190
|
// src/beacon.ts
|
|
5131
5191
|
function Beacon(value, options) {
|
|
5132
5192
|
this[BEACON_SYMBOL] = {
|
|
5133
5193
|
value,
|
|
5134
5194
|
active: true,
|
|
5135
|
-
options: createBeaconOptions(options)
|
|
5195
|
+
options: createBeaconOptions(options),
|
|
5196
|
+
name: BEACON_NAME
|
|
5136
5197
|
};
|
|
5137
5198
|
}
|
|
5138
|
-
Beacon.prototype[BEACON_PROPERTY] = BEACON_NAME;
|
|
5139
5199
|
Beacon.prototype.deactivate = deactivateBeacon;
|
|
5140
5200
|
Beacon.prototype.emit = emitBeaconValue;
|
|
5141
5201
|
Beacon.prototype.error = emitBeaconError;
|
|
@@ -5157,10 +5217,10 @@ Object.defineProperties(Beacon.prototype, {
|
|
|
5157
5217
|
function Observable(beacon) {
|
|
5158
5218
|
this[BEACON_SYMBOL] = {
|
|
5159
5219
|
beacon,
|
|
5160
|
-
active: beacon.active
|
|
5220
|
+
active: beacon.active,
|
|
5221
|
+
name: BEACON_OBSERVABLE
|
|
5161
5222
|
};
|
|
5162
5223
|
}
|
|
5163
|
-
Observable.prototype[BEACON_PROPERTY] = BEACON_OBSERVABLE;
|
|
5164
5224
|
Observable.prototype.deactivate = deactivateObservable;
|
|
5165
5225
|
Observable.prototype.subscribe = subscribeToObservable;
|
|
5166
5226
|
Object.defineProperty(Observable.prototype, "active", {
|
|
@@ -5251,16 +5311,7 @@ function isBeacon(value) {
|
|
|
5251
5311
|
return isBeaconInstance(BEACON_NAME, value);
|
|
5252
5312
|
}
|
|
5253
5313
|
function isBeaconInstance(name, value) {
|
|
5254
|
-
return typeof value === "object" && value !== null &&
|
|
5255
|
-
}
|
|
5256
|
-
/**
|
|
5257
|
-
* Is the value a beacon subscription?
|
|
5258
|
-
*
|
|
5259
|
-
* @param value Value to check
|
|
5260
|
-
* @returns `true` if the value is a beacon subscription, otherwise `false`
|
|
5261
|
-
*/
|
|
5262
|
-
function isBeaconSubscription(value) {
|
|
5263
|
-
return isSubscription(value) && value["$beacon"] === "subscription";
|
|
5314
|
+
return typeof value === "object" && value !== null && BEACON_SYMBOL in value && value[BEACON_SYMBOL].name === name;
|
|
5264
5315
|
}
|
|
5265
5316
|
/**
|
|
5266
5317
|
* Is the value an observable?
|
|
@@ -5274,7 +5325,7 @@ function isObservable(value) {
|
|
|
5274
5325
|
function subscribeToObservable(first, second, third) {
|
|
5275
5326
|
const state = this[BEACON_SYMBOL];
|
|
5276
5327
|
if (!state.beacon.active || !state.active) throw new Error(BEACON_MESSAGE_SUBSCRIBE);
|
|
5277
|
-
state.beacon.subscriptions ??= subscriptions(
|
|
5328
|
+
state.beacon.subscriptions ??= subscriptions();
|
|
5278
5329
|
const observer = createObserver(first, second, third);
|
|
5279
5330
|
const [subscription] = state.beacon.subscriptions.create({
|
|
5280
5331
|
isActive: () => state.beacon.active && state.active,
|
|
@@ -5297,27 +5348,21 @@ function updateBeacon(instance, type, value, finish) {
|
|
|
5297
5348
|
// src/models/herald.model.ts
|
|
5298
5349
|
const HERALD_MESSAGE_ARRAY = "Herald requires an array of event names.";
|
|
5299
5350
|
const HERALD_MESSAGE_ONCREATE = `Herald requires a valid onCreate callback for subscription creation`;
|
|
5300
|
-
const HERALD_MESSAGE_PROPERTY = `Herald requires valid property information for subscription identification`;
|
|
5301
5351
|
const HERALD_NAME_EVENTS = "events";
|
|
5302
5352
|
const HERALD_NAME_HERALD = "herald";
|
|
5303
|
-
const
|
|
5304
|
-
const HERALD_SYMBOL = Symbol(HERALD_PROPERTY);
|
|
5305
|
-
const heraldSubscription = {
|
|
5306
|
-
key: HERALD_PROPERTY,
|
|
5307
|
-
value: SUBSCRIPTION_NAME
|
|
5308
|
-
};
|
|
5353
|
+
const HERALD_SYMBOL = Symbol("herald");
|
|
5309
5354
|
// src/internal/herald.ts
|
|
5310
5355
|
function Events(herald, state) {
|
|
5356
|
+
this[HERALD_SYMBOL] = { name: HERALD_NAME_EVENTS };
|
|
5311
5357
|
for (const key of state.keys) Object.defineProperty(this, key, { value: (callback, signal) => herald.subscribe(key, callback, signal) });
|
|
5312
5358
|
}
|
|
5313
|
-
Events.prototype[HERALD_PROPERTY] = HERALD_NAME_EVENTS;
|
|
5314
5359
|
function Herald(state) {
|
|
5315
5360
|
this[HERALD_SYMBOL] = {
|
|
5316
5361
|
state,
|
|
5317
|
-
events: new Events(this, state)
|
|
5362
|
+
events: new Events(this, state),
|
|
5363
|
+
name: HERALD_NAME_HERALD
|
|
5318
5364
|
};
|
|
5319
5365
|
}
|
|
5320
|
-
Herald.prototype[HERALD_PROPERTY] = HERALD_NAME_HERALD;
|
|
5321
5366
|
Herald.prototype.clear = clearHerald;
|
|
5322
5367
|
Herald.prototype.emit = emitForHerald;
|
|
5323
5368
|
Herald.prototype.observed = eventIsObserved;
|
|
@@ -5336,22 +5381,10 @@ function createHeraldState(input) {
|
|
|
5336
5381
|
const keys = new Set(options.names);
|
|
5337
5382
|
return {
|
|
5338
5383
|
keys,
|
|
5339
|
-
store: subscriptions({
|
|
5340
|
-
keys,
|
|
5341
|
-
property: createHeraldSubscriptionProperty(options.property)
|
|
5342
|
-
}),
|
|
5384
|
+
store: subscriptions({ keys }),
|
|
5343
5385
|
onCreate: options.onCreate
|
|
5344
5386
|
};
|
|
5345
5387
|
}
|
|
5346
|
-
function createHeraldSubscriptionProperty(input) {
|
|
5347
|
-
if (input == null) return heraldSubscription;
|
|
5348
|
-
const property = isPlainObject(input) ? input : {};
|
|
5349
|
-
if (typeof property.key !== "string" || property.value != null && typeof property.value !== "string") throw new Error(HERALD_MESSAGE_PROPERTY);
|
|
5350
|
-
return {
|
|
5351
|
-
key: property.key,
|
|
5352
|
-
value: property.value
|
|
5353
|
-
};
|
|
5354
|
-
}
|
|
5355
5388
|
function emitForHerald(event, ...parameters) {
|
|
5356
5389
|
const { state } = this[HERALD_SYMBOL];
|
|
5357
5390
|
const items = state.store.values.from.keyed?.get(event);
|
|
@@ -5393,16 +5426,7 @@ function isHeraldEvents(value) {
|
|
|
5393
5426
|
return isHeraldInstance(HERALD_NAME_EVENTS, value);
|
|
5394
5427
|
}
|
|
5395
5428
|
function isHeraldInstance(name, value) {
|
|
5396
|
-
return typeof value === "object" && value !== null &&
|
|
5397
|
-
}
|
|
5398
|
-
/**
|
|
5399
|
-
* Is the value a herald subscription?
|
|
5400
|
-
*
|
|
5401
|
-
* @param value Value to check
|
|
5402
|
-
* @returns `true` if the value is a herald subscription, otherwise `false`
|
|
5403
|
-
*/
|
|
5404
|
-
function isHeraldSubscription(value) {
|
|
5405
|
-
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;
|
|
5406
5430
|
}
|
|
5407
5431
|
function subscribeToHerald(key, callback, signal) {
|
|
5408
5432
|
const { state } = this[HERALD_SYMBOL];
|
|
@@ -5483,9 +5507,7 @@ const COLOR_MAX = {
|
|
|
5483
5507
|
hex: 255,
|
|
5484
5508
|
percent: 100
|
|
5485
5509
|
};
|
|
5486
|
-
const
|
|
5487
|
-
const COLOR_PROPERTY = "$color";
|
|
5488
|
-
const COLOR_SYMBOL = Symbol(COLOR_PROPERTY);
|
|
5510
|
+
const COLOR_SYMBOL = Symbol("color");
|
|
5489
5511
|
const COLOR_TYPE = {
|
|
5490
5512
|
all: void 0,
|
|
5491
5513
|
hex: "hex",
|
|
@@ -5520,10 +5542,6 @@ const COLOR_SRGB = {
|
|
|
5520
5542
|
luminanceRed: .2126,
|
|
5521
5543
|
luminanceThreshold: .625
|
|
5522
5544
|
};
|
|
5523
|
-
const colorSubscription = {
|
|
5524
|
-
key: COLOR_PROPERTY,
|
|
5525
|
-
value: SUBSCRIPTION_NAME
|
|
5526
|
-
};
|
|
5527
5545
|
// src/color/misc/alpha.ts
|
|
5528
5546
|
function getAlpha(value, hex) {
|
|
5529
5547
|
if (typeof value === "number") return getAlphaFromValue(value);
|
|
@@ -5712,7 +5730,7 @@ function isBytey(value) {
|
|
|
5712
5730
|
* @returns `true` if the value is a _Color_, otherwise `false`
|
|
5713
5731
|
*/
|
|
5714
5732
|
function isColor(value) {
|
|
5715
|
-
return typeof value === "object" && value !== null &&
|
|
5733
|
+
return typeof value === "object" && value !== null && COLOR_SYMBOL in value;
|
|
5716
5734
|
}
|
|
5717
5735
|
function isColorValue(value, properties) {
|
|
5718
5736
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -6546,13 +6564,11 @@ function Color(value) {
|
|
|
6546
6564
|
this[COLOR_SYMBOL] = {
|
|
6547
6565
|
changes: herald({
|
|
6548
6566
|
names: [COLOR_TYPE.wildcard, ...COLOR_TYPE.all],
|
|
6549
|
-
property: colorSubscription,
|
|
6550
6567
|
onCreate: (event, callback) => onCreateSubscription(this, event, callback)
|
|
6551
6568
|
}),
|
|
6552
6569
|
values: getColorState(value)
|
|
6553
6570
|
};
|
|
6554
6571
|
}
|
|
6555
|
-
Color.prototype[COLOR_PROPERTY] = COLOR_NAME;
|
|
6556
6572
|
Color.prototype.subscribe = subscribeToColor;
|
|
6557
6573
|
Color.prototype.toHexString = formatHexColor;
|
|
6558
6574
|
Color.prototype.toHslString = formatHslColor;
|
|
@@ -6770,11 +6786,11 @@ function isObject(value) {
|
|
|
6770
6786
|
// src/models/logger.model.ts
|
|
6771
6787
|
const LOGGER_NAME = "Logger";
|
|
6772
6788
|
const LOGGER_NAME_TIMED = "TimedLogger";
|
|
6773
|
-
const
|
|
6774
|
-
const LOGGER_SYMBOL = Symbol(LOGGER_PROPERTY);
|
|
6789
|
+
const LOGGER_SYMBOL = Symbol("logger");
|
|
6775
6790
|
// src/logger.ts
|
|
6776
|
-
function Lumberjack() {
|
|
6777
|
-
|
|
6791
|
+
function Lumberjack() {
|
|
6792
|
+
this[LOGGER_SYMBOL] = { name: LOGGER_NAME };
|
|
6793
|
+
}
|
|
6778
6794
|
Lumberjack.prototype.time = getTimeLogger;
|
|
6779
6795
|
Object.defineProperties(Lumberjack.prototype, {
|
|
6780
6796
|
debug: { get: getLoggerCallback.bind("debug") },
|
|
@@ -6794,6 +6810,7 @@ Object.defineProperties(Lumberjack.prototype, {
|
|
|
6794
6810
|
function TimeLogger(label) {
|
|
6795
6811
|
this[LOGGER_SYMBOL] = {
|
|
6796
6812
|
label,
|
|
6813
|
+
name: LOGGER_NAME_TIMED,
|
|
6797
6814
|
started: enabled,
|
|
6798
6815
|
stopped: false
|
|
6799
6816
|
};
|
|
@@ -6802,7 +6819,6 @@ function TimeLogger(label) {
|
|
|
6802
6819
|
};
|
|
6803
6820
|
if (this[LOGGER_SYMBOL].started) console.time(label);
|
|
6804
6821
|
}
|
|
6805
|
-
TimeLogger.prototype[LOGGER_PROPERTY] = LOGGER_NAME_TIMED;
|
|
6806
6822
|
Object.defineProperties(TimeLogger.prototype, {
|
|
6807
6823
|
active: {
|
|
6808
6824
|
enumerable: true,
|
|
@@ -6845,7 +6861,7 @@ function isLogger(value) {
|
|
|
6845
6861
|
return isLoggerInstance(LOGGER_NAME, value);
|
|
6846
6862
|
}
|
|
6847
6863
|
function isLoggerInstance(name, value) {
|
|
6848
|
-
return typeof value === "object" && value !== null &&
|
|
6864
|
+
return typeof value === "object" && value !== null && LOGGER_SYMBOL in value && value[LOGGER_SYMBOL].name === name;
|
|
6849
6865
|
}
|
|
6850
6866
|
/**
|
|
6851
6867
|
* Is the value a _TimeLogger_?
|
|
@@ -7019,21 +7035,20 @@ const QUEUE_MESSAGE_MAXIMUM = "Queue has reached its maximum size";
|
|
|
7019
7035
|
const QUEUE_MESSAGE_REMOVE = "Item removed from queue";
|
|
7020
7036
|
const QUEUE_NAME_KEYED = "keyedQueue";
|
|
7021
7037
|
const QUEUE_NAME_QUEUE = "queue";
|
|
7022
|
-
const QUEUE_PROPERTY = "$queue";
|
|
7023
7038
|
const QUEUE_STATUS_ACTIVE = "active";
|
|
7024
7039
|
const QUEUE_STATUS_EMPTY = "empty";
|
|
7025
7040
|
const QUEUE_STATUS_FULL = "full";
|
|
7026
7041
|
const QUEUE_STATUS_PAUSED = "paused";
|
|
7027
|
-
const QUEUE_SYMBOL = Symbol(
|
|
7042
|
+
const QUEUE_SYMBOL = Symbol("queue");
|
|
7028
7043
|
// src/queue.ts
|
|
7029
7044
|
function KeyedQueue(callback, options) {
|
|
7030
7045
|
this[QUEUE_SYMBOL] = {
|
|
7031
7046
|
callback,
|
|
7032
7047
|
options: createQueueOptions(options),
|
|
7033
|
-
queues: /* @__PURE__ */ new Map()
|
|
7048
|
+
queues: /* @__PURE__ */ new Map(),
|
|
7049
|
+
type: QUEUE_NAME_KEYED
|
|
7034
7050
|
};
|
|
7035
7051
|
}
|
|
7036
|
-
KeyedQueue.prototype[QUEUE_PROPERTY] = QUEUE_NAME_KEYED;
|
|
7037
7052
|
KeyedQueue.prototype.add = addKeyedQueue;
|
|
7038
7053
|
KeyedQueue.prototype.clear = clearQueues;
|
|
7039
7054
|
KeyedQueue.prototype.get = getQueue;
|
|
@@ -7091,10 +7106,10 @@ function Queue(callback, options, key) {
|
|
|
7091
7106
|
id: 0,
|
|
7092
7107
|
items: [],
|
|
7093
7108
|
paused: !options.autostart,
|
|
7094
|
-
runners: 0
|
|
7109
|
+
runners: 0,
|
|
7110
|
+
type: QUEUE_NAME_QUEUE
|
|
7095
7111
|
};
|
|
7096
7112
|
}
|
|
7097
|
-
Queue.prototype[QUEUE_PROPERTY] = QUEUE_NAME_QUEUE;
|
|
7098
7113
|
Queue.prototype.add = addToQueue;
|
|
7099
7114
|
Queue.prototype.clear = clearQueue;
|
|
7100
7115
|
Queue.prototype.pause = pauseQueue;
|
|
@@ -7251,9 +7266,9 @@ function getQueueSize() {
|
|
|
7251
7266
|
}
|
|
7252
7267
|
function getStatus(state, status) {
|
|
7253
7268
|
const queues = state.queues.entries();
|
|
7254
|
-
const
|
|
7255
|
-
for (const [key, queue] of queues) if (queue[status])
|
|
7256
|
-
return
|
|
7269
|
+
const queued = [];
|
|
7270
|
+
for (const [key, queue] of queues) if (queue[status]) queued.push(key);
|
|
7271
|
+
return queued;
|
|
7257
7272
|
}
|
|
7258
7273
|
function handleQueuedResult(item, error, result) {
|
|
7259
7274
|
item.aborter?.cancel();
|
|
@@ -7298,7 +7313,7 @@ function isQueue(value) {
|
|
|
7298
7313
|
return isQueueInstance(QUEUE_NAME_QUEUE, value);
|
|
7299
7314
|
}
|
|
7300
7315
|
function isQueueInstance(name, value) {
|
|
7301
|
-
return typeof value === "object" && value != null &&
|
|
7316
|
+
return typeof value === "object" && value != null && QUEUE_SYMBOL in value && value[QUEUE_SYMBOL].type === name;
|
|
7302
7317
|
}
|
|
7303
7318
|
function keyedQueue(callback, options) {
|
|
7304
7319
|
if (typeof callback !== "function") throw new TypeError(QUEUE_MESSAGE_CALLBACK);
|
|
@@ -7458,6 +7473,9 @@ var SizedSet = class extends Set {
|
|
|
7458
7473
|
get full() {
|
|
7459
7474
|
return this.size >= this.#maximumSize;
|
|
7460
7475
|
}
|
|
7476
|
+
/**
|
|
7477
|
+
* The maximum size of the _Set_
|
|
7478
|
+
*/
|
|
7461
7479
|
get maximum() {
|
|
7462
7480
|
return this.#maximumSize;
|
|
7463
7481
|
}
|
|
@@ -7495,4 +7513,4 @@ var SizedSet = class extends Set {
|
|
|
7495
7513
|
return value;
|
|
7496
7514
|
}
|
|
7497
7515
|
};
|
|
7498
|
-
export { CancelablePromise, Logger,
|
|
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 };
|