@oscarpalmer/atoms 0.202.0 → 0.204.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 +4 -5
- package/dist/array/exists.d.mts +5 -6
- package/dist/array/filter.d.mts +10 -11
- package/dist/array/filter.mjs +0 -1
- package/dist/array/find.d.mts +10 -11
- package/dist/array/find.mjs +0 -1
- package/dist/array/first.d.mts +10 -11
- package/dist/array/first.mjs +0 -1
- package/dist/array/flatten.d.mts +2 -3
- package/dist/array/from.d.mts +7 -8
- package/dist/array/group-by.d.mts +7 -8
- package/dist/array/group-by.mjs +0 -1
- package/dist/array/insert.d.mts +3 -4
- package/dist/array/intersection.d.mts +4 -5
- package/dist/array/last.d.mts +10 -11
- package/dist/array/last.mjs +0 -1
- package/dist/array/move.d.mts +9 -10
- package/dist/array/move.mjs +0 -4
- package/dist/array/partition.d.mts +5 -6
- package/dist/array/push.d.mts +2 -3
- package/dist/array/reverse.d.mts +2 -3
- package/dist/array/select.d.mts +11 -12
- package/dist/array/select.mjs +0 -1
- package/dist/array/single.d.mts +4 -5
- package/dist/array/slice.d.mts +12 -13
- package/dist/array/sort.d.mts +31 -32
- package/dist/array/sort.mjs +38 -39
- package/dist/array/splice.d.mts +5 -6
- package/dist/array/swap.d.mts +8 -9
- package/dist/array/swap.mjs +0 -1
- package/dist/array/to-map.d.mts +7 -8
- package/dist/array/to-map.mjs +0 -1
- package/dist/array/to-record.d.mts +7 -8
- package/dist/array/to-record.mjs +0 -1
- package/dist/array/to-set.d.mts +4 -5
- package/dist/array/toggle.d.mts +4 -5
- package/dist/array/union.d.mts +4 -5
- package/dist/array/unique.d.mts +4 -5
- package/dist/array/update.d.mts +4 -5
- package/dist/beacon.d.mts +8 -9
- package/dist/beacon.mjs +96 -71
- package/dist/color/constants.d.mts +14 -13
- package/dist/color/constants.mjs +9 -2
- package/dist/color/index.d.mts +2 -2
- package/dist/color/instance.d.mts +3 -3
- package/dist/color/instance.mjs +91 -69
- package/dist/color/misc/alpha.d.mts +7 -6
- package/dist/color/misc/alpha.mjs +8 -2
- package/dist/color/misc/format.d.mts +6 -7
- package/dist/color/misc/format.mjs +15 -12
- package/dist/color/misc/get.d.mts +14 -15
- package/dist/color/misc/is.d.mts +16 -17
- package/dist/color/misc/is.mjs +7 -7
- package/dist/color/misc/state.d.mts +33 -10
- package/dist/color/misc/state.mjs +28 -48
- package/dist/color/models.d.mts +25 -19
- package/dist/color/space/hex.d.mts +14 -11
- package/dist/color/space/hex.mjs +21 -2
- package/dist/color/space/hsl.d.mts +13 -10
- package/dist/color/space/hsl.mjs +25 -4
- package/dist/color/space/hwb.d.mts +14 -11
- package/dist/color/space/hwb.mjs +24 -3
- package/dist/color/space/rgb.d.mts +16 -13
- package/dist/color/space/rgb.mjs +41 -20
- package/dist/function/limit.d.mts +9 -8
- package/dist/function/limit.mjs +5 -7
- package/dist/function/once.d.mts +26 -6
- package/dist/function/once.mjs +129 -76
- package/dist/function/retry.d.mts +5 -6
- package/dist/function/retry.mjs +3 -4
- package/dist/index.d.mts +184 -60
- package/dist/index.mjs +1292 -970
- package/dist/internal/aborter.d.mts +9 -0
- package/dist/internal/{abort.mjs → aborter.mjs} +1 -1
- package/dist/internal/array/callbacks.d.mts +4 -5
- package/dist/internal/array/chunk.d.mts +2 -3
- package/dist/internal/array/compact.d.mts +3 -4
- package/dist/internal/array/find.d.mts +10 -11
- package/dist/internal/array/get.d.mts +7 -8
- package/dist/internal/array/get.mjs +3 -2
- package/dist/internal/array/group.d.mts +2 -3
- package/dist/internal/array/index-of.d.mts +10 -11
- package/dist/internal/array/index-of.mjs +0 -1
- package/dist/internal/array/insert.d.mts +5 -6
- package/dist/internal/array/match.d.mts +17 -18
- package/dist/internal/array/overlap.d.mts +2 -3
- package/dist/internal/array/sets.d.mts +5 -6
- package/dist/internal/array/shuffle.d.mts +2 -3
- package/dist/internal/array/update.d.mts +2 -3
- package/dist/internal/defaults.d.mts +3 -4
- package/dist/internal/function/assert.d.mts +10 -11
- package/dist/internal/function/assert.mjs +0 -7
- package/dist/internal/function/limit.d.mts +41 -0
- package/dist/internal/function/limit.mjs +106 -0
- package/dist/internal/function/memoize.d.mts +4 -5
- package/dist/internal/function/memoize.mjs +55 -31
- package/dist/internal/function/misc.d.mts +2 -3
- package/dist/internal/function/work.d.mts +53 -54
- package/dist/internal/function/work.mjs +0 -2
- package/dist/internal/herald.d.mts +8 -9
- package/dist/internal/herald.mjs +38 -27
- package/dist/internal/is.d.mts +19 -20
- package/dist/internal/math/aggregate.d.mts +14 -15
- package/dist/internal/math/misc.d.mts +3 -4
- package/dist/internal/number.d.mts +4 -5
- package/dist/internal/random.d.mts +3 -4
- package/dist/internal/result/misc.d.mts +29 -14
- package/dist/internal/result/misc.mjs +4 -3
- package/dist/internal/result/models.d.mts +9 -10
- package/dist/internal/sized/map.d.mts +2 -3
- package/dist/internal/sized/misc.d.mts +2 -3
- package/dist/internal/string/case.d.mts +9 -10
- package/dist/internal/string/misc.d.mts +8 -9
- package/dist/internal/subscription.d.mts +10 -11
- package/dist/internal/subscription.mjs +72 -58
- package/dist/internal/value/compare.d.mts +17 -9
- package/dist/internal/value/compare.mjs +6 -11
- package/dist/internal/value/equal.d.mts +34 -15
- package/dist/internal/value/equal.mjs +20 -13
- package/dist/internal/value/get.d.mts +3 -4
- package/dist/internal/value/handlers.d.mts +19 -9
- package/dist/internal/value/handlers.mjs +48 -50
- package/dist/internal/value/has.d.mts +6 -7
- package/dist/internal/value/has.mjs +0 -1
- package/dist/internal/value/misc.d.mts +6 -7
- package/dist/internal/value/misc.mjs +4 -3
- package/dist/internal/value/partial.d.mts +3 -4
- package/dist/internal/value/partial.mjs +2 -1
- package/dist/internal/value/set.d.mts +4 -5
- package/dist/internal/value/set.mjs +2 -1
- package/dist/is.d.mts +13 -13
- package/dist/logger.d.mts +5 -4
- package/dist/logger.mjs +72 -64
- package/dist/math.d.mts +20 -20
- package/dist/models.d.mts +45 -49
- package/dist/promise/constants.d.mts +14 -15
- package/dist/promise/delay.d.mts +3 -4
- package/dist/promise/delay.mjs +5 -5
- package/dist/promise/helpers.d.mts +7 -8
- package/dist/promise/helpers.mjs +4 -3
- package/dist/promise/index.d.mts +13 -14
- package/dist/promise/index.mjs +1 -2
- package/dist/promise/misc.d.mts +7 -7
- package/dist/promise/models.d.mts +17 -18
- package/dist/promise/timed.d.mts +4 -5
- package/dist/promise/timed.mjs +6 -6
- package/dist/query.d.mts +3 -4
- package/dist/queue.d.mts +14 -15
- package/dist/queue.mjs +198 -136
- package/dist/random.d.mts +8 -8
- package/dist/result/index.d.mts +8 -9
- package/dist/result/index.mjs +0 -1
- package/dist/result/match.d.mts +6 -7
- package/dist/result/match.mjs +0 -1
- package/dist/result/misc.d.mts +3 -3
- package/dist/result/work/flow.d.mts +28 -29
- package/dist/result/work/flow.mjs +0 -1
- package/dist/result/work/pipe.d.mts +24 -25
- package/dist/result/work/pipe.mjs +0 -1
- package/dist/sized/set.d.mts +2 -3
- package/dist/string/fuzzy.d.mts +21 -12
- package/dist/string/fuzzy.mjs +77 -52
- package/dist/string/index.d.mts +8 -8
- package/dist/string/match.d.mts +4 -5
- package/dist/string/normalize.d.mts +8 -9
- package/dist/string/normalize.mjs +9 -5
- package/dist/string/template.d.mts +9 -9
- package/dist/string/template.mjs +11 -5
- package/dist/value/clone.d.mts +21 -13
- package/dist/value/clone.mjs +19 -25
- package/dist/value/collection.d.mts +4 -5
- package/dist/value/diff.d.mts +5 -6
- package/dist/value/freeze.d.mts +18 -19
- package/dist/value/freeze.mjs +1 -5
- package/dist/value/merge.d.mts +13 -14
- package/dist/value/merge.mjs +21 -7
- package/dist/value/omit.d.mts +2 -3
- package/dist/value/pick.d.mts +2 -3
- package/dist/value/shake.d.mts +3 -4
- package/dist/value/smush.d.mts +3 -4
- package/dist/value/transform.d.mts +15 -10
- package/dist/value/transform.mjs +12 -8
- package/dist/value/unsmush.d.mts +3 -4
- package/package.json +2 -2
- package/dist/internal/abort.d.mts +0 -10
- package/dist/internal/function/timer.d.mts +0 -10
- package/dist/internal/function/timer.mjs +0 -87
package/dist/index.mjs
CHANGED
|
@@ -114,7 +114,6 @@ function filter(array, ...parameters) {
|
|
|
114
114
|
return findValues("all", array, parameters).matched;
|
|
115
115
|
}
|
|
116
116
|
filter.remove = exclude;
|
|
117
|
-
Object.defineProperty(filter, "remove", { value: exclude });
|
|
118
117
|
//#endregion
|
|
119
118
|
//#region src/array/first.ts
|
|
120
119
|
function first(array, ...parameters) {
|
|
@@ -124,7 +123,6 @@ function firstOrDefault(array, defaultValue, ...parameters) {
|
|
|
124
123
|
return findAbsoluteValueOrDefault(array, parameters, defaultValue, true, false);
|
|
125
124
|
}
|
|
126
125
|
first.default = firstOrDefault;
|
|
127
|
-
Object.defineProperty(first, "default", { value: firstOrDefault });
|
|
128
126
|
//#endregion
|
|
129
127
|
//#region src/internal/array/group.ts
|
|
130
128
|
function groupValues(array, key, value, arrays) {
|
|
@@ -153,7 +151,6 @@ function groupArraysBy(array, first, second) {
|
|
|
153
151
|
return groupValues(array, first, second, true);
|
|
154
152
|
}
|
|
155
153
|
groupBy.arrays = groupArraysBy;
|
|
156
|
-
Object.defineProperty(groupBy, "arrays", { value: groupArraysBy });
|
|
157
154
|
//#endregion
|
|
158
155
|
//#region src/internal/array/chunk.ts
|
|
159
156
|
/**
|
|
@@ -379,13 +376,14 @@ function getArray(value, indiced) {
|
|
|
379
376
|
if (value instanceof Set) return [...value.values()];
|
|
380
377
|
if (isNonPlainObject(value)) return [value];
|
|
381
378
|
if (indiced !== true) return Object.entries(value);
|
|
382
|
-
const
|
|
379
|
+
const obj = value;
|
|
380
|
+
const keys = Object.keys(obj);
|
|
383
381
|
const { length } = keys;
|
|
384
382
|
const array = [];
|
|
385
383
|
for (let index = 0; index < length; index += 1) {
|
|
386
384
|
const key = keys[index];
|
|
387
385
|
const asNumber = Number.parseInt(key, 10);
|
|
388
|
-
if (!Number.isNaN(asNumber)) array[asNumber] =
|
|
386
|
+
if (!Number.isNaN(asNumber)) array[asNumber] = obj[key];
|
|
389
387
|
}
|
|
390
388
|
return array;
|
|
391
389
|
}
|
|
@@ -398,7 +396,6 @@ function lastIndexOf(array, ...parameters) {
|
|
|
398
396
|
return findValue(FIND_VALUE_INDEX, array, parameters, true);
|
|
399
397
|
}
|
|
400
398
|
indexOf.last = lastIndexOf;
|
|
401
|
-
Object.defineProperty(indexOf, "last", { value: lastIndexOf });
|
|
402
399
|
//#endregion
|
|
403
400
|
//#region src/internal/array/match.ts
|
|
404
401
|
function endsWithArray(haystack, needle, key) {
|
|
@@ -553,7 +550,6 @@ function findLast(array, ...parameters) {
|
|
|
553
550
|
return findValue(FIND_VALUE_ITEM, array, parameters, true);
|
|
554
551
|
}
|
|
555
552
|
find.last = findLast;
|
|
556
|
-
Object.defineProperty(find, "last", { value: findLast });
|
|
557
553
|
//#endregion
|
|
558
554
|
//#region src/array/flatten.ts
|
|
559
555
|
/**
|
|
@@ -689,7 +685,6 @@ function selectValues(array, parameters) {
|
|
|
689
685
|
}).matched;
|
|
690
686
|
}
|
|
691
687
|
select.reverse = reverseSelect;
|
|
692
|
-
Object.defineProperty(select, "reverse", { value: reverseSelect });
|
|
693
688
|
//#endregion
|
|
694
689
|
//#region src/array/single.ts
|
|
695
690
|
function single(array, ...parameters) {
|
|
@@ -818,7 +813,6 @@ function lastOrDefault(array, defaultValue, ...parameters) {
|
|
|
818
813
|
return findAbsoluteValueOrDefault(array, parameters, defaultValue, true, true);
|
|
819
814
|
}
|
|
820
815
|
last.default = lastOrDefault;
|
|
821
|
-
Object.defineProperty(last, "default", { value: lastOrDefault });
|
|
822
816
|
//#endregion
|
|
823
817
|
//#region src/internal/array/overlap.ts
|
|
824
818
|
function arraysOverlap(first, second) {
|
|
@@ -912,10 +906,6 @@ function moveToIndex(array, value, index, key) {
|
|
|
912
906
|
}
|
|
913
907
|
move.indices = moveIndices;
|
|
914
908
|
move.toIndex = moveToIndex;
|
|
915
|
-
Object.defineProperties(move, {
|
|
916
|
-
indices: { value: moveIndices },
|
|
917
|
-
toIndex: { value: moveToIndex }
|
|
918
|
-
});
|
|
919
909
|
//#endregion
|
|
920
910
|
//#region src/internal/math/aggregate.ts
|
|
921
911
|
function aggregate(type, array, key, first) {
|
|
@@ -1069,59 +1059,57 @@ const STRING_EXPRESSION_IGNORED = /(^|\.)(__proto__|constructor|prototype)(\.|$)
|
|
|
1069
1059
|
const STRING_EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
1070
1060
|
//#endregion
|
|
1071
1061
|
//#region src/internal/value/handlers.ts
|
|
1072
|
-
function
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
handlers.deregister(constructor);
|
|
1077
|
-
},
|
|
1078
|
-
handle(first, second, ...parameters) {
|
|
1079
|
-
const handler = handlers.get(first, second);
|
|
1080
|
-
if (handler == null) return options.callback(first, second, ...parameters);
|
|
1081
|
-
return typeof handler === "function" ? handler(first, second) : first[handler](second);
|
|
1082
|
-
},
|
|
1083
|
-
register(constructor, handler) {
|
|
1084
|
-
handlers.register(constructor, handler);
|
|
1085
|
-
}
|
|
1086
|
-
};
|
|
1062
|
+
function BaseHandler(owner, options) {
|
|
1063
|
+
this.handlers = /* @__PURE__ */ new WeakMap();
|
|
1064
|
+
this.owner = owner;
|
|
1065
|
+
this.options = options;
|
|
1087
1066
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
},
|
|
1094
|
-
get(first, second) {
|
|
1095
|
-
if (isConstructable(first) && isConstructable(second) && first.constructor === second.constructor) return handlers.get(first.constructor);
|
|
1096
|
-
},
|
|
1097
|
-
register(constructor, handler) {
|
|
1098
|
-
if (isNonConstructor(constructor) || handler === owner) return;
|
|
1099
|
-
let actual = handler ?? options.method;
|
|
1100
|
-
if (typeof actual !== "function" && typeof actual !== "string") return;
|
|
1101
|
-
if (typeof actual === "string") actual = typeof constructor.prototype[actual] === "function" ? actual : void 0;
|
|
1102
|
-
if (actual != null) handlers.set(constructor, actual);
|
|
1103
|
-
}
|
|
1104
|
-
};
|
|
1067
|
+
BaseHandler.prototype.deregister = deregisterHandler;
|
|
1068
|
+
BaseHandler.prototype.get = getHandler$1;
|
|
1069
|
+
BaseHandler.prototype.register = registerHandler;
|
|
1070
|
+
function CompareHandler(base) {
|
|
1071
|
+
this.base = base;
|
|
1105
1072
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1073
|
+
CompareHandler.prototype.handle = handleComparison;
|
|
1074
|
+
function ValueHandler(value) {
|
|
1075
|
+
this.base = value;
|
|
1076
|
+
}
|
|
1077
|
+
ValueHandler.prototype.handle = handleValue$1;
|
|
1078
|
+
function createBaseHandler(owner, options) {
|
|
1079
|
+
return new BaseHandler(owner, options);
|
|
1080
|
+
}
|
|
1081
|
+
function createCompareHandler(owner, options) {
|
|
1082
|
+
return new CompareHandler(createBaseHandler(owner, options));
|
|
1083
|
+
}
|
|
1084
|
+
function createValueHandler(owner, options) {
|
|
1085
|
+
return new ValueHandler(createBaseHandler(owner, options));
|
|
1086
|
+
}
|
|
1087
|
+
function deregisterHandler(value) {
|
|
1088
|
+
this.handlers.delete(value);
|
|
1089
|
+
}
|
|
1090
|
+
function getHandler$1(first, second) {
|
|
1091
|
+
if (isConstructable(first) && isConstructable(second) && first.constructor === second.constructor) return this.handlers.get(first.constructor);
|
|
1092
|
+
}
|
|
1093
|
+
function handleComparison(first, second, ...parameters) {
|
|
1094
|
+
const handler = this.base.get(first, second);
|
|
1095
|
+
if (handler == null) return this.base.options.callback(first, second, ...parameters);
|
|
1096
|
+
return typeof handler === "function" ? handler(first, second) : first[handler](second);
|
|
1121
1097
|
}
|
|
1122
1098
|
function isConstructable(value) {
|
|
1123
1099
|
return typeof value === "object" && value !== null;
|
|
1124
1100
|
}
|
|
1101
|
+
function registerHandler(constructor, handler) {
|
|
1102
|
+
if (isNonConstructor(constructor) || handler === this.owner) return;
|
|
1103
|
+
let actual = handler ?? this.options.method;
|
|
1104
|
+
if (typeof actual !== "function" && typeof actual !== "string") return;
|
|
1105
|
+
if (typeof actual === "string") actual = typeof constructor.prototype[actual] === "function" ? actual : void 0;
|
|
1106
|
+
if (actual != null) this.handlers.set(constructor, actual);
|
|
1107
|
+
}
|
|
1108
|
+
function handleValue$1(value, ...parameters) {
|
|
1109
|
+
const handler = this.base.get(value, value);
|
|
1110
|
+
if (handler == null) return this.base.options.callback(value, ...parameters);
|
|
1111
|
+
return typeof handler === "function" ? handler(value) : value[handler]();
|
|
1112
|
+
}
|
|
1125
1113
|
//#endregion
|
|
1126
1114
|
//#region src/internal/value/compare.ts
|
|
1127
1115
|
const COMPARE_NAME = "compare";
|
|
@@ -1167,7 +1155,7 @@ function compareValue(first, second, compareStrings) {
|
|
|
1167
1155
|
const firstType = typeof first;
|
|
1168
1156
|
if (firstType === typeof second && firstType in comparators) return comparators[firstType](first, second);
|
|
1169
1157
|
if (first instanceof Date && second instanceof Date) return compareNumbers(first.getTime(), second.getTime());
|
|
1170
|
-
return compare.
|
|
1158
|
+
return compare.handler.handle(first, second, compareStrings);
|
|
1171
1159
|
}
|
|
1172
1160
|
/**
|
|
1173
1161
|
* Deregister a custom comparison handler for a class
|
|
@@ -1177,7 +1165,7 @@ function compareValue(first, second, compareStrings) {
|
|
|
1177
1165
|
* @param constructor Class constructor
|
|
1178
1166
|
*/
|
|
1179
1167
|
function deregisterComparator(constructor) {
|
|
1180
|
-
compare.
|
|
1168
|
+
compare.handler.base.deregister(constructor);
|
|
1181
1169
|
}
|
|
1182
1170
|
function getComparisonParts(value) {
|
|
1183
1171
|
if (Array.isArray(value)) return value;
|
|
@@ -1192,7 +1180,7 @@ function getComparisonParts(value) {
|
|
|
1192
1180
|
* @param handler Method name or comparison function _(defaults to `compare`)_
|
|
1193
1181
|
*/
|
|
1194
1182
|
function registerComparator(constructor, handler) {
|
|
1195
|
-
compare.
|
|
1183
|
+
compare.handler.base.register(constructor, handler);
|
|
1196
1184
|
}
|
|
1197
1185
|
const comparators = {
|
|
1198
1186
|
bigint: compareNumbers,
|
|
@@ -1200,24 +1188,25 @@ const comparators = {
|
|
|
1200
1188
|
number: compareNumbers,
|
|
1201
1189
|
symbol: compareSymbols
|
|
1202
1190
|
};
|
|
1203
|
-
const
|
|
1191
|
+
const compareHandler = createCompareHandler(compare, {
|
|
1204
1192
|
callback: (first, second, compareStrings) => compareStrings ? getString(first).localeCompare(getString(second)) : void 0,
|
|
1205
1193
|
method: COMPARE_NAME
|
|
1206
1194
|
});
|
|
1207
1195
|
compare.deregister = deregisterComparator;
|
|
1208
|
-
compare.
|
|
1196
|
+
compare.handler = compareHandler;
|
|
1209
1197
|
compare.register = registerComparator;
|
|
1210
|
-
Object.defineProperties(compare, {
|
|
1211
|
-
deregister: { value: deregisterComparator },
|
|
1212
|
-
handlers: { value: compareHandlers },
|
|
1213
|
-
register: { value: registerComparator }
|
|
1214
|
-
});
|
|
1215
1198
|
//#endregion
|
|
1216
1199
|
//#region src/array/sort.ts
|
|
1200
|
+
function Sorter(sorters) {
|
|
1201
|
+
this[SORTER_SYMBOL] = sorters;
|
|
1202
|
+
}
|
|
1203
|
+
Sorter.prototype.index = getSortedArrayIndex;
|
|
1204
|
+
Sorter.prototype.is = isSortedArray;
|
|
1205
|
+
Sorter.prototype.sort = sortArray;
|
|
1217
1206
|
function getComparisonSorter(callback, modifier) {
|
|
1218
1207
|
return {
|
|
1219
1208
|
modifier,
|
|
1220
|
-
|
|
1209
|
+
comparison: { simple: callback },
|
|
1221
1210
|
get: false,
|
|
1222
1211
|
identifier: callback.toString()
|
|
1223
1212
|
};
|
|
@@ -1225,16 +1214,30 @@ function getComparisonSorter(callback, modifier) {
|
|
|
1225
1214
|
function getComparisonValue(first, second, sorters, length) {
|
|
1226
1215
|
for (let index = 0; index < length; index += 1) {
|
|
1227
1216
|
const sorter = sorters[index];
|
|
1228
|
-
const values = [sorter.get ? sorter.value(first) : first, sorter.get ? sorter.value(second) : second];
|
|
1229
|
-
const comparison = (sorter.
|
|
1217
|
+
const values = [sorter.get ? sorter.value?.(first) : first, sorter.get ? sorter.value?.(second) : second];
|
|
1218
|
+
const comparison = (sorter.comparison?.complex?.(first, values[0], second, values[1]) ?? sorter.comparison?.simple?.(values[0], values[1]) ?? compare(values[0], values[1])) * sorter.modifier;
|
|
1230
1219
|
if (comparison !== 0) return comparison;
|
|
1231
1220
|
}
|
|
1232
1221
|
return 0;
|
|
1233
1222
|
}
|
|
1234
|
-
function
|
|
1223
|
+
function getModifier(first, second) {
|
|
1224
|
+
return modifiers[first === true || second === true ? SORT_DIRECTION_DESCENDING : SORT_DIRECTION_ASCENDING];
|
|
1225
|
+
}
|
|
1226
|
+
function getObjectSorter(obj, modifier) {
|
|
1227
|
+
let sorter;
|
|
1228
|
+
if (typeof obj.comparison === "function") sorter = getComparisonSorter(obj.comparison, modifier);
|
|
1229
|
+
else if (typeof obj.key === "string") {
|
|
1230
|
+
sorter = getValueSortHandlers(obj.key, modifier);
|
|
1231
|
+
if (typeof obj.compare === "function") sorter.comparison = { complex: obj.compare };
|
|
1232
|
+
} else if (typeof obj.value === "function") sorter = getValueSortHandlers(obj.value, modifier);
|
|
1233
|
+
if (sorter != null && typeof obj.direction === "string") sorter.modifier = modifiers[obj.direction] ?? modifier;
|
|
1234
|
+
return sorter;
|
|
1235
|
+
}
|
|
1236
|
+
function getSortedArrayIndex(array, item) {
|
|
1235
1237
|
if (!Array.isArray(array)) return -1;
|
|
1236
1238
|
const { length } = array;
|
|
1237
1239
|
if (length === 0) return 0;
|
|
1240
|
+
const sorters = Array.isArray(this) ? this : this[SORTER_SYMBOL];
|
|
1238
1241
|
const sortersLength = sorters.length;
|
|
1239
1242
|
if (getComparisonValue(item, array[0], sorters, sortersLength) < 0) return 0;
|
|
1240
1243
|
if (getComparisonValue(item, array[length - 1], sorters, sortersLength) >= 0) return length;
|
|
@@ -1247,36 +1250,23 @@ function getIndex(array, item, sorters) {
|
|
|
1247
1250
|
}
|
|
1248
1251
|
return low;
|
|
1249
1252
|
}
|
|
1250
|
-
function getModifier(first, second) {
|
|
1251
|
-
return modifiers[first === true || second === true ? SORT_DIRECTION_DESCENDING : SORT_DIRECTION_ASCENDING];
|
|
1252
|
-
}
|
|
1253
|
-
function getObjectSorter(obj, modifier) {
|
|
1254
|
-
let sorter;
|
|
1255
|
-
if (typeof obj.comparison === "function") sorter = getComparisonSorter(obj.comparison, modifier);
|
|
1256
|
-
else if (typeof obj.key === "string") {
|
|
1257
|
-
sorter = getValueSorter(obj.key, modifier);
|
|
1258
|
-
if (typeof obj.compare === "function") sorter.compare = { complex: obj.compare };
|
|
1259
|
-
} else if (typeof obj.value === "function") sorter = getValueSorter(obj.value, modifier);
|
|
1260
|
-
if (sorter != null && typeof obj.direction === "string") sorter.modifier = modifiers[obj.direction] ?? modifier;
|
|
1261
|
-
return sorter;
|
|
1262
|
-
}
|
|
1263
1253
|
function getSortedIndex(array, item, first, second) {
|
|
1264
|
-
return
|
|
1254
|
+
return getSortedArrayIndex.call(getSortHandlers(first, getModifier(first, second)), array, item);
|
|
1265
1255
|
}
|
|
1266
|
-
function
|
|
1256
|
+
function getSortHandler(value, modifier) {
|
|
1267
1257
|
switch (true) {
|
|
1268
1258
|
case typeof value === "function": return getComparisonSorter(value, modifier);
|
|
1269
|
-
case typeof value === "string": return
|
|
1259
|
+
case typeof value === "string": return getValueSortHandlers(value, modifier);
|
|
1270
1260
|
case isPlainObject(value): return getObjectSorter(value, modifier);
|
|
1271
1261
|
}
|
|
1272
1262
|
}
|
|
1273
|
-
function
|
|
1263
|
+
function getSortHandlers(value, modifier) {
|
|
1274
1264
|
const array = Array.isArray(value) ? value : [value];
|
|
1275
1265
|
const { length } = array;
|
|
1276
1266
|
const sorters = [];
|
|
1277
1267
|
for (let index = 0; index < length; index += 1) {
|
|
1278
1268
|
const item = array[index];
|
|
1279
|
-
const sorter =
|
|
1269
|
+
const sorter = getSortHandler(item, modifier);
|
|
1280
1270
|
if (sorter != null) sorters.push(sorter);
|
|
1281
1271
|
}
|
|
1282
1272
|
if (sorters.length === 0) return [{
|
|
@@ -1286,7 +1276,7 @@ function getSorters(value, modifier) {
|
|
|
1286
1276
|
}];
|
|
1287
1277
|
return sorters.filter((value, index, array) => array.findIndex((next) => next.identifier === value.identifier) === index);
|
|
1288
1278
|
}
|
|
1289
|
-
function
|
|
1279
|
+
function getValueSortHandlers(value, modifier) {
|
|
1290
1280
|
const isFunction = typeof value === "function";
|
|
1291
1281
|
return {
|
|
1292
1282
|
modifier,
|
|
@@ -1296,21 +1286,16 @@ function getValueSorter(value, modifier) {
|
|
|
1296
1286
|
};
|
|
1297
1287
|
}
|
|
1298
1288
|
function initializeSorter(first, second) {
|
|
1299
|
-
|
|
1300
|
-
const sorter = (array) => sortArray(array, sorters);
|
|
1301
|
-
Object.defineProperties(sorter, {
|
|
1302
|
-
index: { value: (array, item) => getIndex(array, item, sorters) },
|
|
1303
|
-
is: { value: (array) => isSortedArray(array, sorters) }
|
|
1304
|
-
});
|
|
1305
|
-
return sorter;
|
|
1289
|
+
return new Sorter(getSortHandlers(first, getModifier(first, second)));
|
|
1306
1290
|
}
|
|
1307
1291
|
function isSorted(array, first, second) {
|
|
1308
|
-
return isSortedArray(
|
|
1292
|
+
return isSortedArray.call(getSortHandlers(first, getModifier(first, second)), array);
|
|
1309
1293
|
}
|
|
1310
|
-
function isSortedArray(array
|
|
1294
|
+
function isSortedArray(array) {
|
|
1311
1295
|
if (!Array.isArray(array)) return false;
|
|
1312
1296
|
const { length } = array;
|
|
1313
1297
|
if (length < 2) return true;
|
|
1298
|
+
const sorters = Array.isArray(this) ? this : this[SORTER_SYMBOL];
|
|
1314
1299
|
const sortersLength = sorters.length;
|
|
1315
1300
|
let offset = 0;
|
|
1316
1301
|
if (length >= SORT_THRESHOLD) {
|
|
@@ -1332,10 +1317,11 @@ function isSortedArray(array, sorters) {
|
|
|
1332
1317
|
return true;
|
|
1333
1318
|
}
|
|
1334
1319
|
function sort(array, first, second) {
|
|
1335
|
-
return sortArray(
|
|
1320
|
+
return sortArray.call(getSortHandlers(first, getModifier(first, second)), array);
|
|
1336
1321
|
}
|
|
1337
|
-
function sortArray(array
|
|
1322
|
+
function sortArray(array) {
|
|
1338
1323
|
if (!Array.isArray(array)) return [];
|
|
1324
|
+
const sorters = Array.isArray(this) ? this : this[SORTER_SYMBOL];
|
|
1339
1325
|
const { length } = sorters;
|
|
1340
1326
|
return array.length > 1 ? array.sort((first, second) => getComparisonValue(first, second, sorters, length)) : array;
|
|
1341
1327
|
}
|
|
@@ -1343,6 +1329,7 @@ const SORT_PEEK_PERCENTAGE = 10;
|
|
|
1343
1329
|
const SORT_THRESHOLD = 100;
|
|
1344
1330
|
const SORT_DIRECTION_ASCENDING = "ascending";
|
|
1345
1331
|
const SORT_DIRECTION_DESCENDING = "descending";
|
|
1332
|
+
const SORTER_SYMBOL = Symbol("sorter");
|
|
1346
1333
|
const modifiers = {
|
|
1347
1334
|
[SORT_DIRECTION_ASCENDING]: 1,
|
|
1348
1335
|
[SORT_DIRECTION_DESCENDING]: -1
|
|
@@ -1350,11 +1337,6 @@ const modifiers = {
|
|
|
1350
1337
|
sort.getIndex = getSortedIndex;
|
|
1351
1338
|
sort.initialize = initializeSorter;
|
|
1352
1339
|
sort.is = isSorted;
|
|
1353
|
-
Object.defineProperties(sort, {
|
|
1354
|
-
getIndex: { value: getSortedIndex },
|
|
1355
|
-
initialize: { value: initializeSorter },
|
|
1356
|
-
is: { value: isSorted }
|
|
1357
|
-
});
|
|
1358
1340
|
//#endregion
|
|
1359
1341
|
//#region src/array/swap.ts
|
|
1360
1342
|
function swap(array, first, second, third) {
|
|
@@ -1412,7 +1394,6 @@ function swapValues(array, from, to, key) {
|
|
|
1412
1394
|
return swapIndices(array, first, second);
|
|
1413
1395
|
}
|
|
1414
1396
|
swap.indices = swapIndices;
|
|
1415
|
-
Object.defineProperty(swap, "indices", { value: swapIndices });
|
|
1416
1397
|
//#endregion
|
|
1417
1398
|
//#region src/array/to-map.ts
|
|
1418
1399
|
function getMapValues(array, first, second, arrays) {
|
|
@@ -1439,7 +1420,6 @@ function toMapArrays(array, first, second) {
|
|
|
1439
1420
|
return getMapValues(array, first, second, true);
|
|
1440
1421
|
}
|
|
1441
1422
|
toMap.arrays = toMapArrays;
|
|
1442
|
-
Object.defineProperty(toMap, "arrays", { value: toMapArrays });
|
|
1443
1423
|
//#endregion
|
|
1444
1424
|
//#region src/array/to-record.ts
|
|
1445
1425
|
function toRecord(array, first, second) {
|
|
@@ -1449,7 +1429,6 @@ function toRecordArrays(array, first, second) {
|
|
|
1449
1429
|
return groupValues(array, first, second, true);
|
|
1450
1430
|
}
|
|
1451
1431
|
toRecord.arrays = toRecordArrays;
|
|
1452
|
-
Object.defineProperty(toRecord, "arrays", { value: toRecordArrays });
|
|
1453
1432
|
//#endregion
|
|
1454
1433
|
//#region src/internal/function/misc.ts
|
|
1455
1434
|
/**
|
|
@@ -1465,86 +1444,105 @@ function getNumberOrDefault(value, defaultValue, minimum) {
|
|
|
1465
1444
|
return typeof value === "number" && !Number.isNaN(value) && value >= (minimum ?? 0) ? value : defaultValue;
|
|
1466
1445
|
}
|
|
1467
1446
|
//#endregion
|
|
1468
|
-
//#region src/internal/function/
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
}
|
|
1492
|
-
} else id = startTimer(() => run(item));
|
|
1493
|
-
}
|
|
1494
|
-
const interval = getNumberOrDefault(time, 0);
|
|
1495
|
-
const throttle = type === TIMER_THROTTLE;
|
|
1496
|
-
let id;
|
|
1497
|
-
let last;
|
|
1498
|
-
let start;
|
|
1499
|
-
const timer = (...parameters) => {
|
|
1500
|
-
cancel();
|
|
1501
|
-
const next = {
|
|
1502
|
-
parameters,
|
|
1503
|
-
running: false
|
|
1504
|
-
};
|
|
1505
|
-
next.promise = new Promise((resolve, reject) => {
|
|
1506
|
-
next.reject = reject;
|
|
1507
|
-
next.resolve = resolve;
|
|
1508
|
-
});
|
|
1509
|
-
last = next;
|
|
1510
|
-
if (throttle) run(next);
|
|
1511
|
-
else id = startTimer(() => run(next));
|
|
1512
|
-
return next.promise;
|
|
1447
|
+
//#region src/internal/function/limit.ts
|
|
1448
|
+
const LIMITER_NAME_ASYNC = "asyncLimiter";
|
|
1449
|
+
const LIMITER_NAME_SYNC = "limiter";
|
|
1450
|
+
const LIMITER_PROPERTY = "$limiter";
|
|
1451
|
+
function AsyncLimiter(type, callback, time) {
|
|
1452
|
+
this[LIMITER_SYMBOL] = {
|
|
1453
|
+
callback,
|
|
1454
|
+
type,
|
|
1455
|
+
interval: getNumberOrDefault(time, 0),
|
|
1456
|
+
parameters: [],
|
|
1457
|
+
throttle: type === LIMITER_THROTTLE
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
AsyncLimiter.prototype[LIMITER_PROPERTY] = LIMITER_NAME_ASYNC;
|
|
1461
|
+
AsyncLimiter.prototype.cancel = cancelAsyncLimiter;
|
|
1462
|
+
AsyncLimiter.prototype.run = runAsyncLimiter;
|
|
1463
|
+
function Limiter(type, callback, time) {
|
|
1464
|
+
this[LIMITER_SYMBOL] = {
|
|
1465
|
+
callback,
|
|
1466
|
+
type,
|
|
1467
|
+
interval: getNumberOrDefault(time, 0),
|
|
1468
|
+
parameters: [],
|
|
1469
|
+
throttle: type === LIMITER_THROTTLE
|
|
1513
1470
|
};
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1471
|
+
}
|
|
1472
|
+
Limiter.prototype[LIMITER_PROPERTY] = LIMITER_NAME_SYNC;
|
|
1473
|
+
Limiter.prototype.cancel = cancelLimiter;
|
|
1474
|
+
Limiter.prototype.run = runLimiter;
|
|
1475
|
+
function cancelAsyncLimiter() {
|
|
1476
|
+
const state = this[LIMITER_SYMBOL];
|
|
1477
|
+
if (state.timer != null) clearTimer(state.timer);
|
|
1478
|
+
if (state.last != null && !state.last.running) {
|
|
1479
|
+
state.last.reject();
|
|
1480
|
+
state.last = void 0;
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
function cancelLimiter() {
|
|
1484
|
+
const { timer } = this[LIMITER_SYMBOL];
|
|
1485
|
+
if (timer != null) clearTimer(timer);
|
|
1486
|
+
}
|
|
1487
|
+
function getAsyncLimiter(type, callback, time) {
|
|
1488
|
+
return new AsyncLimiter(type, callback, time);
|
|
1489
|
+
}
|
|
1490
|
+
function getLimiter(type, callback, time) {
|
|
1491
|
+
return new Limiter(type, callback, time);
|
|
1492
|
+
}
|
|
1493
|
+
async function handleAsyncLimiter(state, item) {
|
|
1494
|
+
const now = performance.now();
|
|
1495
|
+
state.start ??= now;
|
|
1496
|
+
if (state.interval === 0 || now - state.start >= state.interval - LIMITER_OFFSET) {
|
|
1497
|
+
state.start = state.throttle ? now : void 0;
|
|
1498
|
+
item.running = true;
|
|
1499
|
+
try {
|
|
1500
|
+
let result = state.callback(...item.parameters);
|
|
1501
|
+
if (result instanceof Promise) result = await result;
|
|
1502
|
+
item.resolve(result);
|
|
1503
|
+
} catch (error) {
|
|
1504
|
+
item.reject(error);
|
|
1505
|
+
} finally {
|
|
1506
|
+
item.running = false;
|
|
1507
|
+
}
|
|
1508
|
+
} else state.timer = startTimer(() => handleAsyncLimiter(state, item));
|
|
1509
|
+
}
|
|
1510
|
+
function handleLimiter(state) {
|
|
1511
|
+
const now = performance.now();
|
|
1512
|
+
state.start ??= now;
|
|
1513
|
+
if (state.interval === 0 || now - state.start >= state.interval - LIMITER_OFFSET) {
|
|
1514
|
+
state.start = state.throttle ? now : void 0;
|
|
1515
|
+
state.callback(...state.parameters);
|
|
1516
|
+
} else state.timer = startTimer(() => handleLimiter(state));
|
|
1517
|
+
}
|
|
1518
|
+
function runAsyncLimiter() {
|
|
1519
|
+
const state = this[LIMITER_SYMBOL];
|
|
1520
|
+
cancelAsyncLimiter.call(this);
|
|
1521
|
+
const next = {
|
|
1522
|
+
parameters: state.parameters,
|
|
1523
|
+
running: false
|
|
1539
1524
|
};
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1525
|
+
next.promise = new Promise((resolve, reject) => {
|
|
1526
|
+
next.reject = reject;
|
|
1527
|
+
next.resolve = resolve;
|
|
1528
|
+
});
|
|
1529
|
+
state.last = next;
|
|
1530
|
+
if (state.throttle) handleAsyncLimiter(state, next);
|
|
1531
|
+
else state.timer = startTimer(() => handleAsyncLimiter(state, next));
|
|
1532
|
+
return next.promise;
|
|
1533
|
+
}
|
|
1534
|
+
function runLimiter(...parameters) {
|
|
1535
|
+
const state = this[LIMITER_SYMBOL];
|
|
1536
|
+
cancelLimiter.call(this);
|
|
1537
|
+
state.parameters = parameters;
|
|
1538
|
+
if (state.throttle) handleLimiter(state);
|
|
1539
|
+
else state.timer = startTimer(() => handleLimiter(state));
|
|
1540
|
+
}
|
|
1541
|
+
const LIMITER_DEBOUNCE = "debounce";
|
|
1542
|
+
const LIMITER_OFFSET = 5;
|
|
1543
|
+
const LIMITER_SYMBOL = Symbol("limiter");
|
|
1544
|
+
const LIMITER_THROTTLE = "throttle";
|
|
1545
|
+
const LIMITER_WAIT = "wait";
|
|
1548
1546
|
// istanbul ignore next
|
|
1549
1547
|
const clearTimer = typeof cancelAnimationFrame === "function" ? cancelAnimationFrame : clearTimeout;
|
|
1550
1548
|
// istanbul ignore next
|
|
@@ -1564,7 +1562,7 @@ const startTimer = typeof requestAnimationFrame === "function" ? requestAnimatio
|
|
|
1564
1562
|
* @returns Debounced callback handler with a `cancel` method
|
|
1565
1563
|
*/
|
|
1566
1564
|
function asyncDebounce(callback, time) {
|
|
1567
|
-
return
|
|
1565
|
+
return getAsyncLimiter(LIMITER_DEBOUNCE, callback, time);
|
|
1568
1566
|
}
|
|
1569
1567
|
/**
|
|
1570
1568
|
* Throttle a function, ensuring it is only called once every `time` milliseconds
|
|
@@ -1579,7 +1577,7 @@ function asyncDebounce(callback, time) {
|
|
|
1579
1577
|
* @returns Throttled callback handler with a `cancel` method
|
|
1580
1578
|
*/
|
|
1581
1579
|
function asyncThrottle(callback, time) {
|
|
1582
|
-
return
|
|
1580
|
+
return getAsyncLimiter(LIMITER_THROTTLE, callback, time);
|
|
1583
1581
|
}
|
|
1584
1582
|
/**
|
|
1585
1583
|
* Debounce a function, ensuring it is only called after `time` milliseconds have passed
|
|
@@ -1591,7 +1589,7 @@ function asyncThrottle(callback, time) {
|
|
|
1591
1589
|
* @returns Debounced callback handler with a `cancel` method
|
|
1592
1590
|
*/
|
|
1593
1591
|
function debounce(callback, time) {
|
|
1594
|
-
return
|
|
1592
|
+
return getLimiter(LIMITER_DEBOUNCE, callback, time);
|
|
1595
1593
|
}
|
|
1596
1594
|
/**
|
|
1597
1595
|
* Throttle a function, ensuring it is only called once every `time` milliseconds
|
|
@@ -1601,12 +1599,10 @@ function debounce(callback, time) {
|
|
|
1601
1599
|
* @returns Throttled callback handler with a `cancel` method
|
|
1602
1600
|
*/
|
|
1603
1601
|
function throttle(callback, time) {
|
|
1604
|
-
return
|
|
1602
|
+
return getLimiter(LIMITER_THROTTLE, callback, time);
|
|
1605
1603
|
}
|
|
1606
1604
|
debounce.async = asyncDebounce;
|
|
1607
1605
|
throttle.async = asyncThrottle;
|
|
1608
|
-
Object.defineProperty(debounce, "async", { value: asyncDebounce });
|
|
1609
|
-
Object.defineProperty(throttle, "async", { value: asyncThrottle });
|
|
1610
1606
|
//#endregion
|
|
1611
1607
|
//#region src/internal/result/misc.ts
|
|
1612
1608
|
function error(value, original) {
|
|
@@ -1636,8 +1632,7 @@ function isResult(value) {
|
|
|
1636
1632
|
return isResultValue(value, true) || isResultValue(value, false);
|
|
1637
1633
|
}
|
|
1638
1634
|
function isResultValue(value, okValue) {
|
|
1639
|
-
|
|
1640
|
-
return value.ok === okValue && (okValue ? RESULT_PROPERTY_VALUE : RESULT_PROPERTY_ERROR) in value;
|
|
1635
|
+
return isPlainObject(value) && value.ok === okValue && (okValue ? RESULT_PROPERTY_VALUE : RESULT_PROPERTY_ERROR) in value;
|
|
1641
1636
|
}
|
|
1642
1637
|
/**
|
|
1643
1638
|
* Creates an ok result
|
|
@@ -1656,6 +1651,8 @@ function unwrap(value, defaultValue) {
|
|
|
1656
1651
|
}
|
|
1657
1652
|
const RESULT_PROPERTY_ERROR = "error";
|
|
1658
1653
|
const RESULT_PROPERTY_VALUE = "value";
|
|
1654
|
+
error.is = isError;
|
|
1655
|
+
ok.is = isOk;
|
|
1659
1656
|
//#endregion
|
|
1660
1657
|
//#region src/internal/value/misc.ts
|
|
1661
1658
|
function findKey(needle, haystack) {
|
|
@@ -1687,9 +1684,10 @@ function getPaths(path, lowercase) {
|
|
|
1687
1684
|
function handleValue(data, path, value, get, ignoreCase) {
|
|
1688
1685
|
if (typeof data === "object" && data !== null) {
|
|
1689
1686
|
if (ignoreKey(path)) return error(MISC_NESTED_MESSAGE_UNSAFE);
|
|
1690
|
-
const
|
|
1691
|
-
|
|
1692
|
-
|
|
1687
|
+
const dataObject = data;
|
|
1688
|
+
const key = ignoreCase ? findKey(path, dataObject) : path;
|
|
1689
|
+
if (get) return key in dataObject ? ok(dataObject[key]) : error(MISC_NESTED_MESSAGE_MISSING);
|
|
1690
|
+
dataObject[key] = typeof value === "function" ? value(dataObject[key]) : value;
|
|
1693
1691
|
}
|
|
1694
1692
|
if (get) return error(MISC_NESTED_MESSAGE_MISSING);
|
|
1695
1693
|
}
|
|
@@ -1709,7 +1707,6 @@ function hasValueResult(data, path, ignoreCase) {
|
|
|
1709
1707
|
return getNestedValue(data, path, ignoreCase === true);
|
|
1710
1708
|
}
|
|
1711
1709
|
hasValue.get = hasValueResult;
|
|
1712
|
-
Object.defineProperty(hasValue, "get", { value: hasValueResult });
|
|
1713
1710
|
//#endregion
|
|
1714
1711
|
//#region src/internal/function/assert.ts
|
|
1715
1712
|
/**
|
|
@@ -1804,15 +1801,64 @@ assert.defined = assertDefined;
|
|
|
1804
1801
|
assert.instanceOf = assertInstanceOf;
|
|
1805
1802
|
assert.is = assertIs;
|
|
1806
1803
|
assert.property = assertProperty;
|
|
1807
|
-
Object.defineProperties(assert, {
|
|
1808
|
-
condition: { value: assertCondition },
|
|
1809
|
-
defined: { value: assertDefined },
|
|
1810
|
-
instanceOf: { value: assertInstanceOf },
|
|
1811
|
-
is: { value: assertIs },
|
|
1812
|
-
property: { value: assertProperty }
|
|
1813
|
-
});
|
|
1814
1804
|
//#endregion
|
|
1815
1805
|
//#region src/function/once.ts
|
|
1806
|
+
const ONCE_NAME_ASYNC = "asyncOnce";
|
|
1807
|
+
const ONCE_NAME_SYNC = "once";
|
|
1808
|
+
const ONCE_PROPERTY = "$once";
|
|
1809
|
+
function AsyncOnce(callback) {
|
|
1810
|
+
this[ONCE_SYMBOL] = {
|
|
1811
|
+
callback,
|
|
1812
|
+
called: false,
|
|
1813
|
+
cleared: false,
|
|
1814
|
+
error: false,
|
|
1815
|
+
finished: false,
|
|
1816
|
+
items: [],
|
|
1817
|
+
value: void 0
|
|
1818
|
+
};
|
|
1819
|
+
}
|
|
1820
|
+
AsyncOnce.prototype[ONCE_PROPERTY] = ONCE_NAME_ASYNC;
|
|
1821
|
+
AsyncOnce.prototype.clear = clearOnce;
|
|
1822
|
+
AsyncOnce.prototype.run = runOnceAsync;
|
|
1823
|
+
Object.defineProperties(AsyncOnce.prototype, {
|
|
1824
|
+
called: {
|
|
1825
|
+
enumerable: true,
|
|
1826
|
+
get: getOnceCalled
|
|
1827
|
+
},
|
|
1828
|
+
cleared: {
|
|
1829
|
+
enumerable: true,
|
|
1830
|
+
get: getOnceCleared
|
|
1831
|
+
},
|
|
1832
|
+
error: {
|
|
1833
|
+
enumerable: true,
|
|
1834
|
+
get: getAsyncOnceError
|
|
1835
|
+
},
|
|
1836
|
+
finished: {
|
|
1837
|
+
enumerable: true,
|
|
1838
|
+
get: getAsyncOnceFinished
|
|
1839
|
+
}
|
|
1840
|
+
});
|
|
1841
|
+
function Once(callback) {
|
|
1842
|
+
this[ONCE_SYMBOL] = {
|
|
1843
|
+
callback,
|
|
1844
|
+
called: false,
|
|
1845
|
+
cleared: false,
|
|
1846
|
+
value: void 0
|
|
1847
|
+
};
|
|
1848
|
+
}
|
|
1849
|
+
Once.prototype[ONCE_PROPERTY] = ONCE_NAME_SYNC;
|
|
1850
|
+
Once.prototype.clear = clearOnce;
|
|
1851
|
+
Once.prototype.run = runOnce;
|
|
1852
|
+
Object.defineProperties(Once.prototype, {
|
|
1853
|
+
called: {
|
|
1854
|
+
enumerable: true,
|
|
1855
|
+
get: getOnceCalled
|
|
1856
|
+
},
|
|
1857
|
+
cleared: {
|
|
1858
|
+
enumerable: true,
|
|
1859
|
+
get: getOnceCleared
|
|
1860
|
+
}
|
|
1861
|
+
});
|
|
1816
1862
|
/**
|
|
1817
1863
|
* Create an asynchronous function that can only be called once, rejecting or resolving the same result on subsequent calls
|
|
1818
1864
|
*
|
|
@@ -1823,62 +1869,27 @@ Object.defineProperties(assert, {
|
|
|
1823
1869
|
*/
|
|
1824
1870
|
function asyncOnce(callback) {
|
|
1825
1871
|
assert(() => typeof callback === "function", ONCE_MESSAGE_EXPECTATION);
|
|
1826
|
-
|
|
1827
|
-
called: false,
|
|
1828
|
-
cleared: false,
|
|
1829
|
-
error: false,
|
|
1830
|
-
finished: false,
|
|
1831
|
-
items: [],
|
|
1832
|
-
value: void 0
|
|
1833
|
-
};
|
|
1834
|
-
const fn = (...parameters) => {
|
|
1835
|
-
if (state.cleared) return Promise.reject(new Error(ONCE_MESSAGE_CLEARED));
|
|
1836
|
-
if (state.finished) return state.error ? Promise.reject(state.value) : Promise.resolve(state.value);
|
|
1837
|
-
if (state.called) return new Promise((resolve, reject) => {
|
|
1838
|
-
state.items.push({
|
|
1839
|
-
reject,
|
|
1840
|
-
resolve
|
|
1841
|
-
});
|
|
1842
|
-
});
|
|
1843
|
-
state.called = true;
|
|
1844
|
-
return new Promise((resolve, reject) => {
|
|
1845
|
-
state.items.push({
|
|
1846
|
-
reject,
|
|
1847
|
-
resolve
|
|
1848
|
-
});
|
|
1849
|
-
callback(...parameters).then((value) => {
|
|
1850
|
-
handleOnceResult(state, value, false);
|
|
1851
|
-
}).catch((error) => {
|
|
1852
|
-
handleOnceResult(state, error, true);
|
|
1853
|
-
});
|
|
1854
|
-
});
|
|
1855
|
-
};
|
|
1856
|
-
Object.defineProperties(fn, {
|
|
1857
|
-
called: {
|
|
1858
|
-
enumerable: true,
|
|
1859
|
-
get: () => state.called
|
|
1860
|
-
},
|
|
1861
|
-
clear: { value: () => clearState(state) },
|
|
1862
|
-
cleared: {
|
|
1863
|
-
enumerable: true,
|
|
1864
|
-
get: () => state.cleared
|
|
1865
|
-
},
|
|
1866
|
-
error: {
|
|
1867
|
-
enumerable: true,
|
|
1868
|
-
get: () => state.error
|
|
1869
|
-
},
|
|
1870
|
-
finished: {
|
|
1871
|
-
enumerable: true,
|
|
1872
|
-
get: () => state.finished
|
|
1873
|
-
}
|
|
1874
|
-
});
|
|
1875
|
-
return fn;
|
|
1872
|
+
return new AsyncOnce(callback);
|
|
1876
1873
|
}
|
|
1877
|
-
function
|
|
1874
|
+
function clearOnce() {
|
|
1875
|
+
const state = this[ONCE_SYMBOL];
|
|
1878
1876
|
if (!state.called || state.cleared) return;
|
|
1877
|
+
state.callback = void 0;
|
|
1879
1878
|
state.cleared = true;
|
|
1880
1879
|
state.value = void 0;
|
|
1881
1880
|
}
|
|
1881
|
+
function getAsyncOnceError() {
|
|
1882
|
+
return this[ONCE_SYMBOL].error;
|
|
1883
|
+
}
|
|
1884
|
+
function getAsyncOnceFinished() {
|
|
1885
|
+
return this[ONCE_SYMBOL].finished;
|
|
1886
|
+
}
|
|
1887
|
+
function getOnceCalled() {
|
|
1888
|
+
return this[ONCE_SYMBOL].called;
|
|
1889
|
+
}
|
|
1890
|
+
function getOnceCleared() {
|
|
1891
|
+
return this[ONCE_SYMBOL].cleared;
|
|
1892
|
+
}
|
|
1882
1893
|
function handleOnceResult(state, value, error) {
|
|
1883
1894
|
state.error = error;
|
|
1884
1895
|
state.finished = true;
|
|
@@ -1892,6 +1903,27 @@ function handleOnceResult(state, value, error) {
|
|
|
1892
1903
|
}
|
|
1893
1904
|
}
|
|
1894
1905
|
/**
|
|
1906
|
+
* Is the value an asynchronous once callback?
|
|
1907
|
+
*
|
|
1908
|
+
* @param value Value to check
|
|
1909
|
+
* @returns `true` if the value is an asynchronous once callback, otherwise `false`
|
|
1910
|
+
*/
|
|
1911
|
+
function isAsyncOnce(value) {
|
|
1912
|
+
return isOnceInstance(value, ONCE_NAME_ASYNC);
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* Is the value a once callback?
|
|
1916
|
+
*
|
|
1917
|
+
* @param value Value to check
|
|
1918
|
+
* @returns `true` if the value is a once callback, otherwise `false`
|
|
1919
|
+
*/
|
|
1920
|
+
function isOnce(value) {
|
|
1921
|
+
return isOnceInstance(value, ONCE_NAME_SYNC);
|
|
1922
|
+
}
|
|
1923
|
+
function isOnceInstance(value, name) {
|
|
1924
|
+
return typeof value === "object" && value !== null && ONCE_PROPERTY in value && value[ONCE_PROPERTY] === name;
|
|
1925
|
+
}
|
|
1926
|
+
/**
|
|
1895
1927
|
* Create a function that can only be called once, returning the same value on subsequent calls
|
|
1896
1928
|
*
|
|
1897
1929
|
* @param callback Callback to use once
|
|
@@ -1899,35 +1931,46 @@ function handleOnceResult(state, value, error) {
|
|
|
1899
1931
|
*/
|
|
1900
1932
|
function once(callback) {
|
|
1901
1933
|
assert(() => typeof callback === "function", ONCE_MESSAGE_EXPECTATION);
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1934
|
+
return new Once(callback);
|
|
1935
|
+
}
|
|
1936
|
+
function runOnce(...parameters) {
|
|
1937
|
+
const state = this[ONCE_SYMBOL];
|
|
1938
|
+
if (state.cleared) throw new Error(ONCE_MESSAGE_CLEARED);
|
|
1939
|
+
if (state.called) return state.value;
|
|
1940
|
+
state.called = true;
|
|
1941
|
+
state.value = state.callback(...parameters);
|
|
1942
|
+
return state.value;
|
|
1943
|
+
}
|
|
1944
|
+
function runOnceAsync(...parameters) {
|
|
1945
|
+
const state = this[ONCE_SYMBOL];
|
|
1946
|
+
if (state.cleared) return Promise.reject(new Error(ONCE_MESSAGE_CLEARED));
|
|
1947
|
+
if (state.finished) return state.error ? Promise.reject(state.value) : Promise.resolve(state.value);
|
|
1948
|
+
if (state.called) return new Promise((resolve, reject) => {
|
|
1949
|
+
state.items.push({
|
|
1950
|
+
reject,
|
|
1951
|
+
resolve
|
|
1952
|
+
});
|
|
1953
|
+
});
|
|
1954
|
+
state.called = true;
|
|
1955
|
+
return new Promise((resolve, reject) => {
|
|
1956
|
+
state.items.push({
|
|
1957
|
+
reject,
|
|
1958
|
+
resolve
|
|
1959
|
+
});
|
|
1960
|
+
state.callback(...parameters).then((value) => {
|
|
1961
|
+
handleOnceResult(state, value, false);
|
|
1962
|
+
}).catch((error) => {
|
|
1963
|
+
handleOnceResult(state, error, true);
|
|
1964
|
+
});
|
|
1924
1965
|
});
|
|
1925
|
-
return fn;
|
|
1926
1966
|
}
|
|
1927
1967
|
const ONCE_MESSAGE_CLEARED = "Once has been cleared";
|
|
1928
1968
|
const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
|
|
1969
|
+
const ONCE_SYMBOL = Symbol(ONCE_PROPERTY);
|
|
1970
|
+
asyncOnce.is = isAsyncOnce;
|
|
1929
1971
|
once.async = asyncOnce;
|
|
1930
|
-
|
|
1972
|
+
once.is = isOnce;
|
|
1973
|
+
once.isAsync = isAsyncOnce;
|
|
1931
1974
|
//#endregion
|
|
1932
1975
|
//#region src/function/retry.ts
|
|
1933
1976
|
/**
|
|
@@ -1960,12 +2003,12 @@ async function asyncRetry(callback, options) {
|
|
|
1960
2003
|
if (attempts >= times || !when(error)) rejector(new RetryError(RETRY_MESSAGE_FAILED, error));
|
|
1961
2004
|
else {
|
|
1962
2005
|
attempts += 1;
|
|
1963
|
-
|
|
2006
|
+
limiter.run();
|
|
1964
2007
|
}
|
|
1965
2008
|
}
|
|
1966
2009
|
}
|
|
1967
2010
|
const { delay, times, when } = createRetryOptions(options);
|
|
1968
|
-
const
|
|
2011
|
+
const limiter = getLimiter(LIMITER_WAIT, handle, delay);
|
|
1969
2012
|
let attempts = 0;
|
|
1970
2013
|
let rejector;
|
|
1971
2014
|
let resolver;
|
|
@@ -2011,7 +2054,6 @@ const RETRY_ERROR_NAME = "RetryError";
|
|
|
2011
2054
|
const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
|
|
2012
2055
|
const RETRY_MESSAGE_FAILED = "Retry failed";
|
|
2013
2056
|
retry.async = asyncRetry;
|
|
2014
|
-
Object.defineProperty(retry, "async", { value: asyncRetry });
|
|
2015
2057
|
//#endregion
|
|
2016
2058
|
//#region src/internal/function/work.ts
|
|
2017
2059
|
function asyncFlow(...fns) {
|
|
@@ -2072,8 +2114,6 @@ const assertFlowFunctions = assert.condition((value) => Array.isArray(value) &&
|
|
|
2072
2114
|
const assertPipeFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_PIPE_ARRAY, TypeError);
|
|
2073
2115
|
flow.async = asyncFlow;
|
|
2074
2116
|
pipe.async = asyncPipe;
|
|
2075
|
-
Object.defineProperty(flow, "async", { value: asyncFlow });
|
|
2076
|
-
Object.defineProperty(pipe, "async", { value: asyncPipe });
|
|
2077
2117
|
//#endregion
|
|
2078
2118
|
//#region src/internal/number.ts
|
|
2079
2119
|
/**
|
|
@@ -2211,6 +2251,44 @@ var SizedMap = class extends Map {
|
|
|
2211
2251
|
};
|
|
2212
2252
|
//#endregion
|
|
2213
2253
|
//#region src/internal/function/memoize.ts
|
|
2254
|
+
function Memoized(callback, options) {
|
|
2255
|
+
this[MEMOIZED_SYMBOL] = {
|
|
2256
|
+
options,
|
|
2257
|
+
cache: new SizedMap(options.cacheSize),
|
|
2258
|
+
getter: void 0
|
|
2259
|
+
};
|
|
2260
|
+
this[MEMOIZED_SYMBOL].getter = createGetter(this[MEMOIZED_SYMBOL], callback);
|
|
2261
|
+
}
|
|
2262
|
+
Memoized.prototype.clear = clearMemoized;
|
|
2263
|
+
Memoized.prototype.delete = deleteMemoizedValue;
|
|
2264
|
+
Memoized.prototype.get = getMemoizedValue;
|
|
2265
|
+
Memoized.prototype.has = hasMemoizedValue;
|
|
2266
|
+
Memoized.prototype.run = runMemoized;
|
|
2267
|
+
Object.defineProperties(Memoized.prototype, {
|
|
2268
|
+
maximum: {
|
|
2269
|
+
enumerable: true,
|
|
2270
|
+
get: getMemoizedMaximum
|
|
2271
|
+
},
|
|
2272
|
+
size: {
|
|
2273
|
+
enumerable: true,
|
|
2274
|
+
get: getMemoizedSize
|
|
2275
|
+
}
|
|
2276
|
+
});
|
|
2277
|
+
function clearMemoized() {
|
|
2278
|
+
this[MEMOIZED_SYMBOL].cache.clear();
|
|
2279
|
+
}
|
|
2280
|
+
function deleteMemoizedValue(key) {
|
|
2281
|
+
return this[MEMOIZED_SYMBOL].cache.delete(key);
|
|
2282
|
+
}
|
|
2283
|
+
function createGetter(state, callback) {
|
|
2284
|
+
return (...parameters) => {
|
|
2285
|
+
const key = state.options.cacheKey?.(...parameters) ?? (parameters.length === 1 ? parameters[0] : join(parameters.map(getString), MEMOIZED_KEY_SEPARATOR));
|
|
2286
|
+
if (state.cache.has(key)) return state.cache.get(key);
|
|
2287
|
+
const value = callback(...parameters);
|
|
2288
|
+
state.cache.set(key, value);
|
|
2289
|
+
return value;
|
|
2290
|
+
};
|
|
2291
|
+
}
|
|
2214
2292
|
function createMemoizationOptions(input) {
|
|
2215
2293
|
const { cacheKey, cacheSize } = isPlainObject(input) ? input : {};
|
|
2216
2294
|
return {
|
|
@@ -2218,6 +2296,18 @@ function createMemoizationOptions(input) {
|
|
|
2218
2296
|
cacheSize: getNumberOrDefault(cacheSize, MEMOIZED_CACHE_SIZE_DEFAULT)
|
|
2219
2297
|
};
|
|
2220
2298
|
}
|
|
2299
|
+
function getMemoizedMaximum() {
|
|
2300
|
+
return this[MEMOIZED_SYMBOL].cache.maximum;
|
|
2301
|
+
}
|
|
2302
|
+
function getMemoizedSize() {
|
|
2303
|
+
return this[MEMOIZED_SYMBOL].cache.size;
|
|
2304
|
+
}
|
|
2305
|
+
function getMemoizedValue(key) {
|
|
2306
|
+
return this[MEMOIZED_SYMBOL].cache.get(key);
|
|
2307
|
+
}
|
|
2308
|
+
function hasMemoizedValue(key) {
|
|
2309
|
+
return this[MEMOIZED_SYMBOL].cache.has(key);
|
|
2310
|
+
}
|
|
2221
2311
|
/**
|
|
2222
2312
|
* Memoize a function, caching and retrieving results based on the first parameter
|
|
2223
2313
|
*
|
|
@@ -2227,41 +2317,15 @@ function createMemoizationOptions(input) {
|
|
|
2227
2317
|
*/
|
|
2228
2318
|
function memoize(callback, options) {
|
|
2229
2319
|
if (typeof callback !== "function") throw new TypeError(MEMOIZED_CALLBACK);
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
};
|
|
2235
|
-
state.cache = new SizedMap(state.options.cacheSize);
|
|
2236
|
-
state.getter = (...parameters) => {
|
|
2237
|
-
const key = state.options.cacheKey?.(...parameters) ?? (parameters.length === 1 ? parameters[0] : join(parameters.map(getString), MEMOIZED_KEY_SEPARATOR));
|
|
2238
|
-
if (state.cache.has(key)) return state.cache.get(key);
|
|
2239
|
-
const value = callback(...parameters);
|
|
2240
|
-
state.cache.set(key, value);
|
|
2241
|
-
return value;
|
|
2242
|
-
};
|
|
2243
|
-
const instance = {
|
|
2244
|
-
clear: () => state.cache.clear(),
|
|
2245
|
-
delete: (key) => state.cache.delete(key),
|
|
2246
|
-
get: (key) => state.cache.get(key),
|
|
2247
|
-
has: (key) => state.cache.has(key),
|
|
2248
|
-
run: (...parameters) => state.getter(...parameters)
|
|
2249
|
-
};
|
|
2250
|
-
Object.defineProperties(instance, {
|
|
2251
|
-
maximum: {
|
|
2252
|
-
enumerable: true,
|
|
2253
|
-
get: () => state.cache.maximum
|
|
2254
|
-
},
|
|
2255
|
-
size: {
|
|
2256
|
-
enumerable: true,
|
|
2257
|
-
get: () => state.cache.size
|
|
2258
|
-
}
|
|
2259
|
-
});
|
|
2260
|
-
return Object.freeze(instance);
|
|
2320
|
+
return new Memoized(callback, createMemoizationOptions(options));
|
|
2321
|
+
}
|
|
2322
|
+
function runMemoized(...parameters) {
|
|
2323
|
+
return this[MEMOIZED_SYMBOL].getter(...parameters);
|
|
2261
2324
|
}
|
|
2262
2325
|
const MEMOIZED_CACHE_SIZE_DEFAULT = 1024;
|
|
2263
2326
|
const MEMOIZED_CALLBACK = "Memoized requires a callback function";
|
|
2264
2327
|
const MEMOIZED_KEY_SEPARATOR = "_";
|
|
2328
|
+
const MEMOIZED_SYMBOL = Symbol("memoized");
|
|
2265
2329
|
//#endregion
|
|
2266
2330
|
//#region src/internal/string/case.ts
|
|
2267
2331
|
/**
|
|
@@ -2399,6 +2463,15 @@ let memoizedTitleCase;
|
|
|
2399
2463
|
let memoizedUpperCase;
|
|
2400
2464
|
//#endregion
|
|
2401
2465
|
//#region src/internal/value/equal.ts
|
|
2466
|
+
function Equalizer(options) {
|
|
2467
|
+
this[EQUAL_SYMBOL] = options;
|
|
2468
|
+
}
|
|
2469
|
+
Equalizer.prototype.compare = compare$1;
|
|
2470
|
+
Equalizer.prototype.deregister = deregisterEqualizer;
|
|
2471
|
+
Equalizer.prototype.register = registerEqualizer;
|
|
2472
|
+
function compare$1(first, second) {
|
|
2473
|
+
return equalValue(first, second, this[EQUAL_SYMBOL]);
|
|
2474
|
+
}
|
|
2402
2475
|
function createEqualOptions(input) {
|
|
2403
2476
|
const options = {
|
|
2404
2477
|
ignoreCase: false,
|
|
@@ -2433,7 +2506,7 @@ function createEqualOptions(input) {
|
|
|
2433
2506
|
* @param constructor Class constructor
|
|
2434
2507
|
*/
|
|
2435
2508
|
function deregisterEqualizer(constructor) {
|
|
2436
|
-
|
|
2509
|
+
equalHandler.base.deregister(constructor);
|
|
2437
2510
|
}
|
|
2438
2511
|
function filterKey(key, options) {
|
|
2439
2512
|
if (typeof key !== "string") return true;
|
|
@@ -2444,10 +2517,6 @@ function filterKey(key, options) {
|
|
|
2444
2517
|
function equal(first, second, options) {
|
|
2445
2518
|
return equalValue(first, second, createEqualOptions(options));
|
|
2446
2519
|
}
|
|
2447
|
-
equal.handlers = createCompareHandlers(equal, { callback: Object.is });
|
|
2448
|
-
equal.deregister = deregisterEqualizer;
|
|
2449
|
-
equal.initialize = initializeEqualizer;
|
|
2450
|
-
equal.register = registerEqualizer;
|
|
2451
2520
|
function equalArray(first, second, options) {
|
|
2452
2521
|
const { length } = first;
|
|
2453
2522
|
if (length !== second.length) return false;
|
|
@@ -2536,7 +2605,7 @@ function equalValue(first, second, options) {
|
|
|
2536
2605
|
case Array.isArray(first) && Array.isArray(second): return equalArray(first, second, options);
|
|
2537
2606
|
case isPlainObject(first) && isPlainObject(second): return equalPlainObject(first, second, options);
|
|
2538
2607
|
case isTypedArray(first) && isTypedArray(second): return equalTypedArray(first, second);
|
|
2539
|
-
default: return
|
|
2608
|
+
default: return equalHandler.handle(first, second, options);
|
|
2540
2609
|
}
|
|
2541
2610
|
}
|
|
2542
2611
|
/**
|
|
@@ -2548,11 +2617,7 @@ function equalValue(first, second, options) {
|
|
|
2548
2617
|
* @returns Equalizer function
|
|
2549
2618
|
*/
|
|
2550
2619
|
function initializeEqualizer(options) {
|
|
2551
|
-
|
|
2552
|
-
const equalizer = (first, second) => equalValue(first, second, actual);
|
|
2553
|
-
equalizer.deregister = deregisterEqualizer;
|
|
2554
|
-
equalizer.register = registerEqualizer;
|
|
2555
|
-
return equalizer;
|
|
2620
|
+
return new Equalizer(createEqualOptions(options));
|
|
2556
2621
|
}
|
|
2557
2622
|
/**
|
|
2558
2623
|
* Register a equality comparison function for a specific class
|
|
@@ -2563,13 +2628,19 @@ function initializeEqualizer(options) {
|
|
|
2563
2628
|
* @param handler Comparison function
|
|
2564
2629
|
*/
|
|
2565
2630
|
function registerEqualizer(constructor, handler) {
|
|
2566
|
-
|
|
2631
|
+
equalHandler.base.register(constructor, handler);
|
|
2567
2632
|
}
|
|
2568
2633
|
const EQUAL_ARRAY_PEEK_PERCENTAGE = 10;
|
|
2569
2634
|
const EQUAL_ARRAY_THRESHOLD = 100;
|
|
2570
2635
|
const EQUAL_ERROR_PROPERTIES = ["name", "message"];
|
|
2571
2636
|
const EQUAL_EXPRESSION_PROPERTIES = ["source", "flags"];
|
|
2572
2637
|
const EQUAL_MINIMUM_LENGTH_FOR_SET = 16;
|
|
2638
|
+
const EQUAL_SYMBOL = Symbol("equal");
|
|
2639
|
+
const equalHandler = createCompareHandler(equal, { callback: Object.is });
|
|
2640
|
+
equal.deregister = deregisterEqualizer;
|
|
2641
|
+
equal.handler = equalHandler;
|
|
2642
|
+
equal.initialize = initializeEqualizer;
|
|
2643
|
+
equal.register = registerEqualizer;
|
|
2573
2644
|
//#endregion
|
|
2574
2645
|
//#region src/internal/value/get.ts
|
|
2575
2646
|
function getValue(data, path, ignoreCase) {
|
|
@@ -2594,7 +2665,7 @@ function setValue(data, path, value, ignoreCase) {
|
|
|
2594
2665
|
handleValue(target, currentPath, value, false, shouldIgnoreCase);
|
|
2595
2666
|
break;
|
|
2596
2667
|
}
|
|
2597
|
-
let next = handleValue(target, currentPath, null, true, shouldIgnoreCase)
|
|
2668
|
+
let next = unwrap(handleValue(target, currentPath, null, true, shouldIgnoreCase), void 0);
|
|
2598
2669
|
if (typeof next !== "object" || next === null) {
|
|
2599
2670
|
const nextPath = paths[index + 1];
|
|
2600
2671
|
if (SET_EXPRESSION_INDEX.test(nextPath)) next = Array.from({ length: Number(nextPath) + 1 }, () => void 0);
|
|
@@ -2607,7 +2678,7 @@ function setValue(data, path, value, ignoreCase) {
|
|
|
2607
2678
|
}
|
|
2608
2679
|
const SET_EXPRESSION_INDEX = /^\d+$/;
|
|
2609
2680
|
//#endregion
|
|
2610
|
-
//#region src/internal/
|
|
2681
|
+
//#region src/internal/aborter.ts
|
|
2611
2682
|
function createAborter(value, onAbort) {
|
|
2612
2683
|
if (!(value instanceof AbortSignal)) return;
|
|
2613
2684
|
value.addEventListener(ABORT_EVENT, onAbort, ABORT_OPTIONS);
|
|
@@ -2674,7 +2745,7 @@ function createPromiseOptions(input) {
|
|
|
2674
2745
|
signal: input,
|
|
2675
2746
|
time: 0
|
|
2676
2747
|
};
|
|
2677
|
-
const options =
|
|
2748
|
+
const options = isPlainObject(input) ? input : {};
|
|
2678
2749
|
return {
|
|
2679
2750
|
signal: options.signal instanceof AbortSignal ? options.signal : void 0,
|
|
2680
2751
|
time: getNumberOrDefault(options.time, 0)
|
|
@@ -2686,7 +2757,7 @@ function createPromisesOptions(input) {
|
|
|
2686
2757
|
signal: input,
|
|
2687
2758
|
strategy: PROMISE_STRATEGY_DEFAULT
|
|
2688
2759
|
};
|
|
2689
|
-
const options =
|
|
2760
|
+
const options = isPlainObject(input) ? input : {};
|
|
2690
2761
|
return {
|
|
2691
2762
|
signal: options.signal instanceof AbortSignal ? options.signal : void 0,
|
|
2692
2763
|
strategy: getStrategyOrDefault(options.strategy)
|
|
@@ -2725,7 +2796,7 @@ function isRejected(value) {
|
|
|
2725
2796
|
return isType(value, PROMISE_TYPE_REJECTED);
|
|
2726
2797
|
}
|
|
2727
2798
|
function isType(value, type) {
|
|
2728
|
-
return
|
|
2799
|
+
return isPlainObject(value) && "status" in value && value.status === type;
|
|
2729
2800
|
}
|
|
2730
2801
|
//#endregion
|
|
2731
2802
|
//#region src/result/misc.ts
|
|
@@ -2785,34 +2856,34 @@ function delay(options) {
|
|
|
2785
2856
|
const { signal, time } = createPromiseOptions(options);
|
|
2786
2857
|
if (signal?.aborted ?? false) return Promise.reject(signal?.reason);
|
|
2787
2858
|
const aborter = createAborter(signal, () => {
|
|
2788
|
-
|
|
2859
|
+
limiter.cancel();
|
|
2789
2860
|
rejector(signal?.reason);
|
|
2790
2861
|
});
|
|
2791
|
-
const
|
|
2862
|
+
const limiter = getLimiter(LIMITER_WAIT, () => settlePromise(resolver, void 0, aborter), time);
|
|
2792
2863
|
let rejector;
|
|
2793
2864
|
let resolver;
|
|
2794
2865
|
return new Promise((resolve, reject) => {
|
|
2795
2866
|
rejector = reject;
|
|
2796
2867
|
resolver = resolve;
|
|
2797
2868
|
if (time === 0) settlePromise(resolver, void 0, aborter);
|
|
2798
|
-
else
|
|
2869
|
+
else limiter.run();
|
|
2799
2870
|
});
|
|
2800
2871
|
}
|
|
2801
2872
|
//#endregion
|
|
2802
2873
|
//#region src/promise/timed.ts
|
|
2803
2874
|
async function getTimedPromise(promise, time, signal) {
|
|
2804
2875
|
const aborter = createAborter(signal, () => {
|
|
2805
|
-
|
|
2876
|
+
limiter.cancel();
|
|
2806
2877
|
rejector(signal?.reason);
|
|
2807
2878
|
});
|
|
2808
|
-
const
|
|
2879
|
+
const limiter = getLimiter(LIMITER_WAIT, () => settlePromise(rejector, new PromiseTimeoutError(), aborter), time);
|
|
2809
2880
|
let rejector;
|
|
2810
2881
|
return Promise.race([promise, new Promise((_, reject) => {
|
|
2811
2882
|
rejector = reject;
|
|
2812
|
-
|
|
2883
|
+
limiter.run();
|
|
2813
2884
|
})]).then((value) => {
|
|
2814
2885
|
aborter?.cancel();
|
|
2815
|
-
|
|
2886
|
+
limiter.cancel();
|
|
2816
2887
|
rejector(void 0);
|
|
2817
2888
|
return value;
|
|
2818
2889
|
});
|
|
@@ -2895,7 +2966,6 @@ async function resultPromises(items, signal) {
|
|
|
2895
2966
|
return promises(items, signal).then(getResultsFromPromises);
|
|
2896
2967
|
}
|
|
2897
2968
|
promises.result = resultPromises;
|
|
2898
|
-
Object.defineProperty(promises, "result", { value: resultPromises });
|
|
2899
2969
|
//#endregion
|
|
2900
2970
|
//#region src/result/index.ts
|
|
2901
2971
|
async function asyncAttempt(value, err) {
|
|
@@ -2915,7 +2985,6 @@ function attempt(callback, err) {
|
|
|
2915
2985
|
}
|
|
2916
2986
|
}
|
|
2917
2987
|
attempt.async = asyncAttempt;
|
|
2918
|
-
Object.defineProperty(attempt, "async", { value: asyncAttempt });
|
|
2919
2988
|
//#endregion
|
|
2920
2989
|
//#region src/result/match.ts
|
|
2921
2990
|
async function asyncMatchResult(result, first, error) {
|
|
@@ -2941,7 +3010,6 @@ function matchResult(result, first, error) {
|
|
|
2941
3010
|
}
|
|
2942
3011
|
const MATCH_MESSAGE = "`result.match` expected a Result or a function that returns a Result";
|
|
2943
3012
|
matchResult.async = asyncMatchResult;
|
|
2944
|
-
Object.defineProperty(matchResult, "async", { value: asyncMatchResult });
|
|
2945
3013
|
//#endregion
|
|
2946
3014
|
//#region src/result/work/flow.ts
|
|
2947
3015
|
function attemptAsyncFlow(...fns) {
|
|
@@ -2965,7 +3033,6 @@ function attemptFlow(...fns) {
|
|
|
2965
3033
|
});
|
|
2966
3034
|
}
|
|
2967
3035
|
attemptFlow.async = attemptAsyncFlow;
|
|
2968
|
-
Object.defineProperty(attemptFlow, "async", { value: attemptAsyncFlow });
|
|
2969
3036
|
//#endregion
|
|
2970
3037
|
//#region src/result/work/pipe.ts
|
|
2971
3038
|
async function attemptAsyncPipe(initial, first, ...seconds) {
|
|
@@ -2985,7 +3052,6 @@ function attemptPipe(initial, first, ...seconds) {
|
|
|
2985
3052
|
});
|
|
2986
3053
|
}
|
|
2987
3054
|
attemptPipe.async = attemptAsyncPipe;
|
|
2988
|
-
Object.defineProperty(attemptPipe, "async", { value: attemptAsyncPipe });
|
|
2989
3055
|
//#endregion
|
|
2990
3056
|
//#region src/string/match.ts
|
|
2991
3057
|
/**
|
|
@@ -3035,6 +3101,27 @@ const MATCH_STARTS_WITH = "startsWith";
|
|
|
3035
3101
|
const matchMemoizers = {};
|
|
3036
3102
|
//#endregion
|
|
3037
3103
|
//#region src/string/fuzzy.ts
|
|
3104
|
+
const FUZZY_PROPERTY = "$fuzzy";
|
|
3105
|
+
const FUZZY_SYMBOL = Symbol(FUZZY_PROPERTY);
|
|
3106
|
+
function Fuzzy(state) {
|
|
3107
|
+
this[FUZZY_SYMBOL] = state;
|
|
3108
|
+
}
|
|
3109
|
+
Fuzzy.prototype[FUZZY_PROPERTY] = true;
|
|
3110
|
+
Fuzzy.prototype.search = search;
|
|
3111
|
+
Object.defineProperties(Fuzzy.prototype, {
|
|
3112
|
+
items: {
|
|
3113
|
+
enumerable: true,
|
|
3114
|
+
get: getFuzzyItems,
|
|
3115
|
+
set: setFuzzyItems
|
|
3116
|
+
},
|
|
3117
|
+
strings: {
|
|
3118
|
+
enumerable: true,
|
|
3119
|
+
get: getFuzzyStrings
|
|
3120
|
+
}
|
|
3121
|
+
});
|
|
3122
|
+
function createFuzzyItems(items) {
|
|
3123
|
+
return items.sort((first, second) => first.haystack.localeCompare(second.haystack)).map(({ item }) => item);
|
|
3124
|
+
}
|
|
3038
3125
|
function createFuzzyOptions(input, state) {
|
|
3039
3126
|
const options = isPlainObject(input) ? input : {};
|
|
3040
3127
|
const limit = typeof input === "number" ? input : options.limit;
|
|
@@ -3054,43 +3141,13 @@ function createFuzzyState(items, input) {
|
|
|
3054
3141
|
tolerance: options.tolerance
|
|
3055
3142
|
};
|
|
3056
3143
|
}
|
|
3057
|
-
function getHandler(input) {
|
|
3058
|
-
if (input == null || input === getString) return getString;
|
|
3059
|
-
switch (typeof input) {
|
|
3060
|
-
case "function": return input;
|
|
3061
|
-
case "string": return (item) => item[input];
|
|
3062
|
-
default:
|
|
3063
|
-
if (isPlainObject(input)) return getHandler(input.key ?? input.handler);
|
|
3064
|
-
throw new TypeError(FUZZY_MESSAGE_HANDLER);
|
|
3065
|
-
}
|
|
3066
|
-
}
|
|
3067
|
-
function getFuzzyItems(items) {
|
|
3068
|
-
return items.sort((first, second) => first.haystack.localeCompare(second.haystack)).map(({ item }) => item);
|
|
3069
|
-
}
|
|
3070
|
-
function getTolerance(input, state) {
|
|
3071
|
-
if (typeof input === "number" && !Number.isNaN(input)) return input < 0 ? 0 : Math.floor(input);
|
|
3072
|
-
return state?.tolerance ?? FUZZY_PROXIMITY_THRESHOLD;
|
|
3073
|
-
}
|
|
3074
3144
|
function fuzzy(items, configuration) {
|
|
3075
3145
|
if (!Array.isArray(items)) throw new TypeError(FUZZY_MESSAGE_ARRAY);
|
|
3076
|
-
|
|
3077
|
-
const instance = { search: (value, options) => search(state.items, state.strings, value, options == null ? state : createFuzzyOptions(options, state)) };
|
|
3078
|
-
Object.defineProperties(instance, {
|
|
3079
|
-
items: {
|
|
3080
|
-
enumerable: true,
|
|
3081
|
-
get: () => state.items.slice(),
|
|
3082
|
-
set: (value) => setItems(state, value)
|
|
3083
|
-
},
|
|
3084
|
-
strings: {
|
|
3085
|
-
enumerable: true,
|
|
3086
|
-
get: () => state.strings.slice()
|
|
3087
|
-
}
|
|
3088
|
-
});
|
|
3089
|
-
return Object.freeze(instance);
|
|
3146
|
+
return new Fuzzy(createFuzzyState(items, configuration));
|
|
3090
3147
|
}
|
|
3091
3148
|
/**
|
|
3092
3149
|
* Does the needle match the haystack in a fuzzy way?
|
|
3093
|
-
*
|
|
3150
|
+
*
|
|
3094
3151
|
* _Available as `fuzzyMatch` and `fuzzy.match`_
|
|
3095
3152
|
*
|
|
3096
3153
|
* @param haystack Haystack to search through
|
|
@@ -3103,17 +3160,21 @@ function fuzzyMatch(haystack, needle) {
|
|
|
3103
3160
|
if (includes(haystack, trimmed, true)) return true;
|
|
3104
3161
|
return getScore(haystack, trimmed) > -1;
|
|
3105
3162
|
}
|
|
3106
|
-
function
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
if (needleIndex === needleLength) return true;
|
|
3163
|
+
function getHandler(input) {
|
|
3164
|
+
if (input == null || input === getString) return getString;
|
|
3165
|
+
switch (typeof input) {
|
|
3166
|
+
case "function": return input;
|
|
3167
|
+
case "string": return (item) => item[input];
|
|
3168
|
+
default:
|
|
3169
|
+
if (isPlainObject(input)) return getHandler(input.key ?? input.handler);
|
|
3170
|
+
throw new TypeError(FUZZY_MESSAGE_HANDLER);
|
|
3115
3171
|
}
|
|
3116
|
-
|
|
3172
|
+
}
|
|
3173
|
+
function getFuzzyItems() {
|
|
3174
|
+
return this[FUZZY_SYMBOL].items.slice();
|
|
3175
|
+
}
|
|
3176
|
+
function getFuzzyStrings() {
|
|
3177
|
+
return this[FUZZY_SYMBOL].strings.slice();
|
|
3117
3178
|
}
|
|
3118
3179
|
function getScore(haystack, needle) {
|
|
3119
3180
|
if (!isSubsequence(haystack, needle)) return -1;
|
|
@@ -3139,26 +3200,55 @@ function getScore(haystack, needle) {
|
|
|
3139
3200
|
score -= Math.floor(lowerCaseHaystack.length / FUZZY_LENGTH_DIVISOR);
|
|
3140
3201
|
return Math.max(0, score);
|
|
3141
3202
|
}
|
|
3142
|
-
function
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3203
|
+
function getTolerance(input, state) {
|
|
3204
|
+
if (typeof input === "number" && !Number.isNaN(input)) return input < 0 ? 0 : Math.floor(input);
|
|
3205
|
+
return state?.tolerance ?? FUZZY_PROXIMITY_THRESHOLD;
|
|
3206
|
+
}
|
|
3207
|
+
/**
|
|
3208
|
+
* Is the value a fuzzy searcher?
|
|
3209
|
+
*
|
|
3210
|
+
* _Available as `isFuzzy` and `fuzzy.is`_
|
|
3211
|
+
*
|
|
3212
|
+
* @param value Value to check
|
|
3213
|
+
* @returns `true` if the value is a fuzzy searcher, otherwise `false`
|
|
3214
|
+
*/
|
|
3215
|
+
function isFuzzy(value) {
|
|
3216
|
+
return typeof value === "object" && value !== null && FUZZY_PROPERTY in value && value[FUZZY_PROPERTY] === true;
|
|
3217
|
+
}
|
|
3218
|
+
function isSubsequence(haystack, needle) {
|
|
3219
|
+
const lowerCaseHaystack = lowerCase(haystack);
|
|
3220
|
+
const lowerCaseNeedle = lowerCase(needle);
|
|
3221
|
+
const haystackLength = lowerCaseHaystack.length;
|
|
3222
|
+
const needleLength = lowerCaseNeedle.length;
|
|
3223
|
+
let needleIndex = 0;
|
|
3224
|
+
for (let haystackIndex = 0; haystackIndex < haystackLength; haystackIndex += 1) {
|
|
3225
|
+
if (lowerCaseHaystack[haystackIndex] === lowerCaseNeedle[needleIndex]) needleIndex += 1;
|
|
3226
|
+
if (needleIndex === needleLength) return true;
|
|
3227
|
+
}
|
|
3228
|
+
return false;
|
|
3229
|
+
}
|
|
3230
|
+
function search(input, option) {
|
|
3231
|
+
const state = this[FUZZY_SYMBOL];
|
|
3232
|
+
const options = option == null ? state : createFuzzyOptions(option, state);
|
|
3233
|
+
const result = {
|
|
3234
|
+
exact: [],
|
|
3235
|
+
similar: []
|
|
3236
|
+
};
|
|
3237
|
+
const value = typeof input === "string" ? input.trim() : "";
|
|
3238
|
+
if (value.length === 0) {
|
|
3239
|
+
result.exact = state.items.slice(0, options.limit);
|
|
3240
|
+
return result;
|
|
3241
|
+
}
|
|
3242
|
+
let { length } = state.items;
|
|
3243
|
+
const exact = [];
|
|
3244
|
+
const similar = [];
|
|
3245
|
+
const scored = {};
|
|
3246
|
+
for (let index = 0; index < length; index += 1) {
|
|
3247
|
+
const item = state.items[index];
|
|
3248
|
+
const haystack = state.strings[index];
|
|
3249
|
+
if (includes(haystack, value, true)) {
|
|
3250
|
+
exact.push({
|
|
3251
|
+
item,
|
|
3162
3252
|
haystack
|
|
3163
3253
|
});
|
|
3164
3254
|
continue;
|
|
@@ -3179,16 +3269,17 @@ function search(items, strings, input, options) {
|
|
|
3179
3269
|
for (let index = 0; index < length; index += 1) {
|
|
3180
3270
|
const key = keys[index];
|
|
3181
3271
|
if (maxScore - key > options.tolerance) break;
|
|
3182
|
-
similar.push(...
|
|
3272
|
+
similar.push(...createFuzzyItems(scored[key]));
|
|
3183
3273
|
}
|
|
3184
3274
|
}
|
|
3185
|
-
result.exact =
|
|
3275
|
+
result.exact = createFuzzyItems(options.limit == null ? exact : exact.slice(0, options.limit));
|
|
3186
3276
|
if (options.limit == null) result.similar = similar;
|
|
3187
3277
|
else result.similar = similar.slice(0, options.limit - result.exact.length);
|
|
3188
3278
|
return result;
|
|
3189
3279
|
}
|
|
3190
|
-
function
|
|
3280
|
+
function setFuzzyItems(value) {
|
|
3191
3281
|
if (!Array.isArray(value)) throw new TypeError(FUZZY_MESSAGE_ARRAY);
|
|
3282
|
+
const state = this[FUZZY_SYMBOL];
|
|
3192
3283
|
state.items = value.slice();
|
|
3193
3284
|
state.strings = value.map(state.handler);
|
|
3194
3285
|
}
|
|
@@ -3196,8 +3287,8 @@ const FUZZY_LENGTH_DIVISOR = 3;
|
|
|
3196
3287
|
const FUZZY_MESSAGE_ARRAY = "Fuzzy requires an array of items";
|
|
3197
3288
|
const FUZZY_MESSAGE_HANDLER = "Fuzzy requires a key or function to stringify items";
|
|
3198
3289
|
const FUZZY_PROXIMITY_THRESHOLD = 5;
|
|
3290
|
+
fuzzy.is = isFuzzy;
|
|
3199
3291
|
fuzzy.match = fuzzyMatch;
|
|
3200
|
-
Object.defineProperty(fuzzy, "match", { value: fuzzyMatch });
|
|
3201
3292
|
//#endregion
|
|
3202
3293
|
//#region src/string/index.ts
|
|
3203
3294
|
function dedent(value, ...values) {
|
|
@@ -3294,6 +3385,10 @@ const STRING_NUMERICAL_PREFIX_PATTERN = /^\d/;
|
|
|
3294
3385
|
const STRING_ZERO = "0";
|
|
3295
3386
|
//#endregion
|
|
3296
3387
|
//#region src/string/normalize.ts
|
|
3388
|
+
function Normalizer(options) {
|
|
3389
|
+
this[NORMALIZE_SYMBOL] = options;
|
|
3390
|
+
}
|
|
3391
|
+
Normalizer.prototype.normalize = normalizeString;
|
|
3297
3392
|
function createNormalizeOptions(input) {
|
|
3298
3393
|
const options = isPlainObject(input) ? input : {};
|
|
3299
3394
|
return {
|
|
@@ -3328,8 +3423,7 @@ function deburr(value) {
|
|
|
3328
3423
|
* @returns Normalizer function
|
|
3329
3424
|
*/
|
|
3330
3425
|
function initializeNormalizer(options) {
|
|
3331
|
-
|
|
3332
|
-
return (value) => normalizeString(value, normalization);
|
|
3426
|
+
return new Normalizer(createNormalizeOptions(options));
|
|
3333
3427
|
}
|
|
3334
3428
|
/**
|
|
3335
3429
|
* Normalize a string
|
|
@@ -3341,10 +3435,11 @@ function initializeNormalizer(options) {
|
|
|
3341
3435
|
* @returns Normalized string
|
|
3342
3436
|
*/
|
|
3343
3437
|
function normalize(value, options) {
|
|
3344
|
-
return normalizeString(
|
|
3438
|
+
return normalizeString.call(createNormalizeOptions(options), value);
|
|
3345
3439
|
}
|
|
3346
|
-
function normalizeString(value
|
|
3440
|
+
function normalizeString(value) {
|
|
3347
3441
|
if (typeof value !== "string") return "";
|
|
3442
|
+
const options = NORMALIZE_SYMBOL in this ? this[NORMALIZE_SYMBOL] : this;
|
|
3348
3443
|
let result = value;
|
|
3349
3444
|
if (options.trim) result = result.trim();
|
|
3350
3445
|
if (options.whitespace) result = result.replace(NORMALIZE_WHITESPACE_PATTERN, NORMALIZE_WHITESPACE_REPLACEMENT);
|
|
@@ -3391,13 +3486,17 @@ const NORMALIZE_DEBURR_PATTERN_SIMPLE = /[\u0300-\u036f]/g;
|
|
|
3391
3486
|
const NORMALIZE_NORMALIZATION_NORMALIZATION = "NFC";
|
|
3392
3487
|
const NORMALIZE_SPECIAL_PATTERN = /[\p{P}\p{S}]/gu;
|
|
3393
3488
|
const NORMALIZE_SPECIAL_REPLACEMENT = "";
|
|
3489
|
+
const NORMALIZE_SYMBOL = Symbol("normalize");
|
|
3394
3490
|
const NORMALIZE_WHITESPACE_PATTERN = /\s+/g;
|
|
3395
3491
|
const NORMALIZE_WHITESPACE_REPLACEMENT = " ";
|
|
3396
3492
|
let deburrMemoizer;
|
|
3397
3493
|
normalize.initialize = initializeNormalizer;
|
|
3398
|
-
Object.defineProperty(normalize, "initialize", { value: initializeNormalizer });
|
|
3399
3494
|
//#endregion
|
|
3400
3495
|
//#region src/string/template.ts
|
|
3496
|
+
function Templater(options) {
|
|
3497
|
+
this[TEMPLATE_SYMBOL] = options;
|
|
3498
|
+
}
|
|
3499
|
+
Templater.prototype.render = render;
|
|
3401
3500
|
function createTemplateOptions(input) {
|
|
3402
3501
|
const options = isPlainObject(input) ? input : {};
|
|
3403
3502
|
return {
|
|
@@ -3431,10 +3530,12 @@ function handleTemplate(value, pattern, ignoreCase, variables) {
|
|
|
3431
3530
|
* @returns _Templater_ function
|
|
3432
3531
|
*/
|
|
3433
3532
|
function initializeTemplater(options) {
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
}
|
|
3533
|
+
return new Templater(createTemplateOptions(options));
|
|
3534
|
+
}
|
|
3535
|
+
function render(value, ...parameters) {
|
|
3536
|
+
const { ignoreCase, pattern } = this[TEMPLATE_SYMBOL];
|
|
3537
|
+
if (isTemplateStringsArray(value)) return (variables) => handleTemplate(interpolate(value, parameters), pattern, ignoreCase, variables);
|
|
3538
|
+
return handleTemplate(value, pattern, ignoreCase, parameters[0]);
|
|
3438
3539
|
}
|
|
3439
3540
|
function template(value, ...parameters) {
|
|
3440
3541
|
if (isTemplateStringsArray(value)) return getRenderer(value, parameters);
|
|
@@ -3442,11 +3543,17 @@ function template(value, ...parameters) {
|
|
|
3442
3543
|
return handleTemplate(value, pattern, ignoreCase, parameters[0]);
|
|
3443
3544
|
}
|
|
3444
3545
|
const TEMPLATE_EXPRESSION_VARIABLE = /{{([\s\S]+?)}}/g;
|
|
3546
|
+
const TEMPLATE_SYMBOL = Symbol("template");
|
|
3445
3547
|
template.initialize = initializeTemplater;
|
|
3446
|
-
Object.defineProperty(template, "initialize", { value: initializeTemplater });
|
|
3447
3548
|
//#endregion
|
|
3448
3549
|
//#region src/value/clone.ts
|
|
3449
3550
|
const CLONE_NAME = "clone";
|
|
3551
|
+
function Cloner(options) {
|
|
3552
|
+
this[CLONE_SYMBOL] = options;
|
|
3553
|
+
}
|
|
3554
|
+
Cloner.prototype.clone = cloneFromCloner;
|
|
3555
|
+
Cloner.prototype.deregister = deregisterCloner;
|
|
3556
|
+
Cloner.prototype.register = registerCloner;
|
|
3450
3557
|
function clone(value, options) {
|
|
3451
3558
|
return cloneAny(value, { copy: false }, 0, options);
|
|
3452
3559
|
}
|
|
@@ -3490,6 +3597,12 @@ function cloneDataView(value, parameters, depth) {
|
|
|
3490
3597
|
parameters.references.set(value, cloned);
|
|
3491
3598
|
return cloned;
|
|
3492
3599
|
}
|
|
3600
|
+
function cloneFromCloner(value) {
|
|
3601
|
+
return cloneAny(value, {
|
|
3602
|
+
copy: false,
|
|
3603
|
+
options: this[CLONE_SYMBOL]
|
|
3604
|
+
}, 0);
|
|
3605
|
+
}
|
|
3493
3606
|
function cloneMap(map, parameters, depth) {
|
|
3494
3607
|
if (depth >= CLONE_MAX_DEPTH) return map;
|
|
3495
3608
|
if (parameters.copy) return new Map(map);
|
|
@@ -3561,7 +3674,7 @@ function createCloneOptions(input) {
|
|
|
3561
3674
|
* @param constructor Class constructor
|
|
3562
3675
|
*/
|
|
3563
3676
|
function deregisterCloner(constructor) {
|
|
3564
|
-
|
|
3677
|
+
cloneHandler.base.deregister(constructor);
|
|
3565
3678
|
}
|
|
3566
3679
|
/**
|
|
3567
3680
|
* Create a cloner with predefined options
|
|
@@ -3572,20 +3685,7 @@ function deregisterCloner(constructor) {
|
|
|
3572
3685
|
* @returns Cloner function
|
|
3573
3686
|
*/
|
|
3574
3687
|
function initializeCloner(options) {
|
|
3575
|
-
|
|
3576
|
-
function cloner(value) {
|
|
3577
|
-
return cloneAny(value, {
|
|
3578
|
-
copy: false,
|
|
3579
|
-
options: opts
|
|
3580
|
-
}, 0);
|
|
3581
|
-
}
|
|
3582
|
-
cloner.deregister = deregisterCloner;
|
|
3583
|
-
cloner.register = registerCloner;
|
|
3584
|
-
Object.defineProperties(cloner, {
|
|
3585
|
-
deregister: { value: deregisterCloner },
|
|
3586
|
-
register: { value: registerCloner }
|
|
3587
|
-
});
|
|
3588
|
-
return cloner;
|
|
3688
|
+
return new Cloner(createCloneOptions(options));
|
|
3589
3689
|
}
|
|
3590
3690
|
/**
|
|
3591
3691
|
* Register a clone handler for a specific class
|
|
@@ -3596,7 +3696,7 @@ function initializeCloner(options) {
|
|
|
3596
3696
|
* @param handler Method name or clone function _(defaults to method name `clone`)_
|
|
3597
3697
|
*/
|
|
3598
3698
|
function registerCloner(constructor, handler) {
|
|
3599
|
-
|
|
3699
|
+
cloneHandler.base.register(constructor, handler);
|
|
3600
3700
|
}
|
|
3601
3701
|
function tryStructuredClone(value, parameters, depth) {
|
|
3602
3702
|
if (depth >= CLONE_MAX_DEPTH) return value;
|
|
@@ -3618,7 +3718,7 @@ const CLONE_DEFAULT_OPTIONS = {
|
|
|
3618
3718
|
copySymbols: false
|
|
3619
3719
|
};
|
|
3620
3720
|
const CLONE_MAX_DEPTH = 100;
|
|
3621
|
-
const
|
|
3721
|
+
const cloneHandler = createValueHandler(clone, {
|
|
3622
3722
|
callback: tryStructuredClone,
|
|
3623
3723
|
method: CLONE_NAME
|
|
3624
3724
|
});
|
|
@@ -3632,16 +3732,11 @@ const CLONE_PRIMITIVES = {
|
|
|
3632
3732
|
symbol: false,
|
|
3633
3733
|
undefined: true
|
|
3634
3734
|
};
|
|
3735
|
+
const CLONE_SYMBOL = Symbol(CLONE_NAME);
|
|
3635
3736
|
clone.deregister = deregisterCloner;
|
|
3636
|
-
clone.handlers =
|
|
3737
|
+
clone.handlers = cloneHandler;
|
|
3637
3738
|
clone.initialize = initializeCloner;
|
|
3638
3739
|
clone.register = registerCloner;
|
|
3639
|
-
Object.defineProperties(clone, {
|
|
3640
|
-
deregister: { value: deregisterCloner },
|
|
3641
|
-
handlers: { value: cloneHandlers },
|
|
3642
|
-
initialize: { value: initializeCloner },
|
|
3643
|
-
register: { value: registerCloner }
|
|
3644
|
-
});
|
|
3645
3740
|
//#endregion
|
|
3646
3741
|
//#region src/value/collection.ts
|
|
3647
3742
|
function inMap(map, value, key) {
|
|
@@ -3834,7 +3929,7 @@ function freezeValue(value, references, flat) {
|
|
|
3834
3929
|
}
|
|
3835
3930
|
/**
|
|
3836
3931
|
* Is the value frozen?
|
|
3837
|
-
*
|
|
3932
|
+
*
|
|
3838
3933
|
* _Available as `isFrozen` and `freeze.is`_
|
|
3839
3934
|
*
|
|
3840
3935
|
* @param value Value to check
|
|
@@ -3847,14 +3942,10 @@ function isFrozen(value) {
|
|
|
3847
3942
|
const frozenValues = /* @__PURE__ */ new WeakSet();
|
|
3848
3943
|
freeze.flat = flatFreeze;
|
|
3849
3944
|
freeze.is = isFrozen;
|
|
3850
|
-
Object.defineProperties(freeze, {
|
|
3851
|
-
flat: { value: flatFreeze },
|
|
3852
|
-
is: { value: isFrozen }
|
|
3853
|
-
});
|
|
3854
3945
|
//#endregion
|
|
3855
3946
|
//#region src/internal/value/partial.ts
|
|
3856
3947
|
function partial(value, providedKeys, omit) {
|
|
3857
|
-
if (
|
|
3948
|
+
if (!isPlainObject(value)) return {};
|
|
3858
3949
|
const keys = omit ? Object.keys(value) : Array.isArray(providedKeys) ? providedKeys : [];
|
|
3859
3950
|
const { length } = keys;
|
|
3860
3951
|
if (length === 0) return omit ? value : {};
|
|
@@ -3983,6 +4074,17 @@ function unsmush(value) {
|
|
|
3983
4074
|
}
|
|
3984
4075
|
//#endregion
|
|
3985
4076
|
//#region src/value/merge.ts
|
|
4077
|
+
function Assigner(options) {
|
|
4078
|
+
this[MERGE_SYMBOL_ASSIGN] = {
|
|
4079
|
+
...options,
|
|
4080
|
+
assignValues: true
|
|
4081
|
+
};
|
|
4082
|
+
}
|
|
4083
|
+
Assigner.prototype.assign = assignFromAssigner;
|
|
4084
|
+
function Merger(options) {
|
|
4085
|
+
this[MERGE_SYMBOL_MERGE] = options;
|
|
4086
|
+
}
|
|
4087
|
+
Merger.prototype.merge = mergeFromMerger;
|
|
3986
4088
|
/**
|
|
3987
4089
|
* Assign values from one or more objects to the first one
|
|
3988
4090
|
*
|
|
@@ -3996,6 +4098,9 @@ function assign(to, from, options) {
|
|
|
3996
4098
|
actual.assignValues = true;
|
|
3997
4099
|
return mergeValues([to, ...from], actual);
|
|
3998
4100
|
}
|
|
4101
|
+
function assignFromAssigner(to, from) {
|
|
4102
|
+
return mergeValues([to, ...from], this[MERGE_SYMBOL_ASSIGN]);
|
|
4103
|
+
}
|
|
3999
4104
|
function createMergeOptions(options) {
|
|
4000
4105
|
const actual = {
|
|
4001
4106
|
assignValues: false,
|
|
@@ -4024,9 +4129,7 @@ function getReplaceableObjects(value) {
|
|
|
4024
4129
|
* @returns Assigner function
|
|
4025
4130
|
*/
|
|
4026
4131
|
function initializeAssigner(options) {
|
|
4027
|
-
|
|
4028
|
-
actual.assignValues = true;
|
|
4029
|
-
return ((to, from) => mergeValues([to, ...from], actual));
|
|
4132
|
+
return new Assigner(createMergeOptions(options));
|
|
4030
4133
|
}
|
|
4031
4134
|
/**
|
|
4032
4135
|
* Create a merger with predefined options
|
|
@@ -4037,8 +4140,7 @@ function initializeAssigner(options) {
|
|
|
4037
4140
|
* @returns Merger function
|
|
4038
4141
|
*/
|
|
4039
4142
|
function initializeMerger(options) {
|
|
4040
|
-
|
|
4041
|
-
return ((values) => mergeValues(values, actual));
|
|
4143
|
+
return new Merger(createMergeOptions(options));
|
|
4042
4144
|
}
|
|
4043
4145
|
/**
|
|
4044
4146
|
* Merge multiple arrays or objects into a single one
|
|
@@ -4050,6 +4152,9 @@ function initializeMerger(options) {
|
|
|
4050
4152
|
function merge(values, options) {
|
|
4051
4153
|
return mergeValues(values, createMergeOptions(options));
|
|
4052
4154
|
}
|
|
4155
|
+
function mergeFromMerger(values) {
|
|
4156
|
+
return mergeValues(values, this[MERGE_SYMBOL_MERGE]);
|
|
4157
|
+
}
|
|
4053
4158
|
function mergeObjects(values, options, destination, prefix) {
|
|
4054
4159
|
const { length } = values;
|
|
4055
4160
|
const isArray = Array.isArray(destination ?? values[0]);
|
|
@@ -4079,13 +4184,17 @@ function mergeValues(values, options, prefix) {
|
|
|
4079
4184
|
if (actual.length > 1) return mergeObjects(actual, options, options.assignValues ? actual[0] : void 0, prefix);
|
|
4080
4185
|
return options.assignValues ? actual[0] : Array.isArray(actual[0]) ? actual[0].slice() : { ...actual[0] };
|
|
4081
4186
|
}
|
|
4187
|
+
const MERGE_SYMBOL_ASSIGN = Symbol("assign");
|
|
4188
|
+
const MERGE_SYMBOL_MERGE = Symbol("merge");
|
|
4082
4189
|
assign.initialize = initializeAssigner;
|
|
4083
4190
|
merge.initialize = initializeMerger;
|
|
4084
|
-
Object.defineProperty(assign, "initialize", { value: initializeAssigner });
|
|
4085
|
-
Object.defineProperty(merge, "initialize", { value: initializeMerger });
|
|
4086
4191
|
//#endregion
|
|
4087
4192
|
//#region src/value/transform.ts
|
|
4088
|
-
function
|
|
4193
|
+
function Transformer(transformer) {
|
|
4194
|
+
this[TRANSFORM_SYMBOL] = transformer;
|
|
4195
|
+
}
|
|
4196
|
+
Object.defineProperties(Transformer.prototype, { transform: { value: transformValue } });
|
|
4197
|
+
function getTransformHandler(input) {
|
|
4089
4198
|
if (typeof input === "function") return input;
|
|
4090
4199
|
if (isNonPlainObject(input)) return;
|
|
4091
4200
|
const keys = Object.keys(input);
|
|
@@ -4096,18 +4205,18 @@ function getTransformer(input) {
|
|
|
4096
4205
|
const value = input[key];
|
|
4097
4206
|
if (typeof value === "function") transformer[key] = value;
|
|
4098
4207
|
}
|
|
4099
|
-
|
|
4208
|
+
return Object.keys(transformer).length > 0 ? transformer : void 0;
|
|
4100
4209
|
}
|
|
4101
4210
|
function initializeTransformer(transform) {
|
|
4102
|
-
|
|
4103
|
-
return (value) => transformValue(value, transformer);
|
|
4211
|
+
return new Transformer(getTransformHandler(transform));
|
|
4104
4212
|
}
|
|
4105
4213
|
function transform(value, transform) {
|
|
4106
|
-
return transformValue(
|
|
4214
|
+
return transformValue.call(getTransformHandler(transform), value);
|
|
4107
4215
|
}
|
|
4108
|
-
function transformValue(value
|
|
4216
|
+
function transformValue(value) {
|
|
4109
4217
|
if (isNonPlainObject(value)) return {};
|
|
4110
|
-
if (
|
|
4218
|
+
if (this == null) return value;
|
|
4219
|
+
const transformer = TRANSFORM_SYMBOL in this ? this[TRANSFORM_SYMBOL] : this;
|
|
4111
4220
|
const keys = Object.keys(value);
|
|
4112
4221
|
const { length } = keys;
|
|
4113
4222
|
for (let index = 0; index < length; index += 1) {
|
|
@@ -4118,17 +4227,50 @@ function transformValue(value, transformer) {
|
|
|
4118
4227
|
}
|
|
4119
4228
|
return value;
|
|
4120
4229
|
}
|
|
4230
|
+
const TRANSFORM_SYMBOL = Symbol("transform");
|
|
4121
4231
|
transform.initialize = initializeTransformer;
|
|
4122
|
-
Object.defineProperty(transform, "initialize", { value: initializeTransformer });
|
|
4123
4232
|
//#endregion
|
|
4124
4233
|
//#region src/internal/subscription.ts
|
|
4125
|
-
|
|
4126
|
-
|
|
4234
|
+
const SUBSCRIPTION_NAME = "subscription";
|
|
4235
|
+
const SUBSCRIPTION_PROPERTY = "$subscription";
|
|
4236
|
+
const SUBSCRIPTION_STORE = "subscriptions";
|
|
4237
|
+
function Subscription(state, property, parameters) {
|
|
4238
|
+
this[SUBSCRIPTION_SYMBOL] = state;
|
|
4239
|
+
this[property.key] = property.value;
|
|
4240
|
+
state.aborter = createAborter(parameters.signal, () => this.unsubscribe(subscriptions, this, state));
|
|
4241
|
+
addSubscription(this);
|
|
4242
|
+
}
|
|
4243
|
+
Subscription.prototype[SUBSCRIPTION_PROPERTY] = SUBSCRIPTION_NAME;
|
|
4244
|
+
Subscription.prototype.unsubscribe = removeSubscription;
|
|
4245
|
+
Object.defineProperty(Subscription.prototype, "active", {
|
|
4246
|
+
enumerable: true,
|
|
4247
|
+
get: getSubscriptionActive
|
|
4248
|
+
});
|
|
4249
|
+
function Subscriptions(parameters) {
|
|
4250
|
+
const { keys, property } = createSubscriptionsParameters(parameters);
|
|
4251
|
+
this[SUBSCRIPTION_SYMBOL] = createSubscriptionsState(property, keys);
|
|
4252
|
+
}
|
|
4253
|
+
Subscriptions.prototype[SUBSCRIPTION_PROPERTY] = SUBSCRIPTION_STORE;
|
|
4254
|
+
Subscriptions.prototype.clear = clearSubscriptions;
|
|
4255
|
+
Subscriptions.prototype.create = createSubscription;
|
|
4256
|
+
Object.defineProperties(Subscriptions.prototype, {
|
|
4257
|
+
items: {
|
|
4258
|
+
enumerable: true,
|
|
4259
|
+
get: getSubscriptionsItems
|
|
4260
|
+
},
|
|
4261
|
+
values: {
|
|
4262
|
+
enumerable: true,
|
|
4263
|
+
get: getSubscriptionsValues
|
|
4264
|
+
}
|
|
4265
|
+
});
|
|
4266
|
+
function addSubscription(instance) {
|
|
4267
|
+
const state = instance[SUBSCRIPTION_SYMBOL];
|
|
4127
4268
|
const { key, value } = state.parameters;
|
|
4269
|
+
const { items, values } = state.subscriptions;
|
|
4128
4270
|
if (!isKey(key)) {
|
|
4129
|
-
items.any.add(
|
|
4130
|
-
values.from.any.set(value,
|
|
4131
|
-
values.to.any.set(
|
|
4271
|
+
items.any.add(instance);
|
|
4272
|
+
values.from.any.set(value, instance);
|
|
4273
|
+
values.to.any.set(instance, value);
|
|
4132
4274
|
return;
|
|
4133
4275
|
}
|
|
4134
4276
|
/* istanbul ignore if */
|
|
@@ -4140,29 +4282,32 @@ function addSubscription(subscriptions, subscription, state) {
|
|
|
4140
4282
|
keyedItems = /* @__PURE__ */ new Set();
|
|
4141
4283
|
items.keyed.set(key, keyedItems);
|
|
4142
4284
|
}
|
|
4143
|
-
keyedItems.add(
|
|
4285
|
+
keyedItems.add(instance);
|
|
4144
4286
|
let keyedFrom = values.from.keyed.get(key);
|
|
4145
4287
|
if (keyedFrom == null) {
|
|
4146
4288
|
keyedFrom = /* @__PURE__ */ new Map();
|
|
4147
4289
|
values.from.keyed.set(key, keyedFrom);
|
|
4148
4290
|
}
|
|
4149
|
-
keyedFrom.set(value,
|
|
4291
|
+
keyedFrom.set(value, instance);
|
|
4150
4292
|
let keyedTo = values.to.keyed.get(key);
|
|
4151
4293
|
if (keyedTo == null) {
|
|
4152
4294
|
keyedTo = /* @__PURE__ */ new Map();
|
|
4153
4295
|
values.to.keyed.set(key, keyedTo);
|
|
4154
4296
|
}
|
|
4155
|
-
keyedTo.set(
|
|
4297
|
+
keyedTo.set(instance, value);
|
|
4156
4298
|
}
|
|
4157
|
-
function clearSubscriptions(
|
|
4158
|
-
|
|
4159
|
-
|
|
4299
|
+
function clearSubscriptions() {
|
|
4300
|
+
const state = this[SUBSCRIPTION_SYMBOL];
|
|
4301
|
+
for (const susbcription of state.values.to.any.keys()) susbcription.unsubscribe();
|
|
4302
|
+
if (state.values.to.keyed != null && state.values.to.keyed.size > 0) for (const values of state.values.to.keyed.values()) for (const susbcription of values.keys()) susbcription.unsubscribe();
|
|
4160
4303
|
}
|
|
4161
|
-
function createSubscription(
|
|
4304
|
+
function createSubscription(params) {
|
|
4162
4305
|
const parameters = createSubscriptionParameters(params);
|
|
4163
4306
|
if (parameters.signal?.aborted ?? false) throw new Error(parameters.signal?.reason);
|
|
4307
|
+
const subscriptions = this[SUBSCRIPTION_SYMBOL];
|
|
4164
4308
|
const state = {
|
|
4165
4309
|
parameters,
|
|
4310
|
+
subscriptions,
|
|
4166
4311
|
active: true
|
|
4167
4312
|
};
|
|
4168
4313
|
const existing = getExistingSubscription(subscriptions, state);
|
|
@@ -4171,24 +4316,23 @@ function createSubscription(subscriptions, property, params) {
|
|
|
4171
4316
|
if (subscriptions.keys === false) throw new Error(SUBSCRIPTION_DISALLOWED_KEY);
|
|
4172
4317
|
else if (subscriptions.keys !== true && !subscriptions.keys.has(parameters.key)) throw new Error(SUBSCRIPTION_INVALID_KEY);
|
|
4173
4318
|
}
|
|
4174
|
-
|
|
4175
|
-
const instance = { unsubscribe: () => unsubscribe(subscriptions, instance, state) };
|
|
4176
|
-
Object.defineProperties(instance, {
|
|
4177
|
-
[SUBSCRIPTION_PROPERTY]: { value: SUBSCRIPTION_NAME },
|
|
4178
|
-
[property.key]: { value: property.value },
|
|
4179
|
-
active: {
|
|
4180
|
-
enumerable: true,
|
|
4181
|
-
get: () => (parameters.isActive?.() ?? true) && state.active
|
|
4182
|
-
}
|
|
4183
|
-
});
|
|
4184
|
-
addSubscription(subscriptions, instance, state);
|
|
4185
|
-
return [Object.freeze(instance), false];
|
|
4319
|
+
return [new Subscription(state, subscriptions.property, parameters), false];
|
|
4186
4320
|
}
|
|
4187
4321
|
function getExistingSubscription(subscriptions, state) {
|
|
4188
4322
|
const { values } = subscriptions;
|
|
4189
4323
|
const { parameters } = state;
|
|
4190
4324
|
return isKey(parameters.key) ? values.from.keyed?.get(parameters.key)?.get(parameters.value) : values.from.any.get(parameters.value);
|
|
4191
4325
|
}
|
|
4326
|
+
function getSubscriptionActive() {
|
|
4327
|
+
const state = this[SUBSCRIPTION_SYMBOL];
|
|
4328
|
+
return (state.parameters?.isActive?.() ?? true) && state.active;
|
|
4329
|
+
}
|
|
4330
|
+
function getSubscriptionsItems() {
|
|
4331
|
+
return this[SUBSCRIPTION_SYMBOL].items;
|
|
4332
|
+
}
|
|
4333
|
+
function getSubscriptionsValues() {
|
|
4334
|
+
return this[SUBSCRIPTION_SYMBOL].values;
|
|
4335
|
+
}
|
|
4192
4336
|
function createSubscriptionParameters(input) {
|
|
4193
4337
|
const values = isPlainObject(input) ? input : {};
|
|
4194
4338
|
if (values.value == null) throw new Error(SUBSCRIPTION_INVALID_VALUE);
|
|
@@ -4216,9 +4360,10 @@ function createSubscriptionsProperty(input) {
|
|
|
4216
4360
|
value: values.value == null ? SUBSCRIPTION_NAME : values.value
|
|
4217
4361
|
};
|
|
4218
4362
|
}
|
|
4219
|
-
function createSubscriptionsState(keys) {
|
|
4363
|
+
function createSubscriptionsState(property, keys) {
|
|
4220
4364
|
return {
|
|
4221
4365
|
keys,
|
|
4366
|
+
property,
|
|
4222
4367
|
items: {
|
|
4223
4368
|
any: /* @__PURE__ */ new Set(),
|
|
4224
4369
|
keyed: keys === false ? void 0 : /* @__PURE__ */ new Map()
|
|
@@ -4245,7 +4390,7 @@ function isSubscription(value) {
|
|
|
4245
4390
|
return isSubscriptionInstance(value, SUBSCRIPTION_NAME);
|
|
4246
4391
|
}
|
|
4247
4392
|
function isSubscriptionInstance(value, name) {
|
|
4248
|
-
return
|
|
4393
|
+
return typeof value === "object" && value !== null && SUBSCRIPTION_PROPERTY in value && value[SUBSCRIPTION_PROPERTY] === name;
|
|
4249
4394
|
}
|
|
4250
4395
|
/**
|
|
4251
4396
|
* Is the value a subscriptions store?
|
|
@@ -4266,16 +4411,17 @@ function removeFromStore(items, values, subscription, value, key) {
|
|
|
4266
4411
|
values.to.keyed?.get(key)?.delete(subscription);
|
|
4267
4412
|
}
|
|
4268
4413
|
}
|
|
4269
|
-
function removeSubscription(
|
|
4414
|
+
function removeSubscription() {
|
|
4415
|
+
const state = this[SUBSCRIPTION_SYMBOL];
|
|
4270
4416
|
if (!state.active) return;
|
|
4271
4417
|
state.aborter = void 0;
|
|
4272
4418
|
state.active = false;
|
|
4273
|
-
|
|
4274
|
-
state.parameters.signal = void 0;
|
|
4275
|
-
const { items, values } = subscriptionsState;
|
|
4419
|
+
const { items, values } = state.subscriptions;
|
|
4276
4420
|
const { key, value } = state.parameters;
|
|
4421
|
+
state.parameters = void 0;
|
|
4422
|
+
state.subscriptions = void 0;
|
|
4277
4423
|
if (!isKey(key)) {
|
|
4278
|
-
removeFromStore(items.any, values,
|
|
4424
|
+
removeFromStore(items.any, values, this, value);
|
|
4279
4425
|
return;
|
|
4280
4426
|
}
|
|
4281
4427
|
const keyed = items.keyed?.get(key);
|
|
@@ -4283,7 +4429,7 @@ function removeSubscription(subscriptionsState, subscription, state) {
|
|
|
4283
4429
|
if (items.keyed == null || keyed == null)
|
|
4284
4430
|
// istanbul ignore next
|
|
4285
4431
|
return;
|
|
4286
|
-
removeFromStore(keyed, values,
|
|
4432
|
+
removeFromStore(keyed, values, this, value, key);
|
|
4287
4433
|
if (keyed.size === 0) items.keyed.delete(key);
|
|
4288
4434
|
}
|
|
4289
4435
|
/**
|
|
@@ -4293,37 +4439,56 @@ function removeSubscription(subscriptionsState, subscription, state) {
|
|
|
4293
4439
|
* @returns Subscription store
|
|
4294
4440
|
*/
|
|
4295
4441
|
function subscriptions(parameters) {
|
|
4296
|
-
|
|
4297
|
-
const state = createSubscriptionsState(keys);
|
|
4298
|
-
const instance = {
|
|
4299
|
-
clear: () => clearSubscriptions(state),
|
|
4300
|
-
create: (parameters) => createSubscription(state, property, parameters)
|
|
4301
|
-
};
|
|
4302
|
-
Object.defineProperties(instance, {
|
|
4303
|
-
[SUBSCRIPTION_PROPERTY]: { value: SUBSCRIPTION_STORE },
|
|
4304
|
-
items: {
|
|
4305
|
-
enumerable: true,
|
|
4306
|
-
value: state.items
|
|
4307
|
-
},
|
|
4308
|
-
values: {
|
|
4309
|
-
enumerable: true,
|
|
4310
|
-
value: state.values
|
|
4311
|
-
}
|
|
4312
|
-
});
|
|
4313
|
-
return Object.freeze(instance);
|
|
4314
|
-
}
|
|
4315
|
-
function unsubscribe(subscriptionsState, subscription, state) {
|
|
4316
|
-
state.aborter?.cancel();
|
|
4317
|
-
removeSubscription(subscriptionsState, subscription, state);
|
|
4442
|
+
return new Subscriptions(parameters);
|
|
4318
4443
|
}
|
|
4319
4444
|
const SUBSCRIPTION_DISALLOWED_KEY = "Disallowed key for subscription";
|
|
4320
4445
|
const SUBSCRIPTION_INVALID_KEY = "Invalid key for subscription";
|
|
4321
4446
|
const SUBSCRIPTION_INVALID_VALUE = "A subscription requires a non-null value to identify it";
|
|
4322
|
-
const
|
|
4323
|
-
const SUBSCRIPTION_PROPERTY = "$subscriptions";
|
|
4324
|
-
const SUBSCRIPTION_STORE = "subscriptions";
|
|
4447
|
+
const SUBSCRIPTION_SYMBOL = Symbol(SUBSCRIPTION_PROPERTY);
|
|
4325
4448
|
//#endregion
|
|
4326
4449
|
//#region src/beacon.ts
|
|
4450
|
+
const BEACON_PROPERTY = "$beacon";
|
|
4451
|
+
const BEACON_NAME = "beacon";
|
|
4452
|
+
const BEACON_OBSERVABLE = "observable";
|
|
4453
|
+
function Beacon(value, options) {
|
|
4454
|
+
this[BEACON_SYMBOL] = {
|
|
4455
|
+
value,
|
|
4456
|
+
active: true,
|
|
4457
|
+
options: createBeaconOptions(options)
|
|
4458
|
+
};
|
|
4459
|
+
}
|
|
4460
|
+
Beacon.prototype[BEACON_PROPERTY] = BEACON_NAME;
|
|
4461
|
+
Beacon.prototype.deactivate = deactivateBeacon;
|
|
4462
|
+
Beacon.prototype.emit = emitBeaconValue;
|
|
4463
|
+
Beacon.prototype.error = emitBeaconError;
|
|
4464
|
+
Beacon.prototype.finish = finishBeacon;
|
|
4465
|
+
Object.defineProperties(Beacon.prototype, {
|
|
4466
|
+
active: {
|
|
4467
|
+
enumerable: true,
|
|
4468
|
+
get: getBeaconActive
|
|
4469
|
+
},
|
|
4470
|
+
observable: {
|
|
4471
|
+
enumerable: true,
|
|
4472
|
+
get: getBeaconObservable
|
|
4473
|
+
},
|
|
4474
|
+
value: {
|
|
4475
|
+
enumerable: true,
|
|
4476
|
+
get: getBeaconValue
|
|
4477
|
+
}
|
|
4478
|
+
});
|
|
4479
|
+
function Observable(beacon) {
|
|
4480
|
+
this[BEACON_SYMBOL] = {
|
|
4481
|
+
beacon,
|
|
4482
|
+
active: beacon.active
|
|
4483
|
+
};
|
|
4484
|
+
}
|
|
4485
|
+
Observable.prototype[BEACON_PROPERTY] = BEACON_OBSERVABLE;
|
|
4486
|
+
Observable.prototype.deactivate = deactiveateObservable;
|
|
4487
|
+
Observable.prototype.subscribe = subscribeToObservable;
|
|
4488
|
+
Object.defineProperty(Observable.prototype, "active", {
|
|
4489
|
+
enumerable: true,
|
|
4490
|
+
get: getObservableActive
|
|
4491
|
+
});
|
|
4327
4492
|
/**
|
|
4328
4493
|
* Create a new beacon
|
|
4329
4494
|
*
|
|
@@ -4332,60 +4497,22 @@ const SUBSCRIPTION_STORE = "subscriptions";
|
|
|
4332
4497
|
* @returns Beacon instance
|
|
4333
4498
|
*/
|
|
4334
4499
|
function beacon(value, options) {
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
};
|
|
4348
|
-
Object.defineProperties(instance, {
|
|
4349
|
-
[BEACON_PROPERTY]: { value: BEACON_NAME },
|
|
4350
|
-
active: {
|
|
4351
|
-
enumerable: true,
|
|
4352
|
-
get: () => state.active
|
|
4353
|
-
},
|
|
4354
|
-
observable: {
|
|
4355
|
-
enumerable: true,
|
|
4356
|
-
get: () => getObservable(state)
|
|
4357
|
-
},
|
|
4358
|
-
value: {
|
|
4359
|
-
enumerable: true,
|
|
4360
|
-
get: () => state.value
|
|
4361
|
-
}
|
|
4362
|
-
});
|
|
4363
|
-
return Object.freeze(instance);
|
|
4500
|
+
return new Beacon(value, options);
|
|
4501
|
+
}
|
|
4502
|
+
function closeBeacon(state, emit) {
|
|
4503
|
+
if (!state.active) return;
|
|
4504
|
+
state.active = false;
|
|
4505
|
+
const subscriptions = state.subscriptions?.values.to.any;
|
|
4506
|
+
if (subscriptions != null && subscriptions.size > 0) {
|
|
4507
|
+
for (const [, observer] of subscriptions) if (emit) observer.complete?.();
|
|
4508
|
+
}
|
|
4509
|
+
state.subscriptions?.clear();
|
|
4510
|
+
state.observable?.deactivate();
|
|
4511
|
+
state.observable = void 0;
|
|
4364
4512
|
}
|
|
4365
4513
|
function createBeaconOptions(input) {
|
|
4366
4514
|
const options = isPlainObject(input) ? input : {};
|
|
4367
|
-
|
|
4368
|
-
return options;
|
|
4369
|
-
}
|
|
4370
|
-
function createObservable(beacon) {
|
|
4371
|
-
const state = {
|
|
4372
|
-
beacon,
|
|
4373
|
-
active: beacon.active
|
|
4374
|
-
};
|
|
4375
|
-
const instance = {
|
|
4376
|
-
deactivate: () => {
|
|
4377
|
-
state.active = false;
|
|
4378
|
-
},
|
|
4379
|
-
subscribe: (first, second, third) => subscribeToObservable(state, first, second, third)
|
|
4380
|
-
};
|
|
4381
|
-
Object.defineProperties(instance, {
|
|
4382
|
-
[BEACON_PROPERTY]: { value: BEACON_OBSERVABLE },
|
|
4383
|
-
active: {
|
|
4384
|
-
enumerable: true,
|
|
4385
|
-
get: () => beacon.active && state.active
|
|
4386
|
-
}
|
|
4387
|
-
});
|
|
4388
|
-
return Object.freeze(instance);
|
|
4515
|
+
return { equal: typeof options.equal === "function" ? options.equal : Object.is };
|
|
4389
4516
|
}
|
|
4390
4517
|
function createObserver(first, second, third) {
|
|
4391
4518
|
let observer = { next: noop };
|
|
@@ -4395,25 +4522,44 @@ function createObserver(first, second, third) {
|
|
|
4395
4522
|
complete: getObservableCallback(third)
|
|
4396
4523
|
};
|
|
4397
4524
|
else if (typeof first === "object") {
|
|
4398
|
-
|
|
4399
|
-
observer.
|
|
4400
|
-
observer.
|
|
4525
|
+
const object = first;
|
|
4526
|
+
observer.complete = getObservableCallback(object?.complete);
|
|
4527
|
+
observer.error = getObservableCallback(object?.error);
|
|
4528
|
+
observer.next = getObservableCallback(object?.next);
|
|
4401
4529
|
}
|
|
4402
4530
|
return observer;
|
|
4403
4531
|
}
|
|
4404
|
-
function
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4532
|
+
function deactivateBeacon() {
|
|
4533
|
+
closeBeacon(this[BEACON_SYMBOL], false);
|
|
4534
|
+
}
|
|
4535
|
+
function deactiveateObservable() {
|
|
4536
|
+
this[BEACON_SYMBOL].active = false;
|
|
4537
|
+
}
|
|
4538
|
+
function emitBeaconError(error, finish) {
|
|
4539
|
+
updateBeacon(this, BEACON_TYPE_ERROR, error, finish ?? false);
|
|
4540
|
+
}
|
|
4541
|
+
function emitBeaconValue(value, finish) {
|
|
4542
|
+
updateBeacon(this, BEACON_TYPE_NEXT, value, finish ?? false);
|
|
4543
|
+
}
|
|
4544
|
+
function finishBeacon() {
|
|
4545
|
+
closeBeacon(this[BEACON_SYMBOL], true);
|
|
4411
4546
|
}
|
|
4412
|
-
function
|
|
4547
|
+
function getBeaconActive() {
|
|
4548
|
+
return this[BEACON_SYMBOL].active;
|
|
4549
|
+
}
|
|
4550
|
+
function getBeaconObservable() {
|
|
4551
|
+
const state = this[BEACON_SYMBOL];
|
|
4413
4552
|
if (!state.active) throw new Error(BEACON_MESSAGE_RETRIEVE);
|
|
4414
|
-
state.observable ??=
|
|
4553
|
+
state.observable ??= new Observable(state);
|
|
4415
4554
|
return state.observable;
|
|
4416
4555
|
}
|
|
4556
|
+
function getBeaconValue() {
|
|
4557
|
+
return this[BEACON_SYMBOL].value;
|
|
4558
|
+
}
|
|
4559
|
+
function getObservableActive() {
|
|
4560
|
+
const state = this[BEACON_SYMBOL];
|
|
4561
|
+
return state.beacon.active && state.active;
|
|
4562
|
+
}
|
|
4417
4563
|
function getObservableCallback(value) {
|
|
4418
4564
|
return typeof value === "function" ? value : noop;
|
|
4419
4565
|
}
|
|
@@ -4427,7 +4573,7 @@ function isBeacon(value) {
|
|
|
4427
4573
|
return isBeaconInstance(BEACON_NAME, value);
|
|
4428
4574
|
}
|
|
4429
4575
|
function isBeaconInstance(name, value) {
|
|
4430
|
-
return
|
|
4576
|
+
return typeof value === "object" && value !== null && BEACON_PROPERTY in value && value[BEACON_PROPERTY] === name;
|
|
4431
4577
|
}
|
|
4432
4578
|
/**
|
|
4433
4579
|
* Is the value a beacon subscription?
|
|
@@ -4447,8 +4593,10 @@ function isBeaconSubscription(value) {
|
|
|
4447
4593
|
function isObservable(value) {
|
|
4448
4594
|
return isBeaconInstance(BEACON_OBSERVABLE, value);
|
|
4449
4595
|
}
|
|
4450
|
-
function subscribeToObservable(
|
|
4596
|
+
function subscribeToObservable(first, second, third) {
|
|
4597
|
+
const state = this[BEACON_SYMBOL];
|
|
4451
4598
|
if (!state.beacon.active || !state.active) throw new Error(BEACON_MESSAGE_SUBSCRIBE);
|
|
4599
|
+
state.beacon.subscriptions ??= subscriptions({ property: beaconSubscription });
|
|
4452
4600
|
const observer = createObserver(first, second, third);
|
|
4453
4601
|
const [subscription] = state.beacon.subscriptions.create({
|
|
4454
4602
|
isActive: () => state.beacon.active && state.active,
|
|
@@ -4457,20 +4605,20 @@ function subscribeToObservable(state, first, second, third) {
|
|
|
4457
4605
|
observer.next?.(state.beacon.value);
|
|
4458
4606
|
return subscription;
|
|
4459
4607
|
}
|
|
4460
|
-
function updateBeacon(
|
|
4608
|
+
function updateBeacon(instance, type, value, finish) {
|
|
4609
|
+
const state = instance[BEACON_SYMBOL];
|
|
4461
4610
|
if (!state.active) return;
|
|
4462
4611
|
if (type === BEACON_TYPE_NEXT) {
|
|
4463
4612
|
if (state.options.equal(state.value, value)) return;
|
|
4464
4613
|
state.value = value;
|
|
4465
4614
|
}
|
|
4466
|
-
|
|
4467
|
-
if (
|
|
4615
|
+
const subscriptions = state.subscriptions?.values.to.any;
|
|
4616
|
+
if (subscriptions != null && subscriptions.size > 0) for (const [, observer] of subscriptions) observer[type]?.(value);
|
|
4617
|
+
if (finish === true) closeBeacon(state, true);
|
|
4468
4618
|
}
|
|
4469
4619
|
const BEACON_MESSAGE_RETRIEVE = "Cannot retrieve observable from a closed beacon";
|
|
4470
4620
|
const BEACON_MESSAGE_SUBSCRIBE = "Cannot subscribe to a closed observable";
|
|
4471
|
-
const
|
|
4472
|
-
const BEACON_NAME = "beacon";
|
|
4473
|
-
const BEACON_OBSERVABLE = "observable";
|
|
4621
|
+
const BEACON_SYMBOL = Symbol(BEACON_PROPERTY);
|
|
4474
4622
|
const BEACON_TYPE_ERROR = "error";
|
|
4475
4623
|
const BEACON_TYPE_NEXT = "next";
|
|
4476
4624
|
const beaconSubscription = {
|
|
@@ -4479,11 +4627,30 @@ const beaconSubscription = {
|
|
|
4479
4627
|
};
|
|
4480
4628
|
//#endregion
|
|
4481
4629
|
//#region src/internal/herald.ts
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4630
|
+
const HERALD_NAME_EVENTS = "events";
|
|
4631
|
+
const HERALD_NAME_HERALD = "herald";
|
|
4632
|
+
const HERALD_PROPERTY = "$herald";
|
|
4633
|
+
function Events(herald, state) {
|
|
4634
|
+
for (const key of state.keys) Object.defineProperty(this, key, { value: (callback, signal) => herald.subscribe(key, callback, signal) });
|
|
4635
|
+
}
|
|
4636
|
+
Events.prototype[HERALD_PROPERTY] = HERALD_NAME_EVENTS;
|
|
4637
|
+
function Herald(state) {
|
|
4638
|
+
this[HERALD_SYMBOL] = {
|
|
4639
|
+
state,
|
|
4640
|
+
events: new Events(this, state)
|
|
4641
|
+
};
|
|
4642
|
+
}
|
|
4643
|
+
Herald.prototype[HERALD_PROPERTY] = HERALD_NAME_HERALD;
|
|
4644
|
+
Herald.prototype.clear = clearHerald;
|
|
4645
|
+
Herald.prototype.emit = emitForHerald;
|
|
4646
|
+
Herald.prototype.observed = eventIsObserved;
|
|
4647
|
+
Herald.prototype.subscribe = subscribeToHerald;
|
|
4648
|
+
Object.defineProperty(Herald.prototype, "events", {
|
|
4649
|
+
enumerable: true,
|
|
4650
|
+
get: getHeraldEvents
|
|
4651
|
+
});
|
|
4652
|
+
function clearHerald() {
|
|
4653
|
+
this[HERALD_SYMBOL].state.store.clear();
|
|
4487
4654
|
}
|
|
4488
4655
|
function createHeraldState(input) {
|
|
4489
4656
|
const options = isPlainObject(input) ? input : {};
|
|
@@ -4508,11 +4675,18 @@ function createHeraldSubscriptionProperty(input) {
|
|
|
4508
4675
|
value: property.value
|
|
4509
4676
|
};
|
|
4510
4677
|
}
|
|
4511
|
-
function emitForHerald(
|
|
4678
|
+
function emitForHerald(event, ...parameters) {
|
|
4679
|
+
const { state } = this[HERALD_SYMBOL];
|
|
4512
4680
|
const items = state.store.values.from.keyed?.get(event);
|
|
4513
4681
|
if (items == null || items.size === 0) return;
|
|
4514
4682
|
for (const [callback] of items) callback(...parameters);
|
|
4515
4683
|
}
|
|
4684
|
+
function eventIsObserved(event) {
|
|
4685
|
+
return (this[HERALD_SYMBOL].state.store.items.keyed?.get(event)?.size ?? 0) > 0;
|
|
4686
|
+
}
|
|
4687
|
+
function getHeraldEvents() {
|
|
4688
|
+
return this[HERALD_SYMBOL].events;
|
|
4689
|
+
}
|
|
4516
4690
|
/**
|
|
4517
4691
|
* Create a _Herald_ for announcing named events
|
|
4518
4692
|
*
|
|
@@ -4521,21 +4695,7 @@ function emitForHerald(state, event, ...parameters) {
|
|
|
4521
4695
|
* @returns _Herald_ instance
|
|
4522
4696
|
*/
|
|
4523
4697
|
function herald(options) {
|
|
4524
|
-
|
|
4525
|
-
const instance = {
|
|
4526
|
-
clear: () => state.store.clear(),
|
|
4527
|
-
emit: (event, ...parameters) => emitForHerald(state, event, ...parameters),
|
|
4528
|
-
observed: (event) => (state.store.items.keyed?.get(event)?.size ?? 0) > 0,
|
|
4529
|
-
subscribe: (key, callback, signal) => subscribeToHerald(state, key, callback, signal)
|
|
4530
|
-
};
|
|
4531
|
-
Object.defineProperties(instance, {
|
|
4532
|
-
[HERALD_PROPERTY]: { value: HERALD_NAME_HERALD },
|
|
4533
|
-
events: {
|
|
4534
|
-
enumerable: true,
|
|
4535
|
-
value: createEvents(instance, state)
|
|
4536
|
-
}
|
|
4537
|
-
});
|
|
4538
|
-
return Object.freeze(instance);
|
|
4698
|
+
return new Herald(createHeraldState(options));
|
|
4539
4699
|
}
|
|
4540
4700
|
/**
|
|
4541
4701
|
* Is the value a herald?
|
|
@@ -4556,7 +4716,7 @@ function isHeraldEvents(value) {
|
|
|
4556
4716
|
return isHeraldInstance(HERALD_NAME_EVENTS, value);
|
|
4557
4717
|
}
|
|
4558
4718
|
function isHeraldInstance(name, value) {
|
|
4559
|
-
return
|
|
4719
|
+
return typeof value === "object" && value !== null && HERALD_PROPERTY in value && value[HERALD_PROPERTY] === name;
|
|
4560
4720
|
}
|
|
4561
4721
|
/**
|
|
4562
4722
|
* Is the value a herald subscription?
|
|
@@ -4565,9 +4725,10 @@ function isHeraldInstance(name, value) {
|
|
|
4565
4725
|
* @returns `true` if the value is a herald subscription, otherwise `false`
|
|
4566
4726
|
*/
|
|
4567
4727
|
function isHeraldSubscription(value) {
|
|
4568
|
-
return isSubscription(value) && value[HERALD_PROPERTY] === "subscription";
|
|
4728
|
+
return isSubscription(value) && HERALD_PROPERTY in value && value[HERALD_PROPERTY] === "subscription";
|
|
4569
4729
|
}
|
|
4570
|
-
function subscribeToHerald(
|
|
4730
|
+
function subscribeToHerald(key, callback, signal) {
|
|
4731
|
+
const { state } = this[HERALD_SYMBOL];
|
|
4571
4732
|
const [subscription, existing] = state.store.create({
|
|
4572
4733
|
key,
|
|
4573
4734
|
signal,
|
|
@@ -4576,12 +4737,10 @@ function subscribeToHerald(state, key, callback, signal) {
|
|
|
4576
4737
|
if (!existing) state.onCreate?.(key, callback, subscription);
|
|
4577
4738
|
return subscription;
|
|
4578
4739
|
}
|
|
4579
|
-
const HERALD_PROPERTY = "$herald";
|
|
4580
4740
|
const HERALD_MESSAGE_ARRAY = "Herald requires an array of event names.";
|
|
4581
4741
|
const HERALD_MESSAGE_ONCREATE = `Herald requires a valid onCreate callback for subscription creation`;
|
|
4582
4742
|
const HERALD_MESSAGE_PROPERTY = `Herald requires valid property information for subscription identification`;
|
|
4583
|
-
const
|
|
4584
|
-
const HERALD_NAME_HERALD = "herald";
|
|
4743
|
+
const HERALD_SYMBOL = Symbol(HERALD_PROPERTY);
|
|
4585
4744
|
const heraldSubscription = {
|
|
4586
4745
|
key: HERALD_PROPERTY,
|
|
4587
4746
|
value: SUBSCRIPTION_NAME
|
|
@@ -4656,7 +4815,9 @@ const COLOR_MAX = {
|
|
|
4656
4815
|
hex: 255,
|
|
4657
4816
|
percent: 100
|
|
4658
4817
|
};
|
|
4659
|
-
const
|
|
4818
|
+
const COLOR_NAME = "color";
|
|
4819
|
+
const COLOR_PROPERTY = "$color";
|
|
4820
|
+
const COLOR_SYMBOL = Symbol(COLOR_PROPERTY);
|
|
4660
4821
|
const COLOR_TYPE = {
|
|
4661
4822
|
all: void 0,
|
|
4662
4823
|
hex: "hex",
|
|
@@ -4691,6 +4852,10 @@ const COLOR_SRGB = {
|
|
|
4691
4852
|
luminanceRed: .2126,
|
|
4692
4853
|
luminanceThreshold: .625
|
|
4693
4854
|
};
|
|
4855
|
+
const colorSubscription = {
|
|
4856
|
+
key: COLOR_PROPERTY,
|
|
4857
|
+
value: SUBSCRIPTION_NAME
|
|
4858
|
+
};
|
|
4694
4859
|
//#endregion
|
|
4695
4860
|
//#region src/internal/math/misc.ts
|
|
4696
4861
|
/**
|
|
@@ -4720,6 +4885,9 @@ function getAlpha(value, hex) {
|
|
|
4720
4885
|
};
|
|
4721
4886
|
return getAlphaFromValue(Number.parseFloat(value));
|
|
4722
4887
|
}
|
|
4888
|
+
function getColorAlpha() {
|
|
4889
|
+
return this[COLOR_SYMBOL].values.alpha.value;
|
|
4890
|
+
}
|
|
4723
4891
|
function getAlphaHexadecimal(value) {
|
|
4724
4892
|
if (value === COLOR_ALPHA.noneValue) return COLOR_ALPHA.noneHex;
|
|
4725
4893
|
if (value === COLOR_MAX.percent) return COLOR_ALPHA.fullHexLong;
|
|
@@ -4736,6 +4904,9 @@ function getAlphaValue(original) {
|
|
|
4736
4904
|
if (Number.isNaN(original)) return COLOR_MAX.percent;
|
|
4737
4905
|
return clamp(original, COLOR_ALPHA.noneValue, COLOR_MAX.percent);
|
|
4738
4906
|
}
|
|
4907
|
+
function setColorAlpha(value) {
|
|
4908
|
+
if (typeof value === "number" && !Number.isNaN(value)) this[COLOR_SYMBOL].values.alpha = getAlpha(value, false);
|
|
4909
|
+
}
|
|
4739
4910
|
//#endregion
|
|
4740
4911
|
//#region src/color/misc/get.ts
|
|
4741
4912
|
function getClampedValue(value, minimum, maximum, rounding) {
|
|
@@ -4893,13 +5064,14 @@ function isBytey(value) {
|
|
|
4893
5064
|
* @returns `true` if the value is a _Color_, otherwise `false`
|
|
4894
5065
|
*/
|
|
4895
5066
|
function isColor(value) {
|
|
4896
|
-
return
|
|
5067
|
+
return typeof value === "object" && value !== null && "$color" in value && value["$color"] === "color";
|
|
4897
5068
|
}
|
|
4898
|
-
function isColorValue(
|
|
4899
|
-
if (typeof
|
|
4900
|
-
const keys = Object.keys(
|
|
5069
|
+
function isColorValue(value, properties) {
|
|
5070
|
+
if (typeof value !== "object" || value === null) return false;
|
|
5071
|
+
const keys = Object.keys(value);
|
|
4901
5072
|
const { length } = keys;
|
|
4902
5073
|
if (length !== properties.length) return false;
|
|
5074
|
+
const obj = value;
|
|
4903
5075
|
for (let index = 0; index < length; index += 1) {
|
|
4904
5076
|
const key = keys[index];
|
|
4905
5077
|
if (!(properties.includes(key) && validators[key](obj[key]))) return false;
|
|
@@ -5027,7 +5199,7 @@ function convertRgbToHex(rgb, alpha) {
|
|
|
5027
5199
|
return `${hex}${a}`;
|
|
5028
5200
|
}
|
|
5029
5201
|
function convertRgbToHsla(value) {
|
|
5030
|
-
const values =
|
|
5202
|
+
const values = getRgbCalculationValues(isRgbLike(value) ? getRgbValues(value) : { ...COLOR_DEFAULTS.rgb });
|
|
5031
5203
|
const { delta, max, min } = values;
|
|
5032
5204
|
const lightness = (min + max) / 2;
|
|
5033
5205
|
let hue = 0;
|
|
@@ -5045,7 +5217,7 @@ function convertRgbToHsla(value) {
|
|
|
5045
5217
|
};
|
|
5046
5218
|
}
|
|
5047
5219
|
function convertRgbToHwba(value) {
|
|
5048
|
-
const values =
|
|
5220
|
+
const values = getRgbCalculationValues(isRgbLike(value) ? getRgbValues(value) : { ...COLOR_DEFAULTS.rgb });
|
|
5049
5221
|
const { delta, max, min } = values;
|
|
5050
5222
|
let hue = 0;
|
|
5051
5223
|
if (delta !== 0) {
|
|
@@ -5071,22 +5243,7 @@ function getColorFromRgb(state, type) {
|
|
|
5071
5243
|
}
|
|
5072
5244
|
return state[type];
|
|
5073
5245
|
}
|
|
5074
|
-
function
|
|
5075
|
-
const { blue, delta, green, max, red } = values;
|
|
5076
|
-
switch (max) {
|
|
5077
|
-
case blue: return (red - green) / delta + 4;
|
|
5078
|
-
case green: return (blue - red) / delta + 2;
|
|
5079
|
-
default: return (green - blue) / delta + (green < blue ? 6 : 0);
|
|
5080
|
-
}
|
|
5081
|
-
}
|
|
5082
|
-
function getRgbValue(value) {
|
|
5083
|
-
return {
|
|
5084
|
-
blue: getHexValue(value.blue),
|
|
5085
|
-
green: getHexValue(value.green),
|
|
5086
|
-
red: getHexValue(value.red)
|
|
5087
|
-
};
|
|
5088
|
-
}
|
|
5089
|
-
function getRgbValues(rgb) {
|
|
5246
|
+
function getRgbCalculationValues(rgb) {
|
|
5090
5247
|
const blue = rgb.blue / COLOR_MAX.hex;
|
|
5091
5248
|
const green = rgb.green / COLOR_MAX.hex;
|
|
5092
5249
|
const red = rgb.red / COLOR_MAX.hex;
|
|
@@ -5101,6 +5258,27 @@ function getRgbValues(rgb) {
|
|
|
5101
5258
|
red
|
|
5102
5259
|
};
|
|
5103
5260
|
}
|
|
5261
|
+
function getRgbColor$1() {
|
|
5262
|
+
return getStateValue(this, COLOR_TYPE.rgb, false);
|
|
5263
|
+
}
|
|
5264
|
+
function getRgbaColor$1() {
|
|
5265
|
+
return getStateValue(this, COLOR_TYPE.rgb, true);
|
|
5266
|
+
}
|
|
5267
|
+
function getRgbHue(values) {
|
|
5268
|
+
const { blue, delta, green, max, red } = values;
|
|
5269
|
+
switch (max) {
|
|
5270
|
+
case blue: return (red - green) / delta + 4;
|
|
5271
|
+
case green: return (blue - red) / delta + 2;
|
|
5272
|
+
default: return (green - blue) / delta + (green < blue ? 6 : 0);
|
|
5273
|
+
}
|
|
5274
|
+
}
|
|
5275
|
+
function getRgbValues(value) {
|
|
5276
|
+
return {
|
|
5277
|
+
blue: getHexValue(value.blue),
|
|
5278
|
+
green: getHexValue(value.green),
|
|
5279
|
+
red: getHexValue(value.red)
|
|
5280
|
+
};
|
|
5281
|
+
}
|
|
5104
5282
|
/**
|
|
5105
5283
|
* Convert an _RGB(A)_ color to a hex color _(with optional alpha channel, i.e., opacity)_
|
|
5106
5284
|
*
|
|
@@ -5111,7 +5289,7 @@ function getRgbValues(rgb) {
|
|
|
5111
5289
|
* @returns Hex color string
|
|
5112
5290
|
*/
|
|
5113
5291
|
function rgbToHex(rgb, alpha) {
|
|
5114
|
-
return convertRgbToHex(isRgbLike(rgb) ?
|
|
5292
|
+
return convertRgbToHex(isRgbLike(rgb) ? getRgbValues(rgb) : { ...COLOR_DEFAULTS.rgb }, alpha ?? false);
|
|
5115
5293
|
}
|
|
5116
5294
|
/**
|
|
5117
5295
|
* Convert an _RGB(A)_ color to an _HSL_ color
|
|
@@ -5175,6 +5353,20 @@ function rgbToHwb(rgb) {
|
|
|
5175
5353
|
function rgbToHwba(rgb) {
|
|
5176
5354
|
return convertRgbToHwba(rgb);
|
|
5177
5355
|
}
|
|
5356
|
+
function setRgbValue(value) {
|
|
5357
|
+
setRgbColorValueInState(this, value, false);
|
|
5358
|
+
}
|
|
5359
|
+
function setRgbColorValueInState(instance, value, alpha) {
|
|
5360
|
+
if (!isRgbLike(value)) return;
|
|
5361
|
+
setStateValue(instance, COLOR_TYPE.rgb, {
|
|
5362
|
+
red: getHexValue(value.red),
|
|
5363
|
+
green: getHexValue(value.green),
|
|
5364
|
+
blue: getHexValue(value.blue)
|
|
5365
|
+
}, alpha ? value.alpha : void 0);
|
|
5366
|
+
}
|
|
5367
|
+
function setRgbaValue(value) {
|
|
5368
|
+
setRgbColorValueInState(this, value, true);
|
|
5369
|
+
}
|
|
5178
5370
|
//#endregion
|
|
5179
5371
|
//#region src/color/space/hex.ts
|
|
5180
5372
|
function convertHexToRgba(value) {
|
|
@@ -5202,6 +5394,12 @@ function getColorFromHex(state, type) {
|
|
|
5202
5394
|
}
|
|
5203
5395
|
return state[type];
|
|
5204
5396
|
}
|
|
5397
|
+
function getHexColor$1() {
|
|
5398
|
+
return getStateValue(this, COLOR_TYPE.hex, false);
|
|
5399
|
+
}
|
|
5400
|
+
function getHexaColor$1() {
|
|
5401
|
+
return getStateValue(this, COLOR_TYPE.hex, true);
|
|
5402
|
+
}
|
|
5205
5403
|
/**
|
|
5206
5404
|
* Get the normalized hex color from a value
|
|
5207
5405
|
*
|
|
@@ -5299,10 +5497,22 @@ function hexToRgb(value) {
|
|
|
5299
5497
|
function hexToRgba(value) {
|
|
5300
5498
|
return convertHexToRgba(value);
|
|
5301
5499
|
}
|
|
5500
|
+
function setHexValue(value) {
|
|
5501
|
+
setHexValueInState(this, value, false);
|
|
5502
|
+
}
|
|
5503
|
+
function setHexValueInState(instance, value, alpha) {
|
|
5504
|
+
const { values } = instance[COLOR_SYMBOL];
|
|
5505
|
+
if (!isHexColor(value) || !alpha && value === values.hex) return;
|
|
5506
|
+
const normalized = getNormalizedHex(value, true);
|
|
5507
|
+
setStateValue(instance, COLOR_TYPE.hex, normalized.slice(0, COLOR_LENGTHS.hexLong), alpha ? normalized.slice(COLOR_LENGTHS.hexLong) : void 0);
|
|
5508
|
+
}
|
|
5509
|
+
function setHexaValue(value) {
|
|
5510
|
+
setHexValueInState(this, value, true);
|
|
5511
|
+
}
|
|
5302
5512
|
//#endregion
|
|
5303
5513
|
//#region src/color/space/hsl.ts
|
|
5304
5514
|
function convertHslToHwba(input) {
|
|
5305
|
-
let { hue, lightness, saturation } = isHslLike(input) ?
|
|
5515
|
+
let { hue, lightness, saturation } = isHslLike(input) ? getHslValues(input) : { ...COLOR_DEFAULTS.hsl };
|
|
5306
5516
|
lightness /= COLOR_MAX.percent;
|
|
5307
5517
|
saturation /= COLOR_MAX.percent;
|
|
5308
5518
|
const value = lightness + saturation * Math.min(lightness, 1 - lightness);
|
|
@@ -5317,7 +5527,7 @@ function convertHslToHwba(input) {
|
|
|
5317
5527
|
};
|
|
5318
5528
|
}
|
|
5319
5529
|
function convertHslToRgba(input) {
|
|
5320
|
-
const hsl = isHslLike(input) ?
|
|
5530
|
+
const hsl = isHslLike(input) ? getHslValues(input) : { ...COLOR_DEFAULTS.hsl };
|
|
5321
5531
|
const hue = hsl.hue % COLOR_MAX.degree;
|
|
5322
5532
|
const saturation = hsl.saturation / COLOR_MAX.percent;
|
|
5323
5533
|
const lightness = hsl.lightness / COLOR_MAX.percent;
|
|
@@ -5344,7 +5554,13 @@ function getHexyValue(hue, lightness, saturation, value) {
|
|
|
5344
5554
|
const part = (value + hue / 30) % 12;
|
|
5345
5555
|
return (lightness - saturation * Math.min(lightness, 1 - lightness) * Math.max(-1, Math.min(part - 3, 9 - part, 1))) * COLOR_MAX.hex;
|
|
5346
5556
|
}
|
|
5347
|
-
function getHslValue(
|
|
5557
|
+
function getHslValue() {
|
|
5558
|
+
return getStateValue(this, COLOR_TYPE.hsl, false);
|
|
5559
|
+
}
|
|
5560
|
+
function getHslaValue() {
|
|
5561
|
+
return getStateValue(this, COLOR_TYPE.hsl, true);
|
|
5562
|
+
}
|
|
5563
|
+
function getHslValues(value) {
|
|
5348
5564
|
return {
|
|
5349
5565
|
hue: getDegrees(value.hue),
|
|
5350
5566
|
saturation: getPercentage(value.saturation),
|
|
@@ -5421,10 +5637,24 @@ function hslToRgb(hsl) {
|
|
|
5421
5637
|
function hslToRgba(hsl) {
|
|
5422
5638
|
return convertHslToRgba(hsl);
|
|
5423
5639
|
}
|
|
5640
|
+
function setHslValue(value) {
|
|
5641
|
+
setHSLValueInState(this, value, false);
|
|
5642
|
+
}
|
|
5643
|
+
function setHSLValueInState(instance, value, alpha) {
|
|
5644
|
+
if (!isHslLike(value)) return;
|
|
5645
|
+
setStateValue(instance, COLOR_TYPE.hsl, {
|
|
5646
|
+
hue: getDegrees(value.hue),
|
|
5647
|
+
saturation: getPercentage(value.saturation),
|
|
5648
|
+
lightness: getPercentage(value.lightness)
|
|
5649
|
+
}, alpha ? value.alpha : void 0);
|
|
5650
|
+
}
|
|
5651
|
+
function setHslaValue(value) {
|
|
5652
|
+
setHSLValueInState(this, value, true);
|
|
5653
|
+
}
|
|
5424
5654
|
//#endregion
|
|
5425
5655
|
//#region src/color/space/hwb.ts
|
|
5426
5656
|
function convertHwbToHsl(input) {
|
|
5427
|
-
let { blackness, hue, whiteness } = isHwbLike(input) ?
|
|
5657
|
+
let { blackness, hue, whiteness } = isHwbLike(input) ? getHwbValues(input) : COLOR_DEFAULTS.hwb;
|
|
5428
5658
|
blackness /= COLOR_MAX.percent;
|
|
5429
5659
|
whiteness /= COLOR_MAX.percent;
|
|
5430
5660
|
if (blackness + whiteness > 1) {
|
|
@@ -5457,7 +5687,13 @@ function getHwbSaturation(blackness, whiteness, lightness) {
|
|
|
5457
5687
|
if (hue <= 0) return 0;
|
|
5458
5688
|
return hue / Math.min(2 * lightness, 2 - 2 * lightness);
|
|
5459
5689
|
}
|
|
5460
|
-
function getHwbValue(
|
|
5690
|
+
function getHwbValue() {
|
|
5691
|
+
return getStateValue(this, COLOR_TYPE.hwb, false);
|
|
5692
|
+
}
|
|
5693
|
+
function getHwbaValue() {
|
|
5694
|
+
return getStateValue(this, COLOR_TYPE.hwb, true);
|
|
5695
|
+
}
|
|
5696
|
+
function getHwbValues(value) {
|
|
5461
5697
|
return {
|
|
5462
5698
|
hue: getDegrees(value.hue),
|
|
5463
5699
|
whiteness: getPercentage(value.whiteness),
|
|
@@ -5525,6 +5761,20 @@ function hwbToRgb(hwb) {
|
|
|
5525
5761
|
function hwbToRgba(hwb) {
|
|
5526
5762
|
return hslToRgba(hwbToHsla(hwb));
|
|
5527
5763
|
}
|
|
5764
|
+
function setHwbValue(value) {
|
|
5765
|
+
setHwbColorValueInState(this, value, false);
|
|
5766
|
+
}
|
|
5767
|
+
function setHwbColorValueInState(instance, value, alpha) {
|
|
5768
|
+
if (!isHwbLike(value)) return;
|
|
5769
|
+
setStateValue(instance, COLOR_TYPE.hwb, {
|
|
5770
|
+
hue: getDegrees(value.hue),
|
|
5771
|
+
whiteness: getPercentage(value.whiteness),
|
|
5772
|
+
blackness: getPercentage(value.blackness)
|
|
5773
|
+
}, alpha ? value.alpha : void 0);
|
|
5774
|
+
}
|
|
5775
|
+
function setHwbaValue(value) {
|
|
5776
|
+
setHwbColorValueInState(this, value, true);
|
|
5777
|
+
}
|
|
5528
5778
|
//#endregion
|
|
5529
5779
|
//#region src/color/misc/state.ts
|
|
5530
5780
|
function getColorFromState(state, type) {
|
|
@@ -5548,13 +5798,13 @@ function getColorState(value) {
|
|
|
5548
5798
|
origin: void 0
|
|
5549
5799
|
};
|
|
5550
5800
|
if (COLOR_KEYS.hsl.every((key) => key in value)) {
|
|
5551
|
-
state.hsl =
|
|
5801
|
+
state.hsl = getHslValues(value);
|
|
5552
5802
|
state.origin = COLOR_TYPE.hsl;
|
|
5553
5803
|
} else if (COLOR_KEYS.hwb.every((key) => key in value)) {
|
|
5554
|
-
state.hwb =
|
|
5804
|
+
state.hwb = getHwbValues(value);
|
|
5555
5805
|
state.origin = COLOR_TYPE.hwb;
|
|
5556
5806
|
} else if (COLOR_KEYS.rgb.every((key) => key in value)) {
|
|
5557
|
-
state.rgb =
|
|
5807
|
+
state.rgb = getRgbValues(value);
|
|
5558
5808
|
state.origin = COLOR_TYPE.rgb;
|
|
5559
5809
|
}
|
|
5560
5810
|
if (state.origin != null) return state;
|
|
@@ -5579,45 +5829,26 @@ function getDefaultColorState() {
|
|
|
5579
5829
|
origin: COLOR_TYPE.hex
|
|
5580
5830
|
};
|
|
5581
5831
|
}
|
|
5582
|
-
function
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
for (const type of COLOR_TYPE.all) if (changes.observed(type)) changes.emit(type, color[type]);
|
|
5591
|
-
changes.emit(COLOR_TYPE.wildcard, color);
|
|
5592
|
-
}
|
|
5593
|
-
function setHexColor(color, state, changes, value, alpha) {
|
|
5594
|
-
if (!isHexColor(value) || !alpha && value === state.hex) return;
|
|
5595
|
-
const normalized = getNormalizedHex(value, true);
|
|
5596
|
-
setColorValue(color, state, changes, COLOR_TYPE.hex, normalized.slice(0, COLOR_LENGTHS.hexLong), alpha ? normalized.slice(COLOR_LENGTHS.hexLong) : void 0);
|
|
5597
|
-
}
|
|
5598
|
-
function setHSLColor(color, state, changes, value, alpha) {
|
|
5599
|
-
if (!isHslLike(value)) return;
|
|
5600
|
-
setColorValue(color, state, changes, COLOR_TYPE.hsl, {
|
|
5601
|
-
hue: getDegrees(value.hue),
|
|
5602
|
-
saturation: getPercentage(value.saturation),
|
|
5603
|
-
lightness: getPercentage(value.lightness)
|
|
5604
|
-
}, alpha ? value.alpha : void 0);
|
|
5832
|
+
function getStateValue(instance, type, alpha) {
|
|
5833
|
+
const { values } = instance[COLOR_SYMBOL];
|
|
5834
|
+
const value = getColorFromState(values, type);
|
|
5835
|
+
if (typeof value === "string") return alpha ? `${value}${values.alpha.hex}` : value;
|
|
5836
|
+
return alpha ? {
|
|
5837
|
+
...value,
|
|
5838
|
+
alpha: values.alpha.value
|
|
5839
|
+
} : { ...value };
|
|
5605
5840
|
}
|
|
5606
|
-
function
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
if (
|
|
5616
|
-
|
|
5617
|
-
red: getHexValue(value.red),
|
|
5618
|
-
green: getHexValue(value.green),
|
|
5619
|
-
blue: getHexValue(value.blue)
|
|
5620
|
-
}, alpha ? value.alpha : void 0);
|
|
5841
|
+
function setStateValue(instance, type, value, alpha) {
|
|
5842
|
+
const { changes, values } = instance[COLOR_SYMBOL];
|
|
5843
|
+
values.hex = void 0;
|
|
5844
|
+
values.hsl = void 0;
|
|
5845
|
+
values.hwb = void 0;
|
|
5846
|
+
values.rgb = void 0;
|
|
5847
|
+
values.origin = type;
|
|
5848
|
+
values[type] = value;
|
|
5849
|
+
if (alpha != null) values.alpha = getAlpha(alpha, type === COLOR_TYPE.hex);
|
|
5850
|
+
for (const type of COLOR_TYPE.all) if (changes.observed(type)) changes.emit(type, instance[type]);
|
|
5851
|
+
changes.emit(COLOR_TYPE.wildcard, instance);
|
|
5621
5852
|
}
|
|
5622
5853
|
const getters = {
|
|
5623
5854
|
hex: getColorFromHex,
|
|
@@ -5627,83 +5858,110 @@ const getters = {
|
|
|
5627
5858
|
};
|
|
5628
5859
|
//#endregion
|
|
5629
5860
|
//#region src/color/misc/format.ts
|
|
5630
|
-
function formatHexColor(
|
|
5631
|
-
return `#${alpha === true ?
|
|
5861
|
+
function formatHexColor(alpha) {
|
|
5862
|
+
return `#${alpha === true ? this.hexa : this.hex}`;
|
|
5632
5863
|
}
|
|
5633
|
-
function formatHslColor(
|
|
5634
|
-
const {
|
|
5635
|
-
|
|
5864
|
+
function formatHslColor(alpha) {
|
|
5865
|
+
const { values } = this[COLOR_SYMBOL];
|
|
5866
|
+
const { hue, lightness, saturation } = getColorFromState(values, COLOR_TYPE.hsl);
|
|
5867
|
+
return `hsl(${hue}deg ${saturation}% ${lightness}%${getSuffix(values, alpha)})`;
|
|
5636
5868
|
}
|
|
5637
|
-
function formatHwbColor(
|
|
5638
|
-
const {
|
|
5639
|
-
|
|
5869
|
+
function formatHwbColor(alpha) {
|
|
5870
|
+
const { values } = this[COLOR_SYMBOL];
|
|
5871
|
+
const { blackness, hue, whiteness } = getColorFromState(values, COLOR_TYPE.hwb);
|
|
5872
|
+
return `hwb(${hue}deg ${whiteness}% ${blackness}%${getSuffix(values, alpha)})`;
|
|
5640
5873
|
}
|
|
5641
|
-
function formatRgbColor(
|
|
5642
|
-
const {
|
|
5643
|
-
|
|
5874
|
+
function formatRgbColor(alpha) {
|
|
5875
|
+
const { values } = this[COLOR_SYMBOL];
|
|
5876
|
+
const { blue, green, red } = getColorFromState(values, COLOR_TYPE.rgb);
|
|
5877
|
+
return `rgb(${red} ${green} ${blue}${getSuffix(values, alpha)})`;
|
|
5644
5878
|
}
|
|
5645
5879
|
function getSuffix(state, alpha) {
|
|
5646
5880
|
return alpha === true ? ` / ${state.alpha.value}%` : "";
|
|
5647
5881
|
}
|
|
5648
5882
|
//#endregion
|
|
5649
5883
|
//#region src/color/instance.ts
|
|
5650
|
-
function
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
subscribe: (callback, signal) => changes.subscribe(COLOR_TYPE.wildcard, callback, signal),
|
|
5659
|
-
toHexString: (alpha) => formatHexColor(instance, alpha),
|
|
5660
|
-
toHslString: (alpha) => formatHslColor(state, alpha),
|
|
5661
|
-
toHwbString: (alpha) => formatHwbColor(state, alpha),
|
|
5662
|
-
toRgbString: (alpha) => formatRgbColor(state, alpha),
|
|
5663
|
-
toString: () => instance.toHexString(),
|
|
5664
|
-
unsubscribe: () => changes.clear()
|
|
5884
|
+
function Color(value) {
|
|
5885
|
+
this[COLOR_SYMBOL] = {
|
|
5886
|
+
changes: herald({
|
|
5887
|
+
names: [COLOR_TYPE.wildcard, ...COLOR_TYPE.all],
|
|
5888
|
+
property: colorSubscription,
|
|
5889
|
+
onCreate: (event, callback) => onCreateSubscription(this, event, callback)
|
|
5890
|
+
}),
|
|
5891
|
+
values: getColorState(value)
|
|
5665
5892
|
};
|
|
5666
|
-
Object.defineProperties(instance, {
|
|
5667
|
-
[COLOR_PROPERTY.name]: { value: true },
|
|
5668
|
-
alpha: {
|
|
5669
|
-
enumerable: true,
|
|
5670
|
-
get: () => state.alpha.value,
|
|
5671
|
-
set: (value) => setAlphaValue(state, value)
|
|
5672
|
-
},
|
|
5673
|
-
changes: {
|
|
5674
|
-
enumerable: true,
|
|
5675
|
-
value: changes.events
|
|
5676
|
-
},
|
|
5677
|
-
hex: createColorProperty(COLOR_TYPE.hex, instance, state, changes, false),
|
|
5678
|
-
hexa: createColorProperty(COLOR_TYPE.hex, instance, state, changes, true),
|
|
5679
|
-
hsl: createColorProperty(COLOR_TYPE.hsl, instance, state, changes, false),
|
|
5680
|
-
hsla: createColorProperty(COLOR_TYPE.hsl, instance, state, changes, true),
|
|
5681
|
-
hwb: createColorProperty(COLOR_TYPE.hwb, instance, state, changes, false),
|
|
5682
|
-
hwba: createColorProperty(COLOR_TYPE.hwb, instance, state, changes, true),
|
|
5683
|
-
origin: {
|
|
5684
|
-
enumerable: true,
|
|
5685
|
-
get: () => state.origin
|
|
5686
|
-
},
|
|
5687
|
-
rgb: createColorProperty(COLOR_TYPE.rgb, instance, state, changes, false),
|
|
5688
|
-
rgba: createColorProperty(COLOR_TYPE.rgb, instance, state, changes, true)
|
|
5689
|
-
});
|
|
5690
|
-
return Object.freeze(instance);
|
|
5691
5893
|
}
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5894
|
+
Color.prototype[COLOR_PROPERTY] = COLOR_NAME;
|
|
5895
|
+
Color.prototype.subscribe = subscribeToColor;
|
|
5896
|
+
Color.prototype.toHexString = formatHexColor;
|
|
5897
|
+
Color.prototype.toHslString = formatHslColor;
|
|
5898
|
+
Color.prototype.toHwbString = formatHwbColor;
|
|
5899
|
+
Color.prototype.toRgbString = formatRgbColor;
|
|
5900
|
+
Color.prototype.toString = formatHexColor;
|
|
5901
|
+
Color.prototype.unsubscribe = unsubscribeFromColor;
|
|
5902
|
+
Object.defineProperties(Color.prototype, {
|
|
5903
|
+
alpha: {
|
|
5695
5904
|
enumerable: true,
|
|
5696
|
-
get:
|
|
5697
|
-
set:
|
|
5698
|
-
}
|
|
5905
|
+
get: getColorAlpha,
|
|
5906
|
+
set: setColorAlpha
|
|
5907
|
+
},
|
|
5908
|
+
changes: {
|
|
5909
|
+
enumerable: true,
|
|
5910
|
+
get: getColorChanges
|
|
5911
|
+
},
|
|
5912
|
+
hex: {
|
|
5913
|
+
enumerable: true,
|
|
5914
|
+
get: getHexColor$1,
|
|
5915
|
+
set: setHexValue
|
|
5916
|
+
},
|
|
5917
|
+
hexa: {
|
|
5918
|
+
enumerable: true,
|
|
5919
|
+
get: getHexaColor$1,
|
|
5920
|
+
set: setHexaValue
|
|
5921
|
+
},
|
|
5922
|
+
hsl: {
|
|
5923
|
+
enumerable: true,
|
|
5924
|
+
get: getHslValue,
|
|
5925
|
+
set: setHslValue
|
|
5926
|
+
},
|
|
5927
|
+
hsla: {
|
|
5928
|
+
enumerable: true,
|
|
5929
|
+
get: getHslaValue,
|
|
5930
|
+
set: setHslaValue
|
|
5931
|
+
},
|
|
5932
|
+
hwb: {
|
|
5933
|
+
enumerable: true,
|
|
5934
|
+
get: getHwbValue,
|
|
5935
|
+
set: setHwbValue
|
|
5936
|
+
},
|
|
5937
|
+
hwba: {
|
|
5938
|
+
enumerable: true,
|
|
5939
|
+
get: getHwbaValue,
|
|
5940
|
+
set: setHwbaValue
|
|
5941
|
+
},
|
|
5942
|
+
origin: {
|
|
5943
|
+
enumerable: true,
|
|
5944
|
+
get: getOrigin
|
|
5945
|
+
},
|
|
5946
|
+
rgb: {
|
|
5947
|
+
enumerable: true,
|
|
5948
|
+
get: getRgbColor$1,
|
|
5949
|
+
set: setRgbValue
|
|
5950
|
+
},
|
|
5951
|
+
rgba: {
|
|
5952
|
+
enumerable: true,
|
|
5953
|
+
get: getRgbaColor$1,
|
|
5954
|
+
set: setRgbaValue
|
|
5955
|
+
}
|
|
5956
|
+
});
|
|
5957
|
+
function color(value) {
|
|
5958
|
+
return new Color(value);
|
|
5699
5959
|
}
|
|
5700
|
-
function
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
alpha: state.alpha.value
|
|
5706
|
-
} : { ...value };
|
|
5960
|
+
function getColorChanges() {
|
|
5961
|
+
return this[COLOR_SYMBOL].changes.events;
|
|
5962
|
+
}
|
|
5963
|
+
function getOrigin() {
|
|
5964
|
+
return this[COLOR_SYMBOL].values.origin;
|
|
5707
5965
|
}
|
|
5708
5966
|
function onCreateSubscription(instance, event, callback) {
|
|
5709
5967
|
let value;
|
|
@@ -5711,19 +5969,13 @@ function onCreateSubscription(instance, event, callback) {
|
|
|
5711
5969
|
else value = instance[event];
|
|
5712
5970
|
callback(value);
|
|
5713
5971
|
}
|
|
5714
|
-
function
|
|
5715
|
-
|
|
5972
|
+
function subscribeToColor(callback, signal) {
|
|
5973
|
+
const { changes } = this[COLOR_SYMBOL];
|
|
5974
|
+
return changes.subscribe(COLOR_TYPE.wildcard, callback, signal);
|
|
5975
|
+
}
|
|
5976
|
+
function unsubscribeFromColor() {
|
|
5977
|
+
this[COLOR_SYMBOL].changes.clear();
|
|
5716
5978
|
}
|
|
5717
|
-
const colorSubscription = {
|
|
5718
|
-
key: COLOR_PROPERTY.name,
|
|
5719
|
-
value: SUBSCRIPTION_NAME
|
|
5720
|
-
};
|
|
5721
|
-
const setters = {
|
|
5722
|
-
hex: setHexColor,
|
|
5723
|
-
hsl: setHSLColor,
|
|
5724
|
-
hwb: setHWBColor,
|
|
5725
|
-
rgb: setRGBColor
|
|
5726
|
-
};
|
|
5727
5979
|
//#endregion
|
|
5728
5980
|
//#region src/color/index.ts
|
|
5729
5981
|
/**
|
|
@@ -5859,82 +6111,90 @@ function isObject(value) {
|
|
|
5859
6111
|
const EXPRESSION_WHITESPACE = /^\s*$/;
|
|
5860
6112
|
//#endregion
|
|
5861
6113
|
//#region src/logger.ts
|
|
6114
|
+
const LOGGER_NAME = "Logger";
|
|
6115
|
+
const LOGGER_NAME_TIMED = "TimedLogger";
|
|
6116
|
+
const LOGGER_PROPERTY = "$logger";
|
|
6117
|
+
function Lumberjack() {}
|
|
6118
|
+
Lumberjack.prototype[LOGGER_PROPERTY] = LOGGER_NAME;
|
|
6119
|
+
Lumberjack.prototype.time = getTimeLogger;
|
|
6120
|
+
Object.defineProperties(Lumberjack.prototype, {
|
|
6121
|
+
debug: { get: getLoggerCallback.bind("debug") },
|
|
6122
|
+
dir: { get: getLoggerCallback.bind("dir") },
|
|
6123
|
+
error: { get: getLoggerCallback.bind("error") },
|
|
6124
|
+
enabled: {
|
|
6125
|
+
enumerable: true,
|
|
6126
|
+
get: getLoggerEnabled,
|
|
6127
|
+
set: setLoggerEnabled
|
|
6128
|
+
},
|
|
6129
|
+
info: { get: getLoggerCallback.bind("info") },
|
|
6130
|
+
log: { get: getLoggerCallback.bind("log") },
|
|
6131
|
+
table: { get: getLoggerCallback.bind("table") },
|
|
6132
|
+
trace: { get: getLoggerCallback.bind("trace") },
|
|
6133
|
+
warn: { get: getLoggerCallback.bind("warn") }
|
|
6134
|
+
});
|
|
6135
|
+
function TimeLogger(label) {
|
|
6136
|
+
this[LOGGER_SYMBOL] = {
|
|
6137
|
+
label,
|
|
6138
|
+
started: enabled,
|
|
6139
|
+
stopped: false
|
|
6140
|
+
};
|
|
6141
|
+
this[LOGGER_SYMBOL].isActive = () => {
|
|
6142
|
+
return enabled && this[LOGGER_SYMBOL].started && !this[LOGGER_SYMBOL].stopped;
|
|
6143
|
+
};
|
|
6144
|
+
if (this[LOGGER_SYMBOL].started) console.time(label);
|
|
6145
|
+
}
|
|
6146
|
+
TimeLogger.prototype[LOGGER_PROPERTY] = LOGGER_NAME_TIMED;
|
|
6147
|
+
Object.defineProperties(TimeLogger.prototype, {
|
|
6148
|
+
active: {
|
|
6149
|
+
enumerable: true,
|
|
6150
|
+
get: getTimeLoggerActive
|
|
6151
|
+
},
|
|
6152
|
+
log: { get: getTimerLoggerLog },
|
|
6153
|
+
stop: { get: getTimeLoggerStop }
|
|
6154
|
+
});
|
|
6155
|
+
function getLoggerCallback() {
|
|
6156
|
+
return enabled ? console[this].bind(console) : noop;
|
|
6157
|
+
}
|
|
6158
|
+
function getLoggerEnabled() {
|
|
6159
|
+
return enabled;
|
|
6160
|
+
}
|
|
6161
|
+
function getTimeLogger(label) {
|
|
6162
|
+
return new TimeLogger(getString(label));
|
|
6163
|
+
}
|
|
6164
|
+
function getTimeLoggerActive() {
|
|
6165
|
+
return this[LOGGER_SYMBOL].isActive();
|
|
6166
|
+
}
|
|
6167
|
+
function getTimerLoggerLog() {
|
|
6168
|
+
const state = this[LOGGER_SYMBOL];
|
|
6169
|
+
return state.isActive() ? console.timeLog.bind(console, state.label) : noop;
|
|
6170
|
+
}
|
|
6171
|
+
function getTimeLoggerStop() {
|
|
6172
|
+
const state = this[LOGGER_SYMBOL];
|
|
6173
|
+
if (state.isActive()) {
|
|
6174
|
+
state.stopped = true;
|
|
6175
|
+
return console.timeEnd.bind(console, state.label);
|
|
6176
|
+
}
|
|
6177
|
+
return noop;
|
|
6178
|
+
}
|
|
5862
6179
|
function isLogger(value) {
|
|
5863
6180
|
return isLoggerInstance(LOGGER_NAME, value);
|
|
5864
6181
|
}
|
|
5865
6182
|
function isLoggerInstance(name, value) {
|
|
5866
|
-
return typeof value === "object" && value !== null && value[LOGGER_PROPERTY] === name;
|
|
6183
|
+
return typeof value === "object" && value !== null && LOGGER_PROPERTY in value && value[LOGGER_PROPERTY] === name;
|
|
5867
6184
|
}
|
|
5868
|
-
function
|
|
6185
|
+
function isTimeLogger(value) {
|
|
5869
6186
|
return isLoggerInstance(LOGGER_NAME_TIMED, value);
|
|
5870
6187
|
}
|
|
5871
|
-
function
|
|
5872
|
-
|
|
5873
|
-
const fn = stopper;
|
|
5874
|
-
state.stopped = true;
|
|
5875
|
-
logger = void 0;
|
|
5876
|
-
stopper = void 0;
|
|
5877
|
-
return fn;
|
|
5878
|
-
}
|
|
5879
|
-
let logger = console.timeLog.bind(console, label);
|
|
5880
|
-
let stopper = console.timeEnd.bind(console, label);
|
|
5881
|
-
const state = {
|
|
5882
|
-
label,
|
|
5883
|
-
started: enabled,
|
|
5884
|
-
stopped: false
|
|
5885
|
-
};
|
|
5886
|
-
const instance = {};
|
|
5887
|
-
Object.defineProperties(instance, {
|
|
5888
|
-
[LOGGER_PROPERTY]: { value: LOGGER_NAME_TIMED },
|
|
5889
|
-
active: {
|
|
5890
|
-
enumerable: true,
|
|
5891
|
-
get: () => state.started && !state.stopped && enabled
|
|
5892
|
-
},
|
|
5893
|
-
log: { get: () => instance.active ? logger : noop },
|
|
5894
|
-
stop: { get: () => instance.active ? stop() : noop }
|
|
5895
|
-
});
|
|
5896
|
-
if (state.started) console.time(label);
|
|
5897
|
-
return Object.freeze(instance);
|
|
6188
|
+
function setLoggerEnabled(value) {
|
|
6189
|
+
enabled = typeof value === "boolean" ? value : enabled;
|
|
5898
6190
|
}
|
|
5899
|
-
const
|
|
5900
|
-
const LOGGER_NAME_TIMED = "TimedLogger";
|
|
5901
|
-
const LOGGER_PROPERTY = "$logger";
|
|
5902
|
-
const methods = [
|
|
5903
|
-
"debug",
|
|
5904
|
-
"dir",
|
|
5905
|
-
"error",
|
|
5906
|
-
"info",
|
|
5907
|
-
"log",
|
|
5908
|
-
"table",
|
|
5909
|
-
"trace",
|
|
5910
|
-
"warn"
|
|
5911
|
-
];
|
|
6191
|
+
const LOGGER_SYMBOL = Symbol(LOGGER_PROPERTY);
|
|
5912
6192
|
/**
|
|
5913
6193
|
* A logger that can be used to log messages to the console
|
|
5914
6194
|
*
|
|
5915
6195
|
* _(Logging can be enabled or disabled by setting the `enabled` property)_
|
|
5916
6196
|
*/
|
|
5917
|
-
const Logger = (
|
|
5918
|
-
const instance = {};
|
|
5919
|
-
Object.defineProperties(instance, {
|
|
5920
|
-
[LOGGER_PROPERTY]: { value: LOGGER_NAME },
|
|
5921
|
-
enabled: {
|
|
5922
|
-
enumerable: true,
|
|
5923
|
-
get: () => enabled,
|
|
5924
|
-
set: (value) => {
|
|
5925
|
-
enabled = typeof value === "boolean" ? value : enabled;
|
|
5926
|
-
}
|
|
5927
|
-
},
|
|
5928
|
-
time: { value: (label) => timedLogger(getString(label)) }
|
|
5929
|
-
});
|
|
5930
|
-
for (const method of methods) Object.defineProperty(instance, method, {
|
|
5931
|
-
enumerable: true,
|
|
5932
|
-
get() {
|
|
5933
|
-
return enabled ? console[method].bind(console) : noop;
|
|
5934
|
-
}
|
|
5935
|
-
});
|
|
5936
|
-
return Object.freeze(instance);
|
|
5937
|
-
})();
|
|
6197
|
+
const Logger = new Lumberjack();
|
|
5938
6198
|
let enabled = true;
|
|
5939
6199
|
//#endregion
|
|
5940
6200
|
//#region src/math.ts
|
|
@@ -6080,6 +6340,9 @@ const QUERY_TYPES = /* @__PURE__ */ new Set([
|
|
|
6080
6340
|
]);
|
|
6081
6341
|
//#endregion
|
|
6082
6342
|
//#region src/queue.ts
|
|
6343
|
+
const QUEUE_NAME_KEYED = "keyedQueue";
|
|
6344
|
+
const QUEUE_NAME_QUEUE = "queue";
|
|
6345
|
+
const QUEUE_PROPERTY = "$queue";
|
|
6083
6346
|
/**
|
|
6084
6347
|
* An error thrown by the Queue when an operation fails
|
|
6085
6348
|
*/
|
|
@@ -6089,10 +6352,122 @@ var QueueError = class extends Error {
|
|
|
6089
6352
|
this.name = QUEUE_ERROR_NAME;
|
|
6090
6353
|
}
|
|
6091
6354
|
};
|
|
6092
|
-
function
|
|
6093
|
-
|
|
6355
|
+
function KeyedQueue(callback, options) {
|
|
6356
|
+
this[QUEUE_SYMBOL] = {
|
|
6357
|
+
callback,
|
|
6358
|
+
options: createQueueOptions(options),
|
|
6359
|
+
queues: /* @__PURE__ */ new Map()
|
|
6360
|
+
};
|
|
6361
|
+
}
|
|
6362
|
+
KeyedQueue.prototype[QUEUE_PROPERTY] = QUEUE_NAME_KEYED;
|
|
6363
|
+
KeyedQueue.prototype.add = addKeyedQueue;
|
|
6364
|
+
KeyedQueue.prototype.clear = clearQueues;
|
|
6365
|
+
KeyedQueue.prototype.get = getQueue;
|
|
6366
|
+
KeyedQueue.prototype.pause = pauseQueues;
|
|
6367
|
+
KeyedQueue.prototype.remove = removeQueue;
|
|
6368
|
+
KeyedQueue.prototype.resume = resumeQueues;
|
|
6369
|
+
Object.defineProperties(KeyedQueue.prototype, {
|
|
6370
|
+
active: {
|
|
6371
|
+
enumerable: true,
|
|
6372
|
+
get: getActiveQueues
|
|
6373
|
+
},
|
|
6374
|
+
autostart: {
|
|
6375
|
+
enumerable: true,
|
|
6376
|
+
get: getQueueAutostart
|
|
6377
|
+
},
|
|
6378
|
+
concurrency: {
|
|
6379
|
+
enumerable: true,
|
|
6380
|
+
get: getQueueConcurrency
|
|
6381
|
+
},
|
|
6382
|
+
empty: {
|
|
6383
|
+
enumerable: true,
|
|
6384
|
+
get: getEmptyQueues
|
|
6385
|
+
},
|
|
6386
|
+
full: {
|
|
6387
|
+
enumerable: true,
|
|
6388
|
+
get: getFullQueues
|
|
6389
|
+
},
|
|
6390
|
+
items: {
|
|
6391
|
+
enumerable: true,
|
|
6392
|
+
get: getKeyedQueueItems
|
|
6393
|
+
},
|
|
6394
|
+
keys: {
|
|
6395
|
+
enumerable: true,
|
|
6396
|
+
get: getQueueKeys
|
|
6397
|
+
},
|
|
6398
|
+
maximum: {
|
|
6399
|
+
enumerable: true,
|
|
6400
|
+
get: getQueueMaximum
|
|
6401
|
+
},
|
|
6402
|
+
paused: {
|
|
6403
|
+
enumerable: true,
|
|
6404
|
+
get: getPausedQueues
|
|
6405
|
+
},
|
|
6406
|
+
queues: {
|
|
6407
|
+
enumerable: true,
|
|
6408
|
+
get: getKeyedQueueSize
|
|
6409
|
+
}
|
|
6410
|
+
});
|
|
6411
|
+
function Queue(callback, options, key) {
|
|
6412
|
+
this[QUEUE_SYMBOL] = {
|
|
6413
|
+
callback,
|
|
6414
|
+
key,
|
|
6415
|
+
options,
|
|
6416
|
+
handled: [],
|
|
6417
|
+
id: 0,
|
|
6418
|
+
items: [],
|
|
6419
|
+
paused: !options.autostart,
|
|
6420
|
+
runners: 0
|
|
6421
|
+
};
|
|
6422
|
+
}
|
|
6423
|
+
Queue.prototype[QUEUE_PROPERTY] = QUEUE_NAME_QUEUE;
|
|
6424
|
+
Queue.prototype.add = addToQueue;
|
|
6425
|
+
Queue.prototype.clear = clearQueue;
|
|
6426
|
+
Queue.prototype.pause = pauseQueue;
|
|
6427
|
+
Queue.prototype.remove = removeQueued;
|
|
6428
|
+
Queue.prototype.resume = resumeQueue;
|
|
6429
|
+
Object.defineProperties(Queue.prototype, {
|
|
6430
|
+
active: {
|
|
6431
|
+
enumerable: true,
|
|
6432
|
+
get: getQueueActive
|
|
6433
|
+
},
|
|
6434
|
+
autostart: {
|
|
6435
|
+
enumerable: true,
|
|
6436
|
+
get: getQueueAutostart
|
|
6437
|
+
},
|
|
6438
|
+
concurrency: {
|
|
6439
|
+
enumerable: true,
|
|
6440
|
+
get: getQueueConcurrency
|
|
6441
|
+
},
|
|
6442
|
+
empty: {
|
|
6443
|
+
enumerable: true,
|
|
6444
|
+
get: getQueueEmpty
|
|
6445
|
+
},
|
|
6446
|
+
full: {
|
|
6447
|
+
enumerable: true,
|
|
6448
|
+
get: getQueueFull
|
|
6449
|
+
},
|
|
6450
|
+
maximum: {
|
|
6451
|
+
enumerable: true,
|
|
6452
|
+
get: getQueueMaximum
|
|
6453
|
+
},
|
|
6454
|
+
paused: {
|
|
6455
|
+
enumerable: true,
|
|
6456
|
+
get: getQueuePaused
|
|
6457
|
+
},
|
|
6458
|
+
size: {
|
|
6459
|
+
enumerable: true,
|
|
6460
|
+
get: getQueueSize
|
|
6461
|
+
}
|
|
6462
|
+
});
|
|
6463
|
+
function addKeyedQueue(key, parameters, signal) {
|
|
6464
|
+
return getQueue.call(this, key, true).add(parameters, signal);
|
|
6465
|
+
}
|
|
6466
|
+
function addToQueue(parameters, signal) {
|
|
6467
|
+
if (this.full) throw new QueueError(QUEUE_MESSAGE_MAXIMUM);
|
|
6094
6468
|
const abortSignal = signal instanceof AbortSignal ? signal : void 0;
|
|
6095
6469
|
if (abortSignal?.aborted ?? false) throw new Error(abortSignal?.reason);
|
|
6470
|
+
const state = this[QUEUE_SYMBOL];
|
|
6096
6471
|
const id = identify(state);
|
|
6097
6472
|
let rejector;
|
|
6098
6473
|
let resolver;
|
|
@@ -6116,8 +6491,8 @@ function addToQueue(instance, state, parameters, signal) {
|
|
|
6116
6491
|
promise
|
|
6117
6492
|
};
|
|
6118
6493
|
}
|
|
6119
|
-
function clearQueue(
|
|
6120
|
-
const items =
|
|
6494
|
+
function clearQueue() {
|
|
6495
|
+
const items = this[QUEUE_SYMBOL].items.splice(0);
|
|
6121
6496
|
const { length } = items;
|
|
6122
6497
|
for (let index = 0; index < length; index += 1) {
|
|
6123
6498
|
const { aborter, reject } = items[index];
|
|
@@ -6125,63 +6500,12 @@ function clearQueue(state) {
|
|
|
6125
6500
|
reject(new QueueError(QUEUE_MESSAGE_CLEAR));
|
|
6126
6501
|
}
|
|
6127
6502
|
}
|
|
6503
|
+
function clearQueues(key) {
|
|
6504
|
+
handleQueues(this, QUEUE_HANDLE_CLEAR, key);
|
|
6505
|
+
}
|
|
6128
6506
|
function createQueue(callback, options, key) {
|
|
6129
6507
|
if (typeof callback !== "function") throw new TypeError(QUEUE_MESSAGE_CALLBACK);
|
|
6130
|
-
|
|
6131
|
-
callback,
|
|
6132
|
-
key,
|
|
6133
|
-
handled: [],
|
|
6134
|
-
id: 0,
|
|
6135
|
-
items: [],
|
|
6136
|
-
options: createQueueOptions(options),
|
|
6137
|
-
paused: !getBooleanOrDefault(options?.autostart, true),
|
|
6138
|
-
runners: 0
|
|
6139
|
-
};
|
|
6140
|
-
const instance = {
|
|
6141
|
-
add: (parameters, signal) => addToQueue(instance, state, parameters, signal),
|
|
6142
|
-
clear: () => clearQueue(state),
|
|
6143
|
-
pause: () => {
|
|
6144
|
-
state.paused = true;
|
|
6145
|
-
},
|
|
6146
|
-
remove: (id) => removeQueued(state, id),
|
|
6147
|
-
resume: () => resumeQueue(state)
|
|
6148
|
-
};
|
|
6149
|
-
Object.defineProperties(instance, {
|
|
6150
|
-
[QUEUE_PROPERTY]: { value: QUEUE_NAME_QUEUE },
|
|
6151
|
-
active: {
|
|
6152
|
-
enumerable: true,
|
|
6153
|
-
get: () => state.runners > 0
|
|
6154
|
-
},
|
|
6155
|
-
autostart: {
|
|
6156
|
-
enumerable: true,
|
|
6157
|
-
get: () => state.options.autostart
|
|
6158
|
-
},
|
|
6159
|
-
concurrency: {
|
|
6160
|
-
enumerable: true,
|
|
6161
|
-
get: () => state.options.concurrency
|
|
6162
|
-
},
|
|
6163
|
-
empty: {
|
|
6164
|
-
enumerable: true,
|
|
6165
|
-
get: () => state.items.length === 0
|
|
6166
|
-
},
|
|
6167
|
-
full: {
|
|
6168
|
-
enumerable: true,
|
|
6169
|
-
get: () => state.options.maximum > 0 && state.items.length >= state.options.maximum
|
|
6170
|
-
},
|
|
6171
|
-
maximum: {
|
|
6172
|
-
enumerable: true,
|
|
6173
|
-
get: () => state.options.maximum
|
|
6174
|
-
},
|
|
6175
|
-
paused: {
|
|
6176
|
-
enumerable: true,
|
|
6177
|
-
get: () => state.paused
|
|
6178
|
-
},
|
|
6179
|
-
size: {
|
|
6180
|
-
enumerable: true,
|
|
6181
|
-
get: () => state.items.length
|
|
6182
|
-
}
|
|
6183
|
-
});
|
|
6184
|
-
return Object.freeze(instance);
|
|
6508
|
+
return new Queue(callback, createQueueOptions(options), key);
|
|
6185
6509
|
}
|
|
6186
6510
|
function createQueueOptions(input) {
|
|
6187
6511
|
const options = typeof input === "object" && input != null ? input : {};
|
|
@@ -6191,8 +6515,31 @@ function createQueueOptions(input) {
|
|
|
6191
6515
|
maximum: getNumberOrDefault(options.maximum, 0)
|
|
6192
6516
|
};
|
|
6193
6517
|
}
|
|
6194
|
-
function
|
|
6518
|
+
function getActiveQueues() {
|
|
6519
|
+
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_ACTIVE);
|
|
6520
|
+
}
|
|
6521
|
+
function getEmptyQueues() {
|
|
6522
|
+
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_EMPTY);
|
|
6523
|
+
}
|
|
6524
|
+
function getFullQueues() {
|
|
6525
|
+
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_FULL);
|
|
6526
|
+
}
|
|
6527
|
+
function getPausedQueues() {
|
|
6528
|
+
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_PAUSED);
|
|
6529
|
+
}
|
|
6530
|
+
function getKeyedQueueItems() {
|
|
6531
|
+
const state = this[QUEUE_SYMBOL];
|
|
6532
|
+
const size = {};
|
|
6533
|
+
const queues = state.queues.entries();
|
|
6534
|
+
for (const [key, queue] of queues) size[key] = queue.size;
|
|
6535
|
+
return size;
|
|
6536
|
+
}
|
|
6537
|
+
function getKeyedQueueSize() {
|
|
6538
|
+
return this[QUEUE_SYMBOL].queues.size;
|
|
6539
|
+
}
|
|
6540
|
+
function getQueue(key, add) {
|
|
6195
6541
|
if (typeof key !== "string" || key.trim().length === 0) throw new TypeError(QUEUE_MESSAGE_KEY);
|
|
6542
|
+
const state = this[QUEUE_SYMBOL];
|
|
6196
6543
|
let queue = state.queues.get(key);
|
|
6197
6544
|
if (queue == null && add === true) {
|
|
6198
6545
|
queue = createQueue(state.callback, state.options, key);
|
|
@@ -6200,11 +6547,33 @@ function getQueue(state, key, add) {
|
|
|
6200
6547
|
}
|
|
6201
6548
|
return queue;
|
|
6202
6549
|
}
|
|
6203
|
-
function
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
return
|
|
6550
|
+
function getQueueActive() {
|
|
6551
|
+
return this[QUEUE_SYMBOL].runners > 0;
|
|
6552
|
+
}
|
|
6553
|
+
function getQueueAutostart() {
|
|
6554
|
+
return this[QUEUE_SYMBOL].options.autostart === true;
|
|
6555
|
+
}
|
|
6556
|
+
function getQueueConcurrency() {
|
|
6557
|
+
return this[QUEUE_SYMBOL].options.concurrency;
|
|
6558
|
+
}
|
|
6559
|
+
function getQueueEmpty() {
|
|
6560
|
+
return this[QUEUE_SYMBOL].items.length === 0;
|
|
6561
|
+
}
|
|
6562
|
+
function getQueueFull() {
|
|
6563
|
+
const state = this[QUEUE_SYMBOL];
|
|
6564
|
+
return state.options.maximum > 0 && state.items.length >= state.options.maximum;
|
|
6565
|
+
}
|
|
6566
|
+
function getQueueKeys() {
|
|
6567
|
+
return [...this[QUEUE_SYMBOL].queues.keys()];
|
|
6568
|
+
}
|
|
6569
|
+
function getQueueMaximum() {
|
|
6570
|
+
return this[QUEUE_SYMBOL].options.maximum;
|
|
6571
|
+
}
|
|
6572
|
+
function getQueuePaused() {
|
|
6573
|
+
return this[QUEUE_SYMBOL].paused === true;
|
|
6574
|
+
}
|
|
6575
|
+
function getQueueSize() {
|
|
6576
|
+
return this[QUEUE_SYMBOL].items.length;
|
|
6208
6577
|
}
|
|
6209
6578
|
function getStatus(state, status) {
|
|
6210
6579
|
const queues = state.queues.entries();
|
|
@@ -6224,12 +6593,12 @@ function handleQueuedResult(item, error, result) {
|
|
|
6224
6593
|
}
|
|
6225
6594
|
item.resolve(result);
|
|
6226
6595
|
}
|
|
6227
|
-
function handleQueues(
|
|
6596
|
+
function handleQueues(instance, type, key) {
|
|
6228
6597
|
if (typeof key === "string") {
|
|
6229
|
-
getQueue(
|
|
6598
|
+
getQueue.call(instance, key)?.[type]();
|
|
6230
6599
|
return;
|
|
6231
6600
|
}
|
|
6232
|
-
const queues =
|
|
6601
|
+
const queues = instance[QUEUE_SYMBOL].queues.values();
|
|
6233
6602
|
for (const queue of queues) queue[type]();
|
|
6234
6603
|
}
|
|
6235
6604
|
function identify(state) {
|
|
@@ -6255,78 +6624,29 @@ function isQueue(value) {
|
|
|
6255
6624
|
return isQueueInstance(QUEUE_NAME_QUEUE, value);
|
|
6256
6625
|
}
|
|
6257
6626
|
function isQueueInstance(name, value) {
|
|
6258
|
-
return typeof value === "object" && value != null && value[QUEUE_PROPERTY] === name;
|
|
6627
|
+
return typeof value === "object" && value != null && QUEUE_PROPERTY in value && value[QUEUE_PROPERTY] === name;
|
|
6259
6628
|
}
|
|
6260
6629
|
function keyedQueue(callback, options) {
|
|
6261
6630
|
if (typeof callback !== "function") throw new TypeError(QUEUE_MESSAGE_CALLBACK);
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
clear: (key) => handleQueues(state, QUEUE_HANDLE_CLEAR, key),
|
|
6270
|
-
get: (key) => getQueue(state, key),
|
|
6271
|
-
pause: (key) => handleQueues(state, QUEUE_HANDLE_PAUSE, key),
|
|
6272
|
-
remove: (key, id) => removeQueue(state, key, id),
|
|
6273
|
-
resume: (key) => handleQueues(state, QUEUE_HANDLE_RESUME, key)
|
|
6274
|
-
};
|
|
6275
|
-
Object.defineProperties(instance, {
|
|
6276
|
-
[QUEUE_PROPERTY]: { value: QUEUE_NAME_KEYED },
|
|
6277
|
-
active: {
|
|
6278
|
-
enumerable: true,
|
|
6279
|
-
get: () => getStatus(state, QUEUE_STATUS_ACTIVE)
|
|
6280
|
-
},
|
|
6281
|
-
autostart: {
|
|
6282
|
-
enumerable: true,
|
|
6283
|
-
get: () => state.options.autostart
|
|
6284
|
-
},
|
|
6285
|
-
concurrency: {
|
|
6286
|
-
enumerable: true,
|
|
6287
|
-
get: () => state.options.concurrency
|
|
6288
|
-
},
|
|
6289
|
-
empty: {
|
|
6290
|
-
enumerable: true,
|
|
6291
|
-
get: () => getStatus(state, QUEUE_STATUS_EMPTY)
|
|
6292
|
-
},
|
|
6293
|
-
full: {
|
|
6294
|
-
enumerable: true,
|
|
6295
|
-
get: () => getStatus(state, QUEUE_STATUS_FULL)
|
|
6296
|
-
},
|
|
6297
|
-
items: {
|
|
6298
|
-
enumerable: true,
|
|
6299
|
-
get: () => getQueueItems(state)
|
|
6300
|
-
},
|
|
6301
|
-
keys: {
|
|
6302
|
-
enumerable: true,
|
|
6303
|
-
get: () => [...state.queues.keys()]
|
|
6304
|
-
},
|
|
6305
|
-
maximum: {
|
|
6306
|
-
enumerable: true,
|
|
6307
|
-
get: () => state.options.maximum
|
|
6308
|
-
},
|
|
6309
|
-
paused: {
|
|
6310
|
-
enumerable: true,
|
|
6311
|
-
get: () => getStatus(state, QUEUE_STATUS_PAUSED)
|
|
6312
|
-
},
|
|
6313
|
-
queues: {
|
|
6314
|
-
enumerable: true,
|
|
6315
|
-
get: () => state.queues.size
|
|
6316
|
-
}
|
|
6317
|
-
});
|
|
6318
|
-
return Object.freeze(instance);
|
|
6631
|
+
return new KeyedQueue(callback, createQueueOptions(options));
|
|
6632
|
+
}
|
|
6633
|
+
function pauseQueue() {
|
|
6634
|
+
this[QUEUE_SYMBOL].paused = true;
|
|
6635
|
+
}
|
|
6636
|
+
function pauseQueues(key) {
|
|
6637
|
+
handleQueues(this, QUEUE_HANDLE_PAUSE, key);
|
|
6319
6638
|
}
|
|
6320
6639
|
function queue(callback, options) {
|
|
6321
6640
|
return createQueue(callback, options);
|
|
6322
6641
|
}
|
|
6323
|
-
function removeQueue(
|
|
6642
|
+
function removeQueue(key, id) {
|
|
6643
|
+
const state = this[QUEUE_SYMBOL];
|
|
6324
6644
|
if (key == null) {
|
|
6325
|
-
handleQueues(
|
|
6645
|
+
handleQueues(this, QUEUE_HANDLE_CLEAR);
|
|
6326
6646
|
state.queues.clear();
|
|
6327
6647
|
return;
|
|
6328
6648
|
}
|
|
6329
|
-
const queue = getQueue(
|
|
6649
|
+
const queue = getQueue.call(this, key);
|
|
6330
6650
|
if (queue == null) return;
|
|
6331
6651
|
if (typeof id === "number") {
|
|
6332
6652
|
queue.remove(id);
|
|
@@ -6335,7 +6655,8 @@ function removeQueue(state, key, id) {
|
|
|
6335
6655
|
queue.clear();
|
|
6336
6656
|
state.queues.delete(key);
|
|
6337
6657
|
}
|
|
6338
|
-
function removeQueued(
|
|
6658
|
+
function removeQueued(id) {
|
|
6659
|
+
const state = this[QUEUE_SYMBOL];
|
|
6339
6660
|
const index = state.items.findIndex((item) => item.id === id);
|
|
6340
6661
|
if (index > -1) {
|
|
6341
6662
|
const { aborter, reject } = state.items.splice(index, 1)[0];
|
|
@@ -6343,7 +6664,8 @@ function removeQueued(state, id) {
|
|
|
6343
6664
|
reject(new QueueError(QUEUE_MESSAGE_REMOVE));
|
|
6344
6665
|
}
|
|
6345
6666
|
}
|
|
6346
|
-
function resumeQueue(
|
|
6667
|
+
function resumeQueue() {
|
|
6668
|
+
const state = this[QUEUE_SYMBOL];
|
|
6347
6669
|
if (state.paused) {
|
|
6348
6670
|
const handled = state.handled.splice(0);
|
|
6349
6671
|
const { length } = handled;
|
|
@@ -6353,6 +6675,9 @@ function resumeQueue(state) {
|
|
|
6353
6675
|
const length = Math.min(state.options.concurrency, state.items.length);
|
|
6354
6676
|
for (let index = 0; index < length; index += 1) run(state);
|
|
6355
6677
|
}
|
|
6678
|
+
function resumeQueues(key) {
|
|
6679
|
+
handleQueues(this, QUEUE_HANDLE_RESUME, key);
|
|
6680
|
+
}
|
|
6356
6681
|
async function run(state) {
|
|
6357
6682
|
if (state.paused || state.runners >= state.options.concurrency) return;
|
|
6358
6683
|
state.runners += 1;
|
|
@@ -6380,7 +6705,6 @@ async function run(state) {
|
|
|
6380
6705
|
state.runners -= 1;
|
|
6381
6706
|
}
|
|
6382
6707
|
const QUEUE_ERROR_NAME = "QueueError";
|
|
6383
|
-
const QUEUE_PROPERTY = "$queue";
|
|
6384
6708
|
const QUEUE_HANDLE_CLEAR = "clear";
|
|
6385
6709
|
const QUEUE_HANDLE_PAUSE = "pause";
|
|
6386
6710
|
const QUEUE_HANDLE_RESUME = "resume";
|
|
@@ -6389,14 +6713,12 @@ const QUEUE_MESSAGE_CLEAR = "Queue was cleared";
|
|
|
6389
6713
|
const QUEUE_MESSAGE_KEY = "Key must be a non-empty string";
|
|
6390
6714
|
const QUEUE_MESSAGE_MAXIMUM = "Queue has reached its maximum size";
|
|
6391
6715
|
const QUEUE_MESSAGE_REMOVE = "Item removed from queue";
|
|
6392
|
-
const QUEUE_NAME_KEYED = "keyedQueue";
|
|
6393
|
-
const QUEUE_NAME_QUEUE = "queue";
|
|
6394
6716
|
const QUEUE_STATUS_ACTIVE = "active";
|
|
6395
6717
|
const QUEUE_STATUS_EMPTY = "empty";
|
|
6396
6718
|
const QUEUE_STATUS_FULL = "full";
|
|
6397
6719
|
const QUEUE_STATUS_PAUSED = "paused";
|
|
6720
|
+
const QUEUE_SYMBOL = Symbol(QUEUE_PROPERTY);
|
|
6398
6721
|
queue.keyed = keyedQueue;
|
|
6399
|
-
Object.defineProperty(queue, "keyed", { value: keyedQueue });
|
|
6400
6722
|
//#endregion
|
|
6401
6723
|
//#region src/random.ts
|
|
6402
6724
|
/**
|
|
@@ -6514,4 +6836,4 @@ var SizedSet = class extends Set {
|
|
|
6514
6836
|
}
|
|
6515
6837
|
};
|
|
6516
6838
|
//#endregion
|
|
6517
|
-
export { CancelablePromise, Logger, PromiseTimeoutError, QueueError, RetryError, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SizedMap, SizedSet, assert, assertCondition, assertDefined, assertInstanceOf, assertIs, assertProperty, assign, asyncAttempt, asyncDebounce, asyncFlow, asyncMatchResult, asyncOnce, asyncPipe, asyncThrottle, attempt, attemptAsyncFlow, attemptAsyncPipe, attemptFlow, attemptPipe, attemptPromise, 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, filter, find, findLast, first, firstOrDefault, flatFreeze, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getSortedIndex, getString, getTimedPromise, getUuid, getValue, groupArraysBy, groupBy, handleResult, hasValue, hasValueResult, herald, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, ignoreKey, inMap, inSet, includes, includesArray, indexOf, indexOfArray, initializeAssigner, initializeCloner, initializeEqualizer, initializeMerger, initializeNormalizer, initializeSorter, initializeTemplater, initializeTransformer, insert, interpolate, intersection, isArrayOrPlainObject, isBeacon, isBeaconSubscription, isColor, isConstructor, isEmpty, isError, isFrozen, isFulfilled, 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, isNonTypedArray, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isObservable, isOk, isPlainObject, isPrimitive, isQueue, isQueueInstance, isRejected, isResult, isRgbColor, isRgbaColor, isSorted, isSubscription, isSubscriptions,
|
|
6839
|
+
export { CancelablePromise, Logger, PromiseTimeoutError, QueueError, RetryError, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SizedMap, SizedSet, assert, assertCondition, assertDefined, assertInstanceOf, assertIs, assertProperty, assign, asyncAttempt, asyncDebounce, asyncFlow, asyncMatchResult, asyncOnce, asyncPipe, asyncThrottle, attempt, attemptAsyncFlow, attemptAsyncPipe, attemptFlow, attemptPipe, attemptPromise, 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, filter, find, findLast, first, firstOrDefault, flatFreeze, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getSortedIndex, getString, getTimedPromise, getUuid, getValue, groupArraysBy, groupBy, handleResult, hasValue, hasValueResult, herald, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, ignoreKey, inMap, inSet, includes, includesArray, indexOf, indexOfArray, initializeAssigner, initializeCloner, initializeEqualizer, initializeMerger, initializeNormalizer, initializeSorter, initializeTemplater, initializeTransformer, insert, interpolate, intersection, isArrayOrPlainObject, isAsyncOnce, isBeacon, isBeaconSubscription, isColor, isConstructor, isEmpty, isError, isFrozen, isFulfilled, isFuzzy, 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, isNonTypedArray, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isObservable, isOk, isOnce, isPlainObject, isPrimitive, isQueue, isQueueInstance, isRejected, isResult, isRgbColor, isRgbaColor, isSorted, isSubscription, isSubscriptions, isTimeLogger, isTypedArray, join, kebabCase, keyedQueue, last, lastIndexOf, lastOrDefault, lowerCase, matchResult, max, median, memoize, merge, min, move, moveIndices, moveToIndex, noop, normalize, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, registerCloner, registerComparator, registerEqualizer, resultPromises, retry, reverse, reverseSelect, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba, round, select, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, subscriptions, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toResult, toSet, toggle, transform, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };
|