@oscarpalmer/atoms 0.203.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/filter.mjs +0 -1
- package/dist/array/find.mjs +0 -1
- package/dist/array/first.mjs +0 -1
- package/dist/array/group-by.mjs +0 -1
- package/dist/array/last.mjs +0 -1
- package/dist/array/move.mjs +0 -4
- package/dist/array/select.mjs +0 -1
- package/dist/array/sort.mjs +6 -15
- package/dist/array/swap.mjs +0 -1
- package/dist/array/to-map.mjs +0 -1
- package/dist/array/to-record.mjs +0 -1
- package/dist/beacon.mjs +36 -36
- package/dist/color/instance.mjs +42 -84
- package/dist/color/misc/alpha.d.mts +3 -1
- package/dist/color/misc/alpha.mjs +8 -2
- package/dist/color/misc/is.mjs +5 -4
- package/dist/color/misc/state.d.mts +29 -4
- package/dist/color/misc/state.mjs +18 -40
- package/dist/color/space/hex.d.mts +5 -1
- package/dist/color/space/hex.mjs +21 -2
- package/dist/color/space/hsl.d.mts +6 -2
- package/dist/color/space/hsl.mjs +25 -4
- package/dist/color/space/hwb.d.mts +6 -2
- package/dist/color/space/hwb.mjs +24 -3
- package/dist/color/space/rgb.d.mts +6 -2
- package/dist/color/space/rgb.mjs +41 -20
- package/dist/function/limit.mjs +0 -2
- package/dist/function/once.mjs +30 -36
- package/dist/function/retry.mjs +0 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +488 -547
- package/dist/internal/{abort.d.mts → aborter.d.mts} +1 -1
- package/dist/internal/{abort.mjs → aborter.mjs} +1 -1
- package/dist/internal/array/get.mjs +3 -2
- package/dist/internal/array/index-of.mjs +0 -1
- package/dist/internal/function/assert.d.mts +1 -1
- package/dist/internal/function/assert.mjs +0 -7
- package/dist/internal/function/limit.mjs +10 -14
- package/dist/internal/function/memoize.mjs +22 -20
- package/dist/internal/function/work.mjs +0 -2
- package/dist/internal/herald.mjs +14 -15
- package/dist/internal/result/misc.mjs +2 -5
- package/dist/internal/subscription.mjs +24 -22
- package/dist/internal/value/compare.d.mts +1 -1
- package/dist/internal/value/compare.mjs +0 -5
- package/dist/internal/value/equal.d.mts +1 -1
- package/dist/internal/value/equal.mjs +4 -12
- package/dist/internal/value/handlers.d.mts +1 -1
- package/dist/internal/value/handlers.mjs +5 -7
- package/dist/internal/value/has.mjs +0 -1
- package/dist/internal/value/misc.d.mts +1 -1
- package/dist/internal/value/misc.mjs +4 -3
- package/dist/internal/value/partial.mjs +2 -1
- package/dist/internal/value/set.mjs +2 -1
- package/dist/logger.mjs +46 -45
- package/dist/promise/delay.mjs +1 -1
- package/dist/promise/helpers.mjs +4 -3
- package/dist/promise/index.mjs +1 -2
- package/dist/promise/misc.d.mts +1 -1
- package/dist/promise/models.d.mts +1 -1
- package/dist/promise/timed.mjs +1 -1
- package/dist/queue.mjs +86 -80
- package/dist/result/index.mjs +0 -1
- package/dist/result/match.mjs +0 -1
- package/dist/result/work/flow.mjs +0 -1
- package/dist/result/work/pipe.mjs +0 -1
- package/dist/string/fuzzy.mjs +18 -21
- package/dist/string/normalize.mjs +2 -3
- package/dist/string/template.mjs +2 -3
- package/dist/value/clone.d.mts +1 -1
- package/dist/value/clone.mjs +4 -12
- package/dist/value/freeze.mjs +0 -4
- package/dist/value/merge.mjs +5 -7
- package/dist/value/transform.mjs +1 -2
- package/package.json +2 -2
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) {
|
|
@@ -1074,19 +1064,17 @@ function BaseHandler(owner, options) {
|
|
|
1074
1064
|
this.owner = owner;
|
|
1075
1065
|
this.options = options;
|
|
1076
1066
|
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
register: { value: registerHandler }
|
|
1081
|
-
});
|
|
1067
|
+
BaseHandler.prototype.deregister = deregisterHandler;
|
|
1068
|
+
BaseHandler.prototype.get = getHandler$1;
|
|
1069
|
+
BaseHandler.prototype.register = registerHandler;
|
|
1082
1070
|
function CompareHandler(base) {
|
|
1083
1071
|
this.base = base;
|
|
1084
1072
|
}
|
|
1085
|
-
|
|
1073
|
+
CompareHandler.prototype.handle = handleComparison;
|
|
1086
1074
|
function ValueHandler(value) {
|
|
1087
1075
|
this.base = value;
|
|
1088
1076
|
}
|
|
1089
|
-
|
|
1077
|
+
ValueHandler.prototype.handle = handleValue$1;
|
|
1090
1078
|
function createBaseHandler(owner, options) {
|
|
1091
1079
|
return new BaseHandler(owner, options);
|
|
1092
1080
|
}
|
|
@@ -1207,23 +1195,14 @@ const compareHandler = createCompareHandler(compare, {
|
|
|
1207
1195
|
compare.deregister = deregisterComparator;
|
|
1208
1196
|
compare.handler = compareHandler;
|
|
1209
1197
|
compare.register = registerComparator;
|
|
1210
|
-
Object.defineProperties(compare, {
|
|
1211
|
-
deregister: { value: deregisterComparator },
|
|
1212
|
-
handler: { value: compareHandler },
|
|
1213
|
-
register: { value: registerComparator }
|
|
1214
|
-
});
|
|
1215
1198
|
//#endregion
|
|
1216
1199
|
//#region src/array/sort.ts
|
|
1217
|
-
const SORTER_PROPERTY = "$sorter";
|
|
1218
1200
|
function Sorter(sorters) {
|
|
1219
|
-
|
|
1201
|
+
this[SORTER_SYMBOL] = sorters;
|
|
1220
1202
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
is: { value: isSortedArray },
|
|
1225
|
-
sort: { value: sortArray }
|
|
1226
|
-
});
|
|
1203
|
+
Sorter.prototype.index = getSortedArrayIndex;
|
|
1204
|
+
Sorter.prototype.is = isSortedArray;
|
|
1205
|
+
Sorter.prototype.sort = sortArray;
|
|
1227
1206
|
function getComparisonSorter(callback, modifier) {
|
|
1228
1207
|
return {
|
|
1229
1208
|
modifier,
|
|
@@ -1235,7 +1214,7 @@ function getComparisonSorter(callback, modifier) {
|
|
|
1235
1214
|
function getComparisonValue(first, second, sorters, length) {
|
|
1236
1215
|
for (let index = 0; index < length; index += 1) {
|
|
1237
1216
|
const sorter = sorters[index];
|
|
1238
|
-
const values = [sorter.get ? sorter.value(first) : first, sorter.get ? sorter.value(second) : second];
|
|
1217
|
+
const values = [sorter.get ? sorter.value?.(first) : first, sorter.get ? sorter.value?.(second) : second];
|
|
1239
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;
|
|
1240
1219
|
if (comparison !== 0) return comparison;
|
|
1241
1220
|
}
|
|
@@ -1350,7 +1329,7 @@ const SORT_PEEK_PERCENTAGE = 10;
|
|
|
1350
1329
|
const SORT_THRESHOLD = 100;
|
|
1351
1330
|
const SORT_DIRECTION_ASCENDING = "ascending";
|
|
1352
1331
|
const SORT_DIRECTION_DESCENDING = "descending";
|
|
1353
|
-
const SORTER_SYMBOL = Symbol(
|
|
1332
|
+
const SORTER_SYMBOL = Symbol("sorter");
|
|
1354
1333
|
const modifiers = {
|
|
1355
1334
|
[SORT_DIRECTION_ASCENDING]: 1,
|
|
1356
1335
|
[SORT_DIRECTION_DESCENDING]: -1
|
|
@@ -1358,11 +1337,6 @@ const modifiers = {
|
|
|
1358
1337
|
sort.getIndex = getSortedIndex;
|
|
1359
1338
|
sort.initialize = initializeSorter;
|
|
1360
1339
|
sort.is = isSorted;
|
|
1361
|
-
Object.defineProperties(sort, {
|
|
1362
|
-
getIndex: { value: getSortedIndex },
|
|
1363
|
-
initialize: { value: initializeSorter },
|
|
1364
|
-
is: { value: isSorted }
|
|
1365
|
-
});
|
|
1366
1340
|
//#endregion
|
|
1367
1341
|
//#region src/array/swap.ts
|
|
1368
1342
|
function swap(array, first, second, third) {
|
|
@@ -1420,7 +1394,6 @@ function swapValues(array, from, to, key) {
|
|
|
1420
1394
|
return swapIndices(array, first, second);
|
|
1421
1395
|
}
|
|
1422
1396
|
swap.indices = swapIndices;
|
|
1423
|
-
Object.defineProperty(swap, "indices", { value: swapIndices });
|
|
1424
1397
|
//#endregion
|
|
1425
1398
|
//#region src/array/to-map.ts
|
|
1426
1399
|
function getMapValues(array, first, second, arrays) {
|
|
@@ -1447,7 +1420,6 @@ function toMapArrays(array, first, second) {
|
|
|
1447
1420
|
return getMapValues(array, first, second, true);
|
|
1448
1421
|
}
|
|
1449
1422
|
toMap.arrays = toMapArrays;
|
|
1450
|
-
Object.defineProperty(toMap, "arrays", { value: toMapArrays });
|
|
1451
1423
|
//#endregion
|
|
1452
1424
|
//#region src/array/to-record.ts
|
|
1453
1425
|
function toRecord(array, first, second) {
|
|
@@ -1457,7 +1429,6 @@ function toRecordArrays(array, first, second) {
|
|
|
1457
1429
|
return groupValues(array, first, second, true);
|
|
1458
1430
|
}
|
|
1459
1431
|
toRecord.arrays = toRecordArrays;
|
|
1460
|
-
Object.defineProperty(toRecord, "arrays", { value: toRecordArrays });
|
|
1461
1432
|
//#endregion
|
|
1462
1433
|
//#region src/internal/function/misc.ts
|
|
1463
1434
|
/**
|
|
@@ -1478,33 +1449,29 @@ const LIMITER_NAME_ASYNC = "asyncLimiter";
|
|
|
1478
1449
|
const LIMITER_NAME_SYNC = "limiter";
|
|
1479
1450
|
const LIMITER_PROPERTY = "$limiter";
|
|
1480
1451
|
function AsyncLimiter(type, callback, time) {
|
|
1481
|
-
|
|
1452
|
+
this[LIMITER_SYMBOL] = {
|
|
1482
1453
|
callback,
|
|
1483
1454
|
type,
|
|
1484
1455
|
interval: getNumberOrDefault(time, 0),
|
|
1485
1456
|
parameters: [],
|
|
1486
1457
|
throttle: type === LIMITER_THROTTLE
|
|
1487
|
-
}
|
|
1458
|
+
};
|
|
1488
1459
|
}
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
run: { value: runAsyncLimiter }
|
|
1493
|
-
});
|
|
1460
|
+
AsyncLimiter.prototype[LIMITER_PROPERTY] = LIMITER_NAME_ASYNC;
|
|
1461
|
+
AsyncLimiter.prototype.cancel = cancelAsyncLimiter;
|
|
1462
|
+
AsyncLimiter.prototype.run = runAsyncLimiter;
|
|
1494
1463
|
function Limiter(type, callback, time) {
|
|
1495
|
-
|
|
1464
|
+
this[LIMITER_SYMBOL] = {
|
|
1496
1465
|
callback,
|
|
1497
1466
|
type,
|
|
1498
1467
|
interval: getNumberOrDefault(time, 0),
|
|
1499
1468
|
parameters: [],
|
|
1500
1469
|
throttle: type === LIMITER_THROTTLE
|
|
1501
|
-
}
|
|
1470
|
+
};
|
|
1502
1471
|
}
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
run: { value: runLimiter }
|
|
1507
|
-
});
|
|
1472
|
+
Limiter.prototype[LIMITER_PROPERTY] = LIMITER_NAME_SYNC;
|
|
1473
|
+
Limiter.prototype.cancel = cancelLimiter;
|
|
1474
|
+
Limiter.prototype.run = runLimiter;
|
|
1508
1475
|
function cancelAsyncLimiter() {
|
|
1509
1476
|
const state = this[LIMITER_SYMBOL];
|
|
1510
1477
|
if (state.timer != null) clearTimer(state.timer);
|
|
@@ -1636,8 +1603,6 @@ function throttle(callback, time) {
|
|
|
1636
1603
|
}
|
|
1637
1604
|
debounce.async = asyncDebounce;
|
|
1638
1605
|
throttle.async = asyncThrottle;
|
|
1639
|
-
Object.defineProperty(debounce, "async", { value: asyncDebounce });
|
|
1640
|
-
Object.defineProperty(throttle, "async", { value: asyncThrottle });
|
|
1641
1606
|
//#endregion
|
|
1642
1607
|
//#region src/internal/result/misc.ts
|
|
1643
1608
|
function error(value, original) {
|
|
@@ -1667,8 +1632,7 @@ function isResult(value) {
|
|
|
1667
1632
|
return isResultValue(value, true) || isResultValue(value, false);
|
|
1668
1633
|
}
|
|
1669
1634
|
function isResultValue(value, okValue) {
|
|
1670
|
-
|
|
1671
|
-
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;
|
|
1672
1636
|
}
|
|
1673
1637
|
/**
|
|
1674
1638
|
* Creates an ok result
|
|
@@ -1689,8 +1653,6 @@ const RESULT_PROPERTY_ERROR = "error";
|
|
|
1689
1653
|
const RESULT_PROPERTY_VALUE = "value";
|
|
1690
1654
|
error.is = isError;
|
|
1691
1655
|
ok.is = isOk;
|
|
1692
|
-
Object.defineProperty(error, "is", { value: isError });
|
|
1693
|
-
Object.defineProperty(ok, "is", { value: isOk });
|
|
1694
1656
|
//#endregion
|
|
1695
1657
|
//#region src/internal/value/misc.ts
|
|
1696
1658
|
function findKey(needle, haystack) {
|
|
@@ -1722,9 +1684,10 @@ function getPaths(path, lowercase) {
|
|
|
1722
1684
|
function handleValue(data, path, value, get, ignoreCase) {
|
|
1723
1685
|
if (typeof data === "object" && data !== null) {
|
|
1724
1686
|
if (ignoreKey(path)) return error(MISC_NESTED_MESSAGE_UNSAFE);
|
|
1725
|
-
const
|
|
1726
|
-
|
|
1727
|
-
|
|
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;
|
|
1728
1691
|
}
|
|
1729
1692
|
if (get) return error(MISC_NESTED_MESSAGE_MISSING);
|
|
1730
1693
|
}
|
|
@@ -1744,7 +1707,6 @@ function hasValueResult(data, path, ignoreCase) {
|
|
|
1744
1707
|
return getNestedValue(data, path, ignoreCase === true);
|
|
1745
1708
|
}
|
|
1746
1709
|
hasValue.get = hasValueResult;
|
|
1747
|
-
Object.defineProperty(hasValue, "get", { value: hasValueResult });
|
|
1748
1710
|
//#endregion
|
|
1749
1711
|
//#region src/internal/function/assert.ts
|
|
1750
1712
|
/**
|
|
@@ -1839,20 +1801,13 @@ assert.defined = assertDefined;
|
|
|
1839
1801
|
assert.instanceOf = assertInstanceOf;
|
|
1840
1802
|
assert.is = assertIs;
|
|
1841
1803
|
assert.property = assertProperty;
|
|
1842
|
-
Object.defineProperties(assert, {
|
|
1843
|
-
condition: { value: assertCondition },
|
|
1844
|
-
defined: { value: assertDefined },
|
|
1845
|
-
instanceOf: { value: assertInstanceOf },
|
|
1846
|
-
is: { value: assertIs },
|
|
1847
|
-
property: { value: assertProperty }
|
|
1848
|
-
});
|
|
1849
1804
|
//#endregion
|
|
1850
1805
|
//#region src/function/once.ts
|
|
1851
1806
|
const ONCE_NAME_ASYNC = "asyncOnce";
|
|
1852
1807
|
const ONCE_NAME_SYNC = "once";
|
|
1853
1808
|
const ONCE_PROPERTY = "$once";
|
|
1854
1809
|
function AsyncOnce(callback) {
|
|
1855
|
-
|
|
1810
|
+
this[ONCE_SYMBOL] = {
|
|
1856
1811
|
callback,
|
|
1857
1812
|
called: false,
|
|
1858
1813
|
cleared: false,
|
|
@@ -1860,61 +1815,49 @@ function AsyncOnce(callback) {
|
|
|
1860
1815
|
finished: false,
|
|
1861
1816
|
items: [],
|
|
1862
1817
|
value: void 0
|
|
1863
|
-
}
|
|
1818
|
+
};
|
|
1864
1819
|
}
|
|
1820
|
+
AsyncOnce.prototype[ONCE_PROPERTY] = ONCE_NAME_ASYNC;
|
|
1821
|
+
AsyncOnce.prototype.clear = clearOnce;
|
|
1822
|
+
AsyncOnce.prototype.run = runOnceAsync;
|
|
1865
1823
|
Object.defineProperties(AsyncOnce.prototype, {
|
|
1866
|
-
[ONCE_PROPERTY]: { value: ONCE_NAME_ASYNC },
|
|
1867
1824
|
called: {
|
|
1868
1825
|
enumerable: true,
|
|
1869
|
-
get
|
|
1870
|
-
return this[ONCE_SYMBOL].called;
|
|
1871
|
-
}
|
|
1826
|
+
get: getOnceCalled
|
|
1872
1827
|
},
|
|
1873
|
-
clear: { value: clearOnce },
|
|
1874
1828
|
cleared: {
|
|
1875
1829
|
enumerable: true,
|
|
1876
|
-
get
|
|
1877
|
-
return this[ONCE_SYMBOL].cleared;
|
|
1878
|
-
}
|
|
1830
|
+
get: getOnceCleared
|
|
1879
1831
|
},
|
|
1880
1832
|
error: {
|
|
1881
1833
|
enumerable: true,
|
|
1882
|
-
get
|
|
1883
|
-
return this[ONCE_SYMBOL].error;
|
|
1884
|
-
}
|
|
1834
|
+
get: getAsyncOnceError
|
|
1885
1835
|
},
|
|
1886
1836
|
finished: {
|
|
1887
1837
|
enumerable: true,
|
|
1888
|
-
get
|
|
1889
|
-
|
|
1890
|
-
}
|
|
1891
|
-
},
|
|
1892
|
-
run: { value: runOnceAsync }
|
|
1838
|
+
get: getAsyncOnceFinished
|
|
1839
|
+
}
|
|
1893
1840
|
});
|
|
1894
1841
|
function Once(callback) {
|
|
1895
|
-
|
|
1842
|
+
this[ONCE_SYMBOL] = {
|
|
1896
1843
|
callback,
|
|
1897
1844
|
called: false,
|
|
1898
1845
|
cleared: false,
|
|
1899
1846
|
value: void 0
|
|
1900
|
-
}
|
|
1847
|
+
};
|
|
1901
1848
|
}
|
|
1849
|
+
Once.prototype[ONCE_PROPERTY] = ONCE_NAME_SYNC;
|
|
1850
|
+
Once.prototype.clear = clearOnce;
|
|
1851
|
+
Once.prototype.run = runOnce;
|
|
1902
1852
|
Object.defineProperties(Once.prototype, {
|
|
1903
|
-
[ONCE_PROPERTY]: { value: ONCE_NAME_SYNC },
|
|
1904
|
-
clear: { value: clearOnce },
|
|
1905
1853
|
called: {
|
|
1906
1854
|
enumerable: true,
|
|
1907
|
-
get
|
|
1908
|
-
return this[ONCE_SYMBOL].called;
|
|
1909
|
-
}
|
|
1855
|
+
get: getOnceCalled
|
|
1910
1856
|
},
|
|
1911
1857
|
cleared: {
|
|
1912
1858
|
enumerable: true,
|
|
1913
|
-
get
|
|
1914
|
-
|
|
1915
|
-
}
|
|
1916
|
-
},
|
|
1917
|
-
run: { value: runOnce }
|
|
1859
|
+
get: getOnceCleared
|
|
1860
|
+
}
|
|
1918
1861
|
});
|
|
1919
1862
|
/**
|
|
1920
1863
|
* Create an asynchronous function that can only be called once, rejecting or resolving the same result on subsequent calls
|
|
@@ -1935,6 +1878,18 @@ function clearOnce() {
|
|
|
1935
1878
|
state.cleared = true;
|
|
1936
1879
|
state.value = void 0;
|
|
1937
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
|
+
}
|
|
1938
1893
|
function handleOnceResult(state, value, error) {
|
|
1939
1894
|
state.error = error;
|
|
1940
1895
|
state.finished = true;
|
|
@@ -2016,12 +1971,6 @@ asyncOnce.is = isAsyncOnce;
|
|
|
2016
1971
|
once.async = asyncOnce;
|
|
2017
1972
|
once.is = isOnce;
|
|
2018
1973
|
once.isAsync = isAsyncOnce;
|
|
2019
|
-
Object.defineProperty(asyncOnce, "is", { value: isAsyncOnce });
|
|
2020
|
-
Object.defineProperties(once, {
|
|
2021
|
-
async: { value: asyncOnce },
|
|
2022
|
-
is: { value: isOnce },
|
|
2023
|
-
isAsync: { value: isAsyncOnce }
|
|
2024
|
-
});
|
|
2025
1974
|
//#endregion
|
|
2026
1975
|
//#region src/function/retry.ts
|
|
2027
1976
|
/**
|
|
@@ -2105,7 +2054,6 @@ const RETRY_ERROR_NAME = "RetryError";
|
|
|
2105
2054
|
const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
|
|
2106
2055
|
const RETRY_MESSAGE_FAILED = "Retry failed";
|
|
2107
2056
|
retry.async = asyncRetry;
|
|
2108
|
-
Object.defineProperty(retry, "async", { value: asyncRetry });
|
|
2109
2057
|
//#endregion
|
|
2110
2058
|
//#region src/internal/function/work.ts
|
|
2111
2059
|
function asyncFlow(...fns) {
|
|
@@ -2166,8 +2114,6 @@ const assertFlowFunctions = assert.condition((value) => Array.isArray(value) &&
|
|
|
2166
2114
|
const assertPipeFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_PIPE_ARRAY, TypeError);
|
|
2167
2115
|
flow.async = asyncFlow;
|
|
2168
2116
|
pipe.async = asyncPipe;
|
|
2169
|
-
Object.defineProperty(flow, "async", { value: asyncFlow });
|
|
2170
|
-
Object.defineProperty(pipe, "async", { value: asyncPipe });
|
|
2171
2117
|
//#endregion
|
|
2172
2118
|
//#region src/internal/number.ts
|
|
2173
2119
|
/**
|
|
@@ -2305,32 +2251,28 @@ var SizedMap = class extends Map {
|
|
|
2305
2251
|
};
|
|
2306
2252
|
//#endregion
|
|
2307
2253
|
//#region src/internal/function/memoize.ts
|
|
2308
|
-
const MEMOIZED_PROPERTY = "$memoized";
|
|
2309
2254
|
function Memoized(callback, options) {
|
|
2310
|
-
|
|
2255
|
+
this[MEMOIZED_SYMBOL] = {
|
|
2311
2256
|
options,
|
|
2312
2257
|
cache: new SizedMap(options.cacheSize),
|
|
2313
2258
|
getter: void 0
|
|
2314
|
-
}
|
|
2259
|
+
};
|
|
2315
2260
|
this[MEMOIZED_SYMBOL].getter = createGetter(this[MEMOIZED_SYMBOL], callback);
|
|
2316
|
-
Object.defineProperties(this, {
|
|
2317
|
-
maximum: {
|
|
2318
|
-
enumerable: true,
|
|
2319
|
-
get: () => this[MEMOIZED_SYMBOL].cache.maximum
|
|
2320
|
-
},
|
|
2321
|
-
size: {
|
|
2322
|
-
enumerable: true,
|
|
2323
|
-
get: () => this[MEMOIZED_SYMBOL].cache.size
|
|
2324
|
-
}
|
|
2325
|
-
});
|
|
2326
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;
|
|
2327
2267
|
Object.defineProperties(Memoized.prototype, {
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2268
|
+
maximum: {
|
|
2269
|
+
enumerable: true,
|
|
2270
|
+
get: getMemoizedMaximum
|
|
2271
|
+
},
|
|
2272
|
+
size: {
|
|
2273
|
+
enumerable: true,
|
|
2274
|
+
get: getMemoizedSize
|
|
2275
|
+
}
|
|
2334
2276
|
});
|
|
2335
2277
|
function clearMemoized() {
|
|
2336
2278
|
this[MEMOIZED_SYMBOL].cache.clear();
|
|
@@ -2354,6 +2296,12 @@ function createMemoizationOptions(input) {
|
|
|
2354
2296
|
cacheSize: getNumberOrDefault(cacheSize, MEMOIZED_CACHE_SIZE_DEFAULT)
|
|
2355
2297
|
};
|
|
2356
2298
|
}
|
|
2299
|
+
function getMemoizedMaximum() {
|
|
2300
|
+
return this[MEMOIZED_SYMBOL].cache.maximum;
|
|
2301
|
+
}
|
|
2302
|
+
function getMemoizedSize() {
|
|
2303
|
+
return this[MEMOIZED_SYMBOL].cache.size;
|
|
2304
|
+
}
|
|
2357
2305
|
function getMemoizedValue(key) {
|
|
2358
2306
|
return this[MEMOIZED_SYMBOL].cache.get(key);
|
|
2359
2307
|
}
|
|
@@ -2377,7 +2325,7 @@ function runMemoized(...parameters) {
|
|
|
2377
2325
|
const MEMOIZED_CACHE_SIZE_DEFAULT = 1024;
|
|
2378
2326
|
const MEMOIZED_CALLBACK = "Memoized requires a callback function";
|
|
2379
2327
|
const MEMOIZED_KEY_SEPARATOR = "_";
|
|
2380
|
-
const MEMOIZED_SYMBOL = Symbol(
|
|
2328
|
+
const MEMOIZED_SYMBOL = Symbol("memoized");
|
|
2381
2329
|
//#endregion
|
|
2382
2330
|
//#region src/internal/string/case.ts
|
|
2383
2331
|
/**
|
|
@@ -2516,13 +2464,11 @@ let memoizedUpperCase;
|
|
|
2516
2464
|
//#endregion
|
|
2517
2465
|
//#region src/internal/value/equal.ts
|
|
2518
2466
|
function Equalizer(options) {
|
|
2519
|
-
|
|
2467
|
+
this[EQUAL_SYMBOL] = options;
|
|
2520
2468
|
}
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
register: { value: registerEqualizer }
|
|
2525
|
-
});
|
|
2469
|
+
Equalizer.prototype.compare = compare$1;
|
|
2470
|
+
Equalizer.prototype.deregister = deregisterEqualizer;
|
|
2471
|
+
Equalizer.prototype.register = registerEqualizer;
|
|
2526
2472
|
function compare$1(first, second) {
|
|
2527
2473
|
return equalValue(first, second, this[EQUAL_SYMBOL]);
|
|
2528
2474
|
}
|
|
@@ -2695,12 +2641,6 @@ equal.deregister = deregisterEqualizer;
|
|
|
2695
2641
|
equal.handler = equalHandler;
|
|
2696
2642
|
equal.initialize = initializeEqualizer;
|
|
2697
2643
|
equal.register = registerEqualizer;
|
|
2698
|
-
Object.defineProperties(equal, {
|
|
2699
|
-
deregister: { value: deregisterEqualizer },
|
|
2700
|
-
handler: { value: equalHandler },
|
|
2701
|
-
initialize: { value: initializeEqualizer },
|
|
2702
|
-
register: { value: registerEqualizer }
|
|
2703
|
-
});
|
|
2704
2644
|
//#endregion
|
|
2705
2645
|
//#region src/internal/value/get.ts
|
|
2706
2646
|
function getValue(data, path, ignoreCase) {
|
|
@@ -2725,7 +2665,7 @@ function setValue(data, path, value, ignoreCase) {
|
|
|
2725
2665
|
handleValue(target, currentPath, value, false, shouldIgnoreCase);
|
|
2726
2666
|
break;
|
|
2727
2667
|
}
|
|
2728
|
-
let next = handleValue(target, currentPath, null, true, shouldIgnoreCase)
|
|
2668
|
+
let next = unwrap(handleValue(target, currentPath, null, true, shouldIgnoreCase), void 0);
|
|
2729
2669
|
if (typeof next !== "object" || next === null) {
|
|
2730
2670
|
const nextPath = paths[index + 1];
|
|
2731
2671
|
if (SET_EXPRESSION_INDEX.test(nextPath)) next = Array.from({ length: Number(nextPath) + 1 }, () => void 0);
|
|
@@ -2738,7 +2678,7 @@ function setValue(data, path, value, ignoreCase) {
|
|
|
2738
2678
|
}
|
|
2739
2679
|
const SET_EXPRESSION_INDEX = /^\d+$/;
|
|
2740
2680
|
//#endregion
|
|
2741
|
-
//#region src/internal/
|
|
2681
|
+
//#region src/internal/aborter.ts
|
|
2742
2682
|
function createAborter(value, onAbort) {
|
|
2743
2683
|
if (!(value instanceof AbortSignal)) return;
|
|
2744
2684
|
value.addEventListener(ABORT_EVENT, onAbort, ABORT_OPTIONS);
|
|
@@ -2805,7 +2745,7 @@ function createPromiseOptions(input) {
|
|
|
2805
2745
|
signal: input,
|
|
2806
2746
|
time: 0
|
|
2807
2747
|
};
|
|
2808
|
-
const options =
|
|
2748
|
+
const options = isPlainObject(input) ? input : {};
|
|
2809
2749
|
return {
|
|
2810
2750
|
signal: options.signal instanceof AbortSignal ? options.signal : void 0,
|
|
2811
2751
|
time: getNumberOrDefault(options.time, 0)
|
|
@@ -2817,7 +2757,7 @@ function createPromisesOptions(input) {
|
|
|
2817
2757
|
signal: input,
|
|
2818
2758
|
strategy: PROMISE_STRATEGY_DEFAULT
|
|
2819
2759
|
};
|
|
2820
|
-
const options =
|
|
2760
|
+
const options = isPlainObject(input) ? input : {};
|
|
2821
2761
|
return {
|
|
2822
2762
|
signal: options.signal instanceof AbortSignal ? options.signal : void 0,
|
|
2823
2763
|
strategy: getStrategyOrDefault(options.strategy)
|
|
@@ -2856,7 +2796,7 @@ function isRejected(value) {
|
|
|
2856
2796
|
return isType(value, PROMISE_TYPE_REJECTED);
|
|
2857
2797
|
}
|
|
2858
2798
|
function isType(value, type) {
|
|
2859
|
-
return
|
|
2799
|
+
return isPlainObject(value) && "status" in value && value.status === type;
|
|
2860
2800
|
}
|
|
2861
2801
|
//#endregion
|
|
2862
2802
|
//#region src/result/misc.ts
|
|
@@ -3026,7 +2966,6 @@ async function resultPromises(items, signal) {
|
|
|
3026
2966
|
return promises(items, signal).then(getResultsFromPromises);
|
|
3027
2967
|
}
|
|
3028
2968
|
promises.result = resultPromises;
|
|
3029
|
-
Object.defineProperty(promises, "result", { value: resultPromises });
|
|
3030
2969
|
//#endregion
|
|
3031
2970
|
//#region src/result/index.ts
|
|
3032
2971
|
async function asyncAttempt(value, err) {
|
|
@@ -3046,7 +2985,6 @@ function attempt(callback, err) {
|
|
|
3046
2985
|
}
|
|
3047
2986
|
}
|
|
3048
2987
|
attempt.async = asyncAttempt;
|
|
3049
|
-
Object.defineProperty(attempt, "async", { value: asyncAttempt });
|
|
3050
2988
|
//#endregion
|
|
3051
2989
|
//#region src/result/match.ts
|
|
3052
2990
|
async function asyncMatchResult(result, first, error) {
|
|
@@ -3072,7 +3010,6 @@ function matchResult(result, first, error) {
|
|
|
3072
3010
|
}
|
|
3073
3011
|
const MATCH_MESSAGE = "`result.match` expected a Result or a function that returns a Result";
|
|
3074
3012
|
matchResult.async = asyncMatchResult;
|
|
3075
|
-
Object.defineProperty(matchResult, "async", { value: asyncMatchResult });
|
|
3076
3013
|
//#endregion
|
|
3077
3014
|
//#region src/result/work/flow.ts
|
|
3078
3015
|
function attemptAsyncFlow(...fns) {
|
|
@@ -3096,7 +3033,6 @@ function attemptFlow(...fns) {
|
|
|
3096
3033
|
});
|
|
3097
3034
|
}
|
|
3098
3035
|
attemptFlow.async = attemptAsyncFlow;
|
|
3099
|
-
Object.defineProperty(attemptFlow, "async", { value: attemptAsyncFlow });
|
|
3100
3036
|
//#endregion
|
|
3101
3037
|
//#region src/result/work/pipe.ts
|
|
3102
3038
|
async function attemptAsyncPipe(initial, first, ...seconds) {
|
|
@@ -3116,7 +3052,6 @@ function attemptPipe(initial, first, ...seconds) {
|
|
|
3116
3052
|
});
|
|
3117
3053
|
}
|
|
3118
3054
|
attemptPipe.async = attemptAsyncPipe;
|
|
3119
|
-
Object.defineProperty(attemptPipe, "async", { value: attemptAsyncPipe });
|
|
3120
3055
|
//#endregion
|
|
3121
3056
|
//#region src/string/match.ts
|
|
3122
3057
|
/**
|
|
@@ -3169,27 +3104,24 @@ const matchMemoizers = {};
|
|
|
3169
3104
|
const FUZZY_PROPERTY = "$fuzzy";
|
|
3170
3105
|
const FUZZY_SYMBOL = Symbol(FUZZY_PROPERTY);
|
|
3171
3106
|
function Fuzzy(state) {
|
|
3172
|
-
|
|
3107
|
+
this[FUZZY_SYMBOL] = state;
|
|
3173
3108
|
}
|
|
3109
|
+
Fuzzy.prototype[FUZZY_PROPERTY] = true;
|
|
3110
|
+
Fuzzy.prototype.search = search;
|
|
3174
3111
|
Object.defineProperties(Fuzzy.prototype, {
|
|
3175
|
-
[FUZZY_PROPERTY]: { value: true },
|
|
3176
3112
|
items: {
|
|
3177
3113
|
enumerable: true,
|
|
3178
|
-
get
|
|
3179
|
-
|
|
3180
|
-
},
|
|
3181
|
-
set(value) {
|
|
3182
|
-
setItems(this[FUZZY_SYMBOL], value);
|
|
3183
|
-
}
|
|
3114
|
+
get: getFuzzyItems,
|
|
3115
|
+
set: setFuzzyItems
|
|
3184
3116
|
},
|
|
3185
|
-
search: { value: search },
|
|
3186
3117
|
strings: {
|
|
3187
3118
|
enumerable: true,
|
|
3188
|
-
get
|
|
3189
|
-
return this[FUZZY_SYMBOL].strings.slice();
|
|
3190
|
-
}
|
|
3119
|
+
get: getFuzzyStrings
|
|
3191
3120
|
}
|
|
3192
3121
|
});
|
|
3122
|
+
function createFuzzyItems(items) {
|
|
3123
|
+
return items.sort((first, second) => first.haystack.localeCompare(second.haystack)).map(({ item }) => item);
|
|
3124
|
+
}
|
|
3193
3125
|
function createFuzzyOptions(input, state) {
|
|
3194
3126
|
const options = isPlainObject(input) ? input : {};
|
|
3195
3127
|
const limit = typeof input === "number" ? input : options.limit;
|
|
@@ -3238,8 +3170,11 @@ function getHandler(input) {
|
|
|
3238
3170
|
throw new TypeError(FUZZY_MESSAGE_HANDLER);
|
|
3239
3171
|
}
|
|
3240
3172
|
}
|
|
3241
|
-
function getFuzzyItems(
|
|
3242
|
-
return items.
|
|
3173
|
+
function getFuzzyItems() {
|
|
3174
|
+
return this[FUZZY_SYMBOL].items.slice();
|
|
3175
|
+
}
|
|
3176
|
+
function getFuzzyStrings() {
|
|
3177
|
+
return this[FUZZY_SYMBOL].strings.slice();
|
|
3243
3178
|
}
|
|
3244
3179
|
function getScore(haystack, needle) {
|
|
3245
3180
|
if (!isSubsequence(haystack, needle)) return -1;
|
|
@@ -3334,16 +3269,17 @@ function search(input, option) {
|
|
|
3334
3269
|
for (let index = 0; index < length; index += 1) {
|
|
3335
3270
|
const key = keys[index];
|
|
3336
3271
|
if (maxScore - key > options.tolerance) break;
|
|
3337
|
-
similar.push(...
|
|
3272
|
+
similar.push(...createFuzzyItems(scored[key]));
|
|
3338
3273
|
}
|
|
3339
3274
|
}
|
|
3340
|
-
result.exact =
|
|
3275
|
+
result.exact = createFuzzyItems(options.limit == null ? exact : exact.slice(0, options.limit));
|
|
3341
3276
|
if (options.limit == null) result.similar = similar;
|
|
3342
3277
|
else result.similar = similar.slice(0, options.limit - result.exact.length);
|
|
3343
3278
|
return result;
|
|
3344
3279
|
}
|
|
3345
|
-
function
|
|
3280
|
+
function setFuzzyItems(value) {
|
|
3346
3281
|
if (!Array.isArray(value)) throw new TypeError(FUZZY_MESSAGE_ARRAY);
|
|
3282
|
+
const state = this[FUZZY_SYMBOL];
|
|
3347
3283
|
state.items = value.slice();
|
|
3348
3284
|
state.strings = value.map(state.handler);
|
|
3349
3285
|
}
|
|
@@ -3353,10 +3289,6 @@ const FUZZY_MESSAGE_HANDLER = "Fuzzy requires a key or function to stringify ite
|
|
|
3353
3289
|
const FUZZY_PROXIMITY_THRESHOLD = 5;
|
|
3354
3290
|
fuzzy.is = isFuzzy;
|
|
3355
3291
|
fuzzy.match = fuzzyMatch;
|
|
3356
|
-
Object.defineProperties(fuzzy, {
|
|
3357
|
-
is: { value: isFuzzy },
|
|
3358
|
-
match: { value: fuzzyMatch }
|
|
3359
|
-
});
|
|
3360
3292
|
//#endregion
|
|
3361
3293
|
//#region src/string/index.ts
|
|
3362
3294
|
function dedent(value, ...values) {
|
|
@@ -3454,9 +3386,9 @@ const STRING_ZERO = "0";
|
|
|
3454
3386
|
//#endregion
|
|
3455
3387
|
//#region src/string/normalize.ts
|
|
3456
3388
|
function Normalizer(options) {
|
|
3457
|
-
|
|
3389
|
+
this[NORMALIZE_SYMBOL] = options;
|
|
3458
3390
|
}
|
|
3459
|
-
|
|
3391
|
+
Normalizer.prototype.normalize = normalizeString;
|
|
3460
3392
|
function createNormalizeOptions(input) {
|
|
3461
3393
|
const options = isPlainObject(input) ? input : {};
|
|
3462
3394
|
return {
|
|
@@ -3559,13 +3491,12 @@ const NORMALIZE_WHITESPACE_PATTERN = /\s+/g;
|
|
|
3559
3491
|
const NORMALIZE_WHITESPACE_REPLACEMENT = " ";
|
|
3560
3492
|
let deburrMemoizer;
|
|
3561
3493
|
normalize.initialize = initializeNormalizer;
|
|
3562
|
-
Object.defineProperty(normalize, "initialize", { value: initializeNormalizer });
|
|
3563
3494
|
//#endregion
|
|
3564
3495
|
//#region src/string/template.ts
|
|
3565
3496
|
function Templater(options) {
|
|
3566
|
-
|
|
3497
|
+
this[TEMPLATE_SYMBOL] = options;
|
|
3567
3498
|
}
|
|
3568
|
-
|
|
3499
|
+
Templater.prototype.render = render;
|
|
3569
3500
|
function createTemplateOptions(input) {
|
|
3570
3501
|
const options = isPlainObject(input) ? input : {};
|
|
3571
3502
|
return {
|
|
@@ -3614,18 +3545,15 @@ function template(value, ...parameters) {
|
|
|
3614
3545
|
const TEMPLATE_EXPRESSION_VARIABLE = /{{([\s\S]+?)}}/g;
|
|
3615
3546
|
const TEMPLATE_SYMBOL = Symbol("template");
|
|
3616
3547
|
template.initialize = initializeTemplater;
|
|
3617
|
-
Object.defineProperty(template, "initialize", { value: initializeTemplater });
|
|
3618
3548
|
//#endregion
|
|
3619
3549
|
//#region src/value/clone.ts
|
|
3620
3550
|
const CLONE_NAME = "clone";
|
|
3621
3551
|
function Cloner(options) {
|
|
3622
|
-
|
|
3552
|
+
this[CLONE_SYMBOL] = options;
|
|
3623
3553
|
}
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
register: { value: registerCloner }
|
|
3628
|
-
});
|
|
3554
|
+
Cloner.prototype.clone = cloneFromCloner;
|
|
3555
|
+
Cloner.prototype.deregister = deregisterCloner;
|
|
3556
|
+
Cloner.prototype.register = registerCloner;
|
|
3629
3557
|
function clone(value, options) {
|
|
3630
3558
|
return cloneAny(value, { copy: false }, 0, options);
|
|
3631
3559
|
}
|
|
@@ -3809,12 +3737,6 @@ clone.deregister = deregisterCloner;
|
|
|
3809
3737
|
clone.handlers = cloneHandler;
|
|
3810
3738
|
clone.initialize = initializeCloner;
|
|
3811
3739
|
clone.register = registerCloner;
|
|
3812
|
-
Object.defineProperties(clone, {
|
|
3813
|
-
deregister: { value: deregisterCloner },
|
|
3814
|
-
handler: { value: cloneHandler },
|
|
3815
|
-
initialize: { value: initializeCloner },
|
|
3816
|
-
register: { value: registerCloner }
|
|
3817
|
-
});
|
|
3818
3740
|
//#endregion
|
|
3819
3741
|
//#region src/value/collection.ts
|
|
3820
3742
|
function inMap(map, value, key) {
|
|
@@ -4020,14 +3942,10 @@ function isFrozen(value) {
|
|
|
4020
3942
|
const frozenValues = /* @__PURE__ */ new WeakSet();
|
|
4021
3943
|
freeze.flat = flatFreeze;
|
|
4022
3944
|
freeze.is = isFrozen;
|
|
4023
|
-
Object.defineProperties(freeze, {
|
|
4024
|
-
flat: { value: flatFreeze },
|
|
4025
|
-
is: { value: isFrozen }
|
|
4026
|
-
});
|
|
4027
3945
|
//#endregion
|
|
4028
3946
|
//#region src/internal/value/partial.ts
|
|
4029
3947
|
function partial(value, providedKeys, omit) {
|
|
4030
|
-
if (
|
|
3948
|
+
if (!isPlainObject(value)) return {};
|
|
4031
3949
|
const keys = omit ? Object.keys(value) : Array.isArray(providedKeys) ? providedKeys : [];
|
|
4032
3950
|
const { length } = keys;
|
|
4033
3951
|
if (length === 0) return omit ? value : {};
|
|
@@ -4157,16 +4075,16 @@ function unsmush(value) {
|
|
|
4157
4075
|
//#endregion
|
|
4158
4076
|
//#region src/value/merge.ts
|
|
4159
4077
|
function Assigner(options) {
|
|
4160
|
-
|
|
4078
|
+
this[MERGE_SYMBOL_ASSIGN] = {
|
|
4161
4079
|
...options,
|
|
4162
4080
|
assignValues: true
|
|
4163
|
-
}
|
|
4081
|
+
};
|
|
4164
4082
|
}
|
|
4165
|
-
|
|
4083
|
+
Assigner.prototype.assign = assignFromAssigner;
|
|
4166
4084
|
function Merger(options) {
|
|
4167
|
-
|
|
4085
|
+
this[MERGE_SYMBOL_MERGE] = options;
|
|
4168
4086
|
}
|
|
4169
|
-
|
|
4087
|
+
Merger.prototype.merge = mergeFromMerger;
|
|
4170
4088
|
/**
|
|
4171
4089
|
* Assign values from one or more objects to the first one
|
|
4172
4090
|
*
|
|
@@ -4270,12 +4188,10 @@ const MERGE_SYMBOL_ASSIGN = Symbol("assign");
|
|
|
4270
4188
|
const MERGE_SYMBOL_MERGE = Symbol("merge");
|
|
4271
4189
|
assign.initialize = initializeAssigner;
|
|
4272
4190
|
merge.initialize = initializeMerger;
|
|
4273
|
-
Object.defineProperty(assign, "initialize", { value: initializeAssigner });
|
|
4274
|
-
Object.defineProperty(merge, "initialize", { value: initializeMerger });
|
|
4275
4191
|
//#endregion
|
|
4276
4192
|
//#region src/value/transform.ts
|
|
4277
4193
|
function Transformer(transformer) {
|
|
4278
|
-
|
|
4194
|
+
this[TRANSFORM_SYMBOL] = transformer;
|
|
4279
4195
|
}
|
|
4280
4196
|
Object.defineProperties(Transformer.prototype, { transform: { value: transformValue } });
|
|
4281
4197
|
function getTransformHandler(input) {
|
|
@@ -4313,47 +4229,38 @@ function transformValue(value) {
|
|
|
4313
4229
|
}
|
|
4314
4230
|
const TRANSFORM_SYMBOL = Symbol("transform");
|
|
4315
4231
|
transform.initialize = initializeTransformer;
|
|
4316
|
-
Object.defineProperty(transform, "initialize", { value: initializeTransformer });
|
|
4317
4232
|
//#endregion
|
|
4318
4233
|
//#region src/internal/subscription.ts
|
|
4319
4234
|
const SUBSCRIPTION_NAME = "subscription";
|
|
4320
4235
|
const SUBSCRIPTION_PROPERTY = "$subscription";
|
|
4321
4236
|
const SUBSCRIPTION_STORE = "subscriptions";
|
|
4322
4237
|
function Subscription(state, property, parameters) {
|
|
4323
|
-
|
|
4238
|
+
this[SUBSCRIPTION_SYMBOL] = state;
|
|
4239
|
+
this[property.key] = property.value;
|
|
4324
4240
|
state.aborter = createAborter(parameters.signal, () => this.unsubscribe(subscriptions, this, state));
|
|
4325
|
-
Object.defineProperties(this, {
|
|
4326
|
-
[property.key]: { value: property.value },
|
|
4327
|
-
active: {
|
|
4328
|
-
enumerable: true,
|
|
4329
|
-
get: () => (state.parameters?.isActive?.() ?? true) && state.active
|
|
4330
|
-
}
|
|
4331
|
-
});
|
|
4332
4241
|
addSubscription(this);
|
|
4333
4242
|
}
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4243
|
+
Subscription.prototype[SUBSCRIPTION_PROPERTY] = SUBSCRIPTION_NAME;
|
|
4244
|
+
Subscription.prototype.unsubscribe = removeSubscription;
|
|
4245
|
+
Object.defineProperty(Subscription.prototype, "active", {
|
|
4246
|
+
enumerable: true,
|
|
4247
|
+
get: getSubscriptionActive
|
|
4337
4248
|
});
|
|
4338
4249
|
function Subscriptions(parameters) {
|
|
4339
4250
|
const { keys, property } = createSubscriptionsParameters(parameters);
|
|
4340
|
-
|
|
4251
|
+
this[SUBSCRIPTION_SYMBOL] = createSubscriptionsState(property, keys);
|
|
4341
4252
|
}
|
|
4253
|
+
Subscriptions.prototype[SUBSCRIPTION_PROPERTY] = SUBSCRIPTION_STORE;
|
|
4254
|
+
Subscriptions.prototype.clear = clearSubscriptions;
|
|
4255
|
+
Subscriptions.prototype.create = createSubscription;
|
|
4342
4256
|
Object.defineProperties(Subscriptions.prototype, {
|
|
4343
|
-
[SUBSCRIPTION_PROPERTY]: { value: SUBSCRIPTION_STORE },
|
|
4344
|
-
clear: { value: clearSubscriptions },
|
|
4345
|
-
create: { value: createSubscription },
|
|
4346
4257
|
items: {
|
|
4347
4258
|
enumerable: true,
|
|
4348
|
-
get
|
|
4349
|
-
return this[SUBSCRIPTION_SYMBOL].items;
|
|
4350
|
-
}
|
|
4259
|
+
get: getSubscriptionsItems
|
|
4351
4260
|
},
|
|
4352
4261
|
values: {
|
|
4353
4262
|
enumerable: true,
|
|
4354
|
-
get
|
|
4355
|
-
return this[SUBSCRIPTION_SYMBOL].values;
|
|
4356
|
-
}
|
|
4263
|
+
get: getSubscriptionsValues
|
|
4357
4264
|
}
|
|
4358
4265
|
});
|
|
4359
4266
|
function addSubscription(instance) {
|
|
@@ -4416,6 +4323,16 @@ function getExistingSubscription(subscriptions, state) {
|
|
|
4416
4323
|
const { parameters } = state;
|
|
4417
4324
|
return isKey(parameters.key) ? values.from.keyed?.get(parameters.key)?.get(parameters.value) : values.from.any.get(parameters.value);
|
|
4418
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
|
+
}
|
|
4419
4336
|
function createSubscriptionParameters(input) {
|
|
4420
4337
|
const values = isPlainObject(input) ? input : {};
|
|
4421
4338
|
if (values.value == null) throw new Error(SUBSCRIPTION_INVALID_VALUE);
|
|
@@ -4534,54 +4451,43 @@ const BEACON_PROPERTY = "$beacon";
|
|
|
4534
4451
|
const BEACON_NAME = "beacon";
|
|
4535
4452
|
const BEACON_OBSERVABLE = "observable";
|
|
4536
4453
|
function Beacon(value, options) {
|
|
4537
|
-
|
|
4454
|
+
this[BEACON_SYMBOL] = {
|
|
4538
4455
|
value,
|
|
4539
4456
|
active: true,
|
|
4540
4457
|
options: createBeaconOptions(options)
|
|
4541
|
-
}
|
|
4458
|
+
};
|
|
4542
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;
|
|
4543
4465
|
Object.defineProperties(Beacon.prototype, {
|
|
4544
|
-
[BEACON_PROPERTY]: { value: BEACON_NAME },
|
|
4545
4466
|
active: {
|
|
4546
4467
|
enumerable: true,
|
|
4547
|
-
get
|
|
4548
|
-
return this[BEACON_SYMBOL].active;
|
|
4549
|
-
}
|
|
4468
|
+
get: getBeaconActive
|
|
4550
4469
|
},
|
|
4551
|
-
deactivate: { value: deactivateBeacon },
|
|
4552
|
-
emit: { value: emitBeaconValue },
|
|
4553
|
-
error: { value: emitBeaconError },
|
|
4554
|
-
finish: { value: finishBeacon },
|
|
4555
4470
|
observable: {
|
|
4556
4471
|
enumerable: true,
|
|
4557
|
-
get
|
|
4558
|
-
return getObservable(this[BEACON_SYMBOL]);
|
|
4559
|
-
}
|
|
4472
|
+
get: getBeaconObservable
|
|
4560
4473
|
},
|
|
4561
4474
|
value: {
|
|
4562
4475
|
enumerable: true,
|
|
4563
|
-
get
|
|
4564
|
-
return this[BEACON_SYMBOL].value;
|
|
4565
|
-
}
|
|
4476
|
+
get: getBeaconValue
|
|
4566
4477
|
}
|
|
4567
4478
|
});
|
|
4568
4479
|
function Observable(beacon) {
|
|
4569
|
-
|
|
4480
|
+
this[BEACON_SYMBOL] = {
|
|
4570
4481
|
beacon,
|
|
4571
4482
|
active: beacon.active
|
|
4572
|
-
}
|
|
4483
|
+
};
|
|
4573
4484
|
}
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
return state.beacon.active && state.active;
|
|
4581
|
-
}
|
|
4582
|
-
},
|
|
4583
|
-
deactivate: { value: deactiveateObservable },
|
|
4584
|
-
subscribe: { value: subscribeToObservable }
|
|
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
|
|
4585
4491
|
});
|
|
4586
4492
|
/**
|
|
4587
4493
|
* Create a new beacon
|
|
@@ -4606,8 +4512,7 @@ function closeBeacon(state, emit) {
|
|
|
4606
4512
|
}
|
|
4607
4513
|
function createBeaconOptions(input) {
|
|
4608
4514
|
const options = isPlainObject(input) ? input : {};
|
|
4609
|
-
|
|
4610
|
-
return options;
|
|
4515
|
+
return { equal: typeof options.equal === "function" ? options.equal : Object.is };
|
|
4611
4516
|
}
|
|
4612
4517
|
function createObserver(first, second, third) {
|
|
4613
4518
|
let observer = { next: noop };
|
|
@@ -4617,9 +4522,10 @@ function createObserver(first, second, third) {
|
|
|
4617
4522
|
complete: getObservableCallback(third)
|
|
4618
4523
|
};
|
|
4619
4524
|
else if (typeof first === "object") {
|
|
4620
|
-
|
|
4621
|
-
observer.
|
|
4622
|
-
observer.
|
|
4525
|
+
const object = first;
|
|
4526
|
+
observer.complete = getObservableCallback(object?.complete);
|
|
4527
|
+
observer.error = getObservableCallback(object?.error);
|
|
4528
|
+
observer.next = getObservableCallback(object?.next);
|
|
4623
4529
|
}
|
|
4624
4530
|
return observer;
|
|
4625
4531
|
}
|
|
@@ -4638,11 +4544,22 @@ function emitBeaconValue(value, finish) {
|
|
|
4638
4544
|
function finishBeacon() {
|
|
4639
4545
|
closeBeacon(this[BEACON_SYMBOL], true);
|
|
4640
4546
|
}
|
|
4641
|
-
function
|
|
4547
|
+
function getBeaconActive() {
|
|
4548
|
+
return this[BEACON_SYMBOL].active;
|
|
4549
|
+
}
|
|
4550
|
+
function getBeaconObservable() {
|
|
4551
|
+
const state = this[BEACON_SYMBOL];
|
|
4642
4552
|
if (!state.active) throw new Error(BEACON_MESSAGE_RETRIEVE);
|
|
4643
4553
|
state.observable ??= new Observable(state);
|
|
4644
4554
|
return state.observable;
|
|
4645
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
|
+
}
|
|
4646
4563
|
function getObservableCallback(value) {
|
|
4647
4564
|
return typeof value === "function" ? value : noop;
|
|
4648
4565
|
}
|
|
@@ -4656,7 +4573,7 @@ function isBeacon(value) {
|
|
|
4656
4573
|
return isBeaconInstance(BEACON_NAME, value);
|
|
4657
4574
|
}
|
|
4658
4575
|
function isBeaconInstance(name, value) {
|
|
4659
|
-
return typeof value === "object" && value !== null && value[BEACON_PROPERTY] === name;
|
|
4576
|
+
return typeof value === "object" && value !== null && BEACON_PROPERTY in value && value[BEACON_PROPERTY] === name;
|
|
4660
4577
|
}
|
|
4661
4578
|
/**
|
|
4662
4579
|
* Is the value a beacon subscription?
|
|
@@ -4718,23 +4635,19 @@ function Events(herald, state) {
|
|
|
4718
4635
|
}
|
|
4719
4636
|
Events.prototype[HERALD_PROPERTY] = HERALD_NAME_EVENTS;
|
|
4720
4637
|
function Herald(state) {
|
|
4721
|
-
|
|
4638
|
+
this[HERALD_SYMBOL] = {
|
|
4722
4639
|
state,
|
|
4723
4640
|
events: new Events(this, state)
|
|
4724
|
-
}
|
|
4641
|
+
};
|
|
4725
4642
|
}
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
}
|
|
4735
|
-
},
|
|
4736
|
-
observed: { value: eventIsObserved },
|
|
4737
|
-
subscribe: { value: subscribeToHerald }
|
|
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
|
|
4738
4651
|
});
|
|
4739
4652
|
function clearHerald() {
|
|
4740
4653
|
this[HERALD_SYMBOL].state.store.clear();
|
|
@@ -4771,6 +4684,9 @@ function emitForHerald(event, ...parameters) {
|
|
|
4771
4684
|
function eventIsObserved(event) {
|
|
4772
4685
|
return (this[HERALD_SYMBOL].state.store.items.keyed?.get(event)?.size ?? 0) > 0;
|
|
4773
4686
|
}
|
|
4687
|
+
function getHeraldEvents() {
|
|
4688
|
+
return this[HERALD_SYMBOL].events;
|
|
4689
|
+
}
|
|
4774
4690
|
/**
|
|
4775
4691
|
* Create a _Herald_ for announcing named events
|
|
4776
4692
|
*
|
|
@@ -4809,7 +4725,7 @@ function isHeraldInstance(name, value) {
|
|
|
4809
4725
|
* @returns `true` if the value is a herald subscription, otherwise `false`
|
|
4810
4726
|
*/
|
|
4811
4727
|
function isHeraldSubscription(value) {
|
|
4812
|
-
return isSubscription(value) && value[HERALD_PROPERTY] === "subscription";
|
|
4728
|
+
return isSubscription(value) && HERALD_PROPERTY in value && value[HERALD_PROPERTY] === "subscription";
|
|
4813
4729
|
}
|
|
4814
4730
|
function subscribeToHerald(key, callback, signal) {
|
|
4815
4731
|
const { state } = this[HERALD_SYMBOL];
|
|
@@ -4969,6 +4885,9 @@ function getAlpha(value, hex) {
|
|
|
4969
4885
|
};
|
|
4970
4886
|
return getAlphaFromValue(Number.parseFloat(value));
|
|
4971
4887
|
}
|
|
4888
|
+
function getColorAlpha() {
|
|
4889
|
+
return this[COLOR_SYMBOL].values.alpha.value;
|
|
4890
|
+
}
|
|
4972
4891
|
function getAlphaHexadecimal(value) {
|
|
4973
4892
|
if (value === COLOR_ALPHA.noneValue) return COLOR_ALPHA.noneHex;
|
|
4974
4893
|
if (value === COLOR_MAX.percent) return COLOR_ALPHA.fullHexLong;
|
|
@@ -4985,6 +4904,9 @@ function getAlphaValue(original) {
|
|
|
4985
4904
|
if (Number.isNaN(original)) return COLOR_MAX.percent;
|
|
4986
4905
|
return clamp(original, COLOR_ALPHA.noneValue, COLOR_MAX.percent);
|
|
4987
4906
|
}
|
|
4907
|
+
function setColorAlpha(value) {
|
|
4908
|
+
if (typeof value === "number" && !Number.isNaN(value)) this[COLOR_SYMBOL].values.alpha = getAlpha(value, false);
|
|
4909
|
+
}
|
|
4988
4910
|
//#endregion
|
|
4989
4911
|
//#region src/color/misc/get.ts
|
|
4990
4912
|
function getClampedValue(value, minimum, maximum, rounding) {
|
|
@@ -5144,11 +5066,12 @@ function isBytey(value) {
|
|
|
5144
5066
|
function isColor(value) {
|
|
5145
5067
|
return typeof value === "object" && value !== null && "$color" in value && value["$color"] === "color";
|
|
5146
5068
|
}
|
|
5147
|
-
function isColorValue(
|
|
5148
|
-
if (typeof
|
|
5149
|
-
const keys = Object.keys(
|
|
5069
|
+
function isColorValue(value, properties) {
|
|
5070
|
+
if (typeof value !== "object" || value === null) return false;
|
|
5071
|
+
const keys = Object.keys(value);
|
|
5150
5072
|
const { length } = keys;
|
|
5151
5073
|
if (length !== properties.length) return false;
|
|
5074
|
+
const obj = value;
|
|
5152
5075
|
for (let index = 0; index < length; index += 1) {
|
|
5153
5076
|
const key = keys[index];
|
|
5154
5077
|
if (!(properties.includes(key) && validators[key](obj[key]))) return false;
|
|
@@ -5276,7 +5199,7 @@ function convertRgbToHex(rgb, alpha) {
|
|
|
5276
5199
|
return `${hex}${a}`;
|
|
5277
5200
|
}
|
|
5278
5201
|
function convertRgbToHsla(value) {
|
|
5279
|
-
const values =
|
|
5202
|
+
const values = getRgbCalculationValues(isRgbLike(value) ? getRgbValues(value) : { ...COLOR_DEFAULTS.rgb });
|
|
5280
5203
|
const { delta, max, min } = values;
|
|
5281
5204
|
const lightness = (min + max) / 2;
|
|
5282
5205
|
let hue = 0;
|
|
@@ -5294,7 +5217,7 @@ function convertRgbToHsla(value) {
|
|
|
5294
5217
|
};
|
|
5295
5218
|
}
|
|
5296
5219
|
function convertRgbToHwba(value) {
|
|
5297
|
-
const values =
|
|
5220
|
+
const values = getRgbCalculationValues(isRgbLike(value) ? getRgbValues(value) : { ...COLOR_DEFAULTS.rgb });
|
|
5298
5221
|
const { delta, max, min } = values;
|
|
5299
5222
|
let hue = 0;
|
|
5300
5223
|
if (delta !== 0) {
|
|
@@ -5320,22 +5243,7 @@ function getColorFromRgb(state, type) {
|
|
|
5320
5243
|
}
|
|
5321
5244
|
return state[type];
|
|
5322
5245
|
}
|
|
5323
|
-
function
|
|
5324
|
-
const { blue, delta, green, max, red } = values;
|
|
5325
|
-
switch (max) {
|
|
5326
|
-
case blue: return (red - green) / delta + 4;
|
|
5327
|
-
case green: return (blue - red) / delta + 2;
|
|
5328
|
-
default: return (green - blue) / delta + (green < blue ? 6 : 0);
|
|
5329
|
-
}
|
|
5330
|
-
}
|
|
5331
|
-
function getRgbValue(value) {
|
|
5332
|
-
return {
|
|
5333
|
-
blue: getHexValue(value.blue),
|
|
5334
|
-
green: getHexValue(value.green),
|
|
5335
|
-
red: getHexValue(value.red)
|
|
5336
|
-
};
|
|
5337
|
-
}
|
|
5338
|
-
function getRgbValues(rgb) {
|
|
5246
|
+
function getRgbCalculationValues(rgb) {
|
|
5339
5247
|
const blue = rgb.blue / COLOR_MAX.hex;
|
|
5340
5248
|
const green = rgb.green / COLOR_MAX.hex;
|
|
5341
5249
|
const red = rgb.red / COLOR_MAX.hex;
|
|
@@ -5350,6 +5258,27 @@ function getRgbValues(rgb) {
|
|
|
5350
5258
|
red
|
|
5351
5259
|
};
|
|
5352
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
|
+
}
|
|
5353
5282
|
/**
|
|
5354
5283
|
* Convert an _RGB(A)_ color to a hex color _(with optional alpha channel, i.e., opacity)_
|
|
5355
5284
|
*
|
|
@@ -5360,7 +5289,7 @@ function getRgbValues(rgb) {
|
|
|
5360
5289
|
* @returns Hex color string
|
|
5361
5290
|
*/
|
|
5362
5291
|
function rgbToHex(rgb, alpha) {
|
|
5363
|
-
return convertRgbToHex(isRgbLike(rgb) ?
|
|
5292
|
+
return convertRgbToHex(isRgbLike(rgb) ? getRgbValues(rgb) : { ...COLOR_DEFAULTS.rgb }, alpha ?? false);
|
|
5364
5293
|
}
|
|
5365
5294
|
/**
|
|
5366
5295
|
* Convert an _RGB(A)_ color to an _HSL_ color
|
|
@@ -5424,6 +5353,20 @@ function rgbToHwb(rgb) {
|
|
|
5424
5353
|
function rgbToHwba(rgb) {
|
|
5425
5354
|
return convertRgbToHwba(rgb);
|
|
5426
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
|
+
}
|
|
5427
5370
|
//#endregion
|
|
5428
5371
|
//#region src/color/space/hex.ts
|
|
5429
5372
|
function convertHexToRgba(value) {
|
|
@@ -5451,6 +5394,12 @@ function getColorFromHex(state, type) {
|
|
|
5451
5394
|
}
|
|
5452
5395
|
return state[type];
|
|
5453
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
|
+
}
|
|
5454
5403
|
/**
|
|
5455
5404
|
* Get the normalized hex color from a value
|
|
5456
5405
|
*
|
|
@@ -5548,10 +5497,22 @@ function hexToRgb(value) {
|
|
|
5548
5497
|
function hexToRgba(value) {
|
|
5549
5498
|
return convertHexToRgba(value);
|
|
5550
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
|
+
}
|
|
5551
5512
|
//#endregion
|
|
5552
5513
|
//#region src/color/space/hsl.ts
|
|
5553
5514
|
function convertHslToHwba(input) {
|
|
5554
|
-
let { hue, lightness, saturation } = isHslLike(input) ?
|
|
5515
|
+
let { hue, lightness, saturation } = isHslLike(input) ? getHslValues(input) : { ...COLOR_DEFAULTS.hsl };
|
|
5555
5516
|
lightness /= COLOR_MAX.percent;
|
|
5556
5517
|
saturation /= COLOR_MAX.percent;
|
|
5557
5518
|
const value = lightness + saturation * Math.min(lightness, 1 - lightness);
|
|
@@ -5566,7 +5527,7 @@ function convertHslToHwba(input) {
|
|
|
5566
5527
|
};
|
|
5567
5528
|
}
|
|
5568
5529
|
function convertHslToRgba(input) {
|
|
5569
|
-
const hsl = isHslLike(input) ?
|
|
5530
|
+
const hsl = isHslLike(input) ? getHslValues(input) : { ...COLOR_DEFAULTS.hsl };
|
|
5570
5531
|
const hue = hsl.hue % COLOR_MAX.degree;
|
|
5571
5532
|
const saturation = hsl.saturation / COLOR_MAX.percent;
|
|
5572
5533
|
const lightness = hsl.lightness / COLOR_MAX.percent;
|
|
@@ -5593,7 +5554,13 @@ function getHexyValue(hue, lightness, saturation, value) {
|
|
|
5593
5554
|
const part = (value + hue / 30) % 12;
|
|
5594
5555
|
return (lightness - saturation * Math.min(lightness, 1 - lightness) * Math.max(-1, Math.min(part - 3, 9 - part, 1))) * COLOR_MAX.hex;
|
|
5595
5556
|
}
|
|
5596
|
-
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) {
|
|
5597
5564
|
return {
|
|
5598
5565
|
hue: getDegrees(value.hue),
|
|
5599
5566
|
saturation: getPercentage(value.saturation),
|
|
@@ -5670,10 +5637,24 @@ function hslToRgb(hsl) {
|
|
|
5670
5637
|
function hslToRgba(hsl) {
|
|
5671
5638
|
return convertHslToRgba(hsl);
|
|
5672
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
|
+
}
|
|
5673
5654
|
//#endregion
|
|
5674
5655
|
//#region src/color/space/hwb.ts
|
|
5675
5656
|
function convertHwbToHsl(input) {
|
|
5676
|
-
let { blackness, hue, whiteness } = isHwbLike(input) ?
|
|
5657
|
+
let { blackness, hue, whiteness } = isHwbLike(input) ? getHwbValues(input) : COLOR_DEFAULTS.hwb;
|
|
5677
5658
|
blackness /= COLOR_MAX.percent;
|
|
5678
5659
|
whiteness /= COLOR_MAX.percent;
|
|
5679
5660
|
if (blackness + whiteness > 1) {
|
|
@@ -5706,7 +5687,13 @@ function getHwbSaturation(blackness, whiteness, lightness) {
|
|
|
5706
5687
|
if (hue <= 0) return 0;
|
|
5707
5688
|
return hue / Math.min(2 * lightness, 2 - 2 * lightness);
|
|
5708
5689
|
}
|
|
5709
|
-
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) {
|
|
5710
5697
|
return {
|
|
5711
5698
|
hue: getDegrees(value.hue),
|
|
5712
5699
|
whiteness: getPercentage(value.whiteness),
|
|
@@ -5774,6 +5761,20 @@ function hwbToRgb(hwb) {
|
|
|
5774
5761
|
function hwbToRgba(hwb) {
|
|
5775
5762
|
return hslToRgba(hwbToHsla(hwb));
|
|
5776
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
|
+
}
|
|
5777
5778
|
//#endregion
|
|
5778
5779
|
//#region src/color/misc/state.ts
|
|
5779
5780
|
function getColorFromState(state, type) {
|
|
@@ -5797,13 +5798,13 @@ function getColorState(value) {
|
|
|
5797
5798
|
origin: void 0
|
|
5798
5799
|
};
|
|
5799
5800
|
if (COLOR_KEYS.hsl.every((key) => key in value)) {
|
|
5800
|
-
state.hsl =
|
|
5801
|
+
state.hsl = getHslValues(value);
|
|
5801
5802
|
state.origin = COLOR_TYPE.hsl;
|
|
5802
5803
|
} else if (COLOR_KEYS.hwb.every((key) => key in value)) {
|
|
5803
|
-
state.hwb =
|
|
5804
|
+
state.hwb = getHwbValues(value);
|
|
5804
5805
|
state.origin = COLOR_TYPE.hwb;
|
|
5805
5806
|
} else if (COLOR_KEYS.rgb.every((key) => key in value)) {
|
|
5806
|
-
state.rgb =
|
|
5807
|
+
state.rgb = getRgbValues(value);
|
|
5807
5808
|
state.origin = COLOR_TYPE.rgb;
|
|
5808
5809
|
}
|
|
5809
5810
|
if (state.origin != null) return state;
|
|
@@ -5828,7 +5829,16 @@ function getDefaultColorState() {
|
|
|
5828
5829
|
origin: COLOR_TYPE.hex
|
|
5829
5830
|
};
|
|
5830
5831
|
}
|
|
5831
|
-
function
|
|
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 };
|
|
5840
|
+
}
|
|
5841
|
+
function setStateValue(instance, type, value, alpha) {
|
|
5832
5842
|
const { changes, values } = instance[COLOR_SYMBOL];
|
|
5833
5843
|
values.hex = void 0;
|
|
5834
5844
|
values.hsl = void 0;
|
|
@@ -5840,36 +5850,6 @@ function setColorValue(instance, type, value, alpha) {
|
|
|
5840
5850
|
for (const type of COLOR_TYPE.all) if (changes.observed(type)) changes.emit(type, instance[type]);
|
|
5841
5851
|
changes.emit(COLOR_TYPE.wildcard, instance);
|
|
5842
5852
|
}
|
|
5843
|
-
function setHexColor(instance, value, alpha) {
|
|
5844
|
-
const { values } = instance[COLOR_SYMBOL];
|
|
5845
|
-
if (!isHexColor(value) || !alpha && value === values.hex) return;
|
|
5846
|
-
const normalized = getNormalizedHex(value, true);
|
|
5847
|
-
setColorValue(instance, COLOR_TYPE.hex, normalized.slice(0, COLOR_LENGTHS.hexLong), alpha ? normalized.slice(COLOR_LENGTHS.hexLong) : void 0);
|
|
5848
|
-
}
|
|
5849
|
-
function setHSLColor(instance, value, alpha) {
|
|
5850
|
-
if (!isHslLike(value)) return;
|
|
5851
|
-
setColorValue(instance, COLOR_TYPE.hsl, {
|
|
5852
|
-
hue: getDegrees(value.hue),
|
|
5853
|
-
saturation: getPercentage(value.saturation),
|
|
5854
|
-
lightness: getPercentage(value.lightness)
|
|
5855
|
-
}, alpha ? value.alpha : void 0);
|
|
5856
|
-
}
|
|
5857
|
-
function setHWBColor(instance, value, alpha) {
|
|
5858
|
-
if (!isHwbLike(value)) return;
|
|
5859
|
-
setColorValue(instance, COLOR_TYPE.hwb, {
|
|
5860
|
-
hue: getDegrees(value.hue),
|
|
5861
|
-
whiteness: getPercentage(value.whiteness),
|
|
5862
|
-
blackness: getPercentage(value.blackness)
|
|
5863
|
-
}, alpha ? value.alpha : void 0);
|
|
5864
|
-
}
|
|
5865
|
-
function setRGBColor(instance, value, alpha) {
|
|
5866
|
-
if (!isRgbLike(value)) return;
|
|
5867
|
-
setColorValue(instance, COLOR_TYPE.rgb, {
|
|
5868
|
-
red: getHexValue(value.red),
|
|
5869
|
-
green: getHexValue(value.green),
|
|
5870
|
-
blue: getHexValue(value.blue)
|
|
5871
|
-
}, alpha ? value.alpha : void 0);
|
|
5872
|
-
}
|
|
5873
5853
|
const getters = {
|
|
5874
5854
|
hex: getColorFromHex,
|
|
5875
5855
|
hsl: getColorFromHsl,
|
|
@@ -5902,129 +5882,86 @@ function getSuffix(state, alpha) {
|
|
|
5902
5882
|
//#endregion
|
|
5903
5883
|
//#region src/color/instance.ts
|
|
5904
5884
|
function Color(value) {
|
|
5905
|
-
|
|
5885
|
+
this[COLOR_SYMBOL] = {
|
|
5906
5886
|
changes: herald({
|
|
5907
5887
|
names: [COLOR_TYPE.wildcard, ...COLOR_TYPE.all],
|
|
5908
5888
|
property: colorSubscription,
|
|
5909
5889
|
onCreate: (event, callback) => onCreateSubscription(this, event, callback)
|
|
5910
5890
|
}),
|
|
5911
5891
|
values: getColorState(value)
|
|
5912
|
-
}
|
|
5892
|
+
};
|
|
5913
5893
|
}
|
|
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;
|
|
5914
5902
|
Object.defineProperties(Color.prototype, {
|
|
5915
|
-
[COLOR_PROPERTY]: { value: COLOR_NAME },
|
|
5916
5903
|
alpha: {
|
|
5917
5904
|
enumerable: true,
|
|
5918
|
-
get
|
|
5919
|
-
|
|
5920
|
-
},
|
|
5921
|
-
set(value) {
|
|
5922
|
-
setAlphaValue(this[COLOR_SYMBOL].values, value);
|
|
5923
|
-
}
|
|
5905
|
+
get: getColorAlpha,
|
|
5906
|
+
set: setColorAlpha
|
|
5924
5907
|
},
|
|
5925
5908
|
changes: {
|
|
5926
5909
|
enumerable: true,
|
|
5927
|
-
get
|
|
5928
|
-
return this[COLOR_SYMBOL].changes.events;
|
|
5929
|
-
}
|
|
5910
|
+
get: getColorChanges
|
|
5930
5911
|
},
|
|
5931
5912
|
hex: {
|
|
5932
5913
|
enumerable: true,
|
|
5933
|
-
get
|
|
5934
|
-
|
|
5935
|
-
},
|
|
5936
|
-
set(value) {
|
|
5937
|
-
setHexColor(this, value, false);
|
|
5938
|
-
}
|
|
5914
|
+
get: getHexColor$1,
|
|
5915
|
+
set: setHexValue
|
|
5939
5916
|
},
|
|
5940
5917
|
hexa: {
|
|
5941
5918
|
enumerable: true,
|
|
5942
|
-
get
|
|
5943
|
-
|
|
5944
|
-
},
|
|
5945
|
-
set(value) {
|
|
5946
|
-
setHexColor(this, value, true);
|
|
5947
|
-
}
|
|
5919
|
+
get: getHexaColor$1,
|
|
5920
|
+
set: setHexaValue
|
|
5948
5921
|
},
|
|
5949
5922
|
hsl: {
|
|
5950
5923
|
enumerable: true,
|
|
5951
|
-
get
|
|
5952
|
-
|
|
5953
|
-
},
|
|
5954
|
-
set(value) {
|
|
5955
|
-
setHSLColor(this, value, false);
|
|
5956
|
-
}
|
|
5924
|
+
get: getHslValue,
|
|
5925
|
+
set: setHslValue
|
|
5957
5926
|
},
|
|
5958
5927
|
hsla: {
|
|
5959
5928
|
enumerable: true,
|
|
5960
|
-
get
|
|
5961
|
-
|
|
5962
|
-
},
|
|
5963
|
-
set(value) {
|
|
5964
|
-
setHSLColor(this, value, true);
|
|
5965
|
-
}
|
|
5929
|
+
get: getHslaValue,
|
|
5930
|
+
set: setHslaValue
|
|
5966
5931
|
},
|
|
5967
5932
|
hwb: {
|
|
5968
5933
|
enumerable: true,
|
|
5969
|
-
get
|
|
5970
|
-
|
|
5971
|
-
},
|
|
5972
|
-
set(value) {
|
|
5973
|
-
setHWBColor(this, value, false);
|
|
5974
|
-
}
|
|
5934
|
+
get: getHwbValue,
|
|
5935
|
+
set: setHwbValue
|
|
5975
5936
|
},
|
|
5976
5937
|
hwba: {
|
|
5977
5938
|
enumerable: true,
|
|
5978
|
-
get
|
|
5979
|
-
|
|
5980
|
-
},
|
|
5981
|
-
set(value) {
|
|
5982
|
-
setHWBColor(this, value, true);
|
|
5983
|
-
}
|
|
5939
|
+
get: getHwbaValue,
|
|
5940
|
+
set: setHwbaValue
|
|
5984
5941
|
},
|
|
5985
5942
|
origin: {
|
|
5986
5943
|
enumerable: true,
|
|
5987
|
-
get
|
|
5988
|
-
return this[COLOR_SYMBOL].values.origin;
|
|
5989
|
-
}
|
|
5944
|
+
get: getOrigin
|
|
5990
5945
|
},
|
|
5991
5946
|
rgb: {
|
|
5992
5947
|
enumerable: true,
|
|
5993
|
-
get
|
|
5994
|
-
|
|
5995
|
-
},
|
|
5996
|
-
set(value) {
|
|
5997
|
-
setRGBColor(this, value, false);
|
|
5998
|
-
}
|
|
5948
|
+
get: getRgbColor$1,
|
|
5949
|
+
set: setRgbValue
|
|
5999
5950
|
},
|
|
6000
5951
|
rgba: {
|
|
6001
5952
|
enumerable: true,
|
|
6002
|
-
get
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
set(value) {
|
|
6006
|
-
setRGBColor(this, value, true);
|
|
6007
|
-
}
|
|
6008
|
-
},
|
|
6009
|
-
subscribe: { value: subscribeToColor },
|
|
6010
|
-
toHexString: { value: formatHexColor },
|
|
6011
|
-
toHslString: { value: formatHslColor },
|
|
6012
|
-
toHwbString: { value: formatHwbColor },
|
|
6013
|
-
toRgbString: { value: formatRgbColor },
|
|
6014
|
-
toString: { value: formatHexColor },
|
|
6015
|
-
unsubscribe: { value: unsubscribeFromColor }
|
|
5953
|
+
get: getRgbaColor$1,
|
|
5954
|
+
set: setRgbaValue
|
|
5955
|
+
}
|
|
6016
5956
|
});
|
|
6017
5957
|
function color(value) {
|
|
6018
5958
|
return new Color(value);
|
|
6019
5959
|
}
|
|
6020
|
-
function
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
return
|
|
6025
|
-
...value,
|
|
6026
|
-
alpha: values.alpha.value
|
|
6027
|
-
} : { ...value };
|
|
5960
|
+
function getColorChanges() {
|
|
5961
|
+
return this[COLOR_SYMBOL].changes.events;
|
|
5962
|
+
}
|
|
5963
|
+
function getOrigin() {
|
|
5964
|
+
return this[COLOR_SYMBOL].values.origin;
|
|
6028
5965
|
}
|
|
6029
5966
|
function onCreateSubscription(instance, event, callback) {
|
|
6030
5967
|
let value;
|
|
@@ -6032,9 +5969,6 @@ function onCreateSubscription(instance, event, callback) {
|
|
|
6032
5969
|
else value = instance[event];
|
|
6033
5970
|
callback(value);
|
|
6034
5971
|
}
|
|
6035
|
-
function setAlphaValue(state, value) {
|
|
6036
|
-
if (typeof value === "number" && !Number.isNaN(value)) state.alpha = getAlpha(value, false);
|
|
6037
|
-
}
|
|
6038
5972
|
function subscribeToColor(callback, signal) {
|
|
6039
5973
|
const { changes } = this[COLOR_SYMBOL];
|
|
6040
5974
|
return changes.subscribe(COLOR_TYPE.wildcard, callback, signal);
|
|
@@ -6180,36 +6114,32 @@ const EXPRESSION_WHITESPACE = /^\s*$/;
|
|
|
6180
6114
|
const LOGGER_NAME = "Logger";
|
|
6181
6115
|
const LOGGER_NAME_TIMED = "TimedLogger";
|
|
6182
6116
|
const LOGGER_PROPERTY = "$logger";
|
|
6183
|
-
function Lumberjack() {
|
|
6184
|
-
for (const method of methods) {
|
|
6185
|
-
const bound = console[method].bind(console);
|
|
6186
|
-
Object.defineProperty(this, method, {
|
|
6187
|
-
enumerable: true,
|
|
6188
|
-
get() {
|
|
6189
|
-
return enabled ? bound : noop;
|
|
6190
|
-
}
|
|
6191
|
-
});
|
|
6192
|
-
}
|
|
6193
|
-
}
|
|
6117
|
+
function Lumberjack() {}
|
|
6194
6118
|
Lumberjack.prototype[LOGGER_PROPERTY] = LOGGER_NAME;
|
|
6119
|
+
Lumberjack.prototype.time = getTimeLogger;
|
|
6195
6120
|
Object.defineProperties(Lumberjack.prototype, {
|
|
6121
|
+
debug: { get: getLoggerCallback.bind("debug") },
|
|
6122
|
+
dir: { get: getLoggerCallback.bind("dir") },
|
|
6123
|
+
error: { get: getLoggerCallback.bind("error") },
|
|
6196
6124
|
enabled: {
|
|
6197
6125
|
enumerable: true,
|
|
6198
|
-
get:
|
|
6199
|
-
set:
|
|
6200
|
-
enabled = typeof value === "boolean" ? value : enabled;
|
|
6201
|
-
}
|
|
6126
|
+
get: getLoggerEnabled,
|
|
6127
|
+
set: setLoggerEnabled
|
|
6202
6128
|
},
|
|
6203
|
-
|
|
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") }
|
|
6204
6134
|
});
|
|
6205
6135
|
function TimeLogger(label) {
|
|
6206
|
-
|
|
6136
|
+
this[LOGGER_SYMBOL] = {
|
|
6207
6137
|
label,
|
|
6208
6138
|
started: enabled,
|
|
6209
6139
|
stopped: false
|
|
6210
|
-
}
|
|
6140
|
+
};
|
|
6211
6141
|
this[LOGGER_SYMBOL].isActive = () => {
|
|
6212
|
-
return this[LOGGER_SYMBOL].started && !this[LOGGER_SYMBOL].stopped
|
|
6142
|
+
return enabled && this[LOGGER_SYMBOL].started && !this[LOGGER_SYMBOL].stopped;
|
|
6213
6143
|
};
|
|
6214
6144
|
if (this[LOGGER_SYMBOL].started) console.time(label);
|
|
6215
6145
|
}
|
|
@@ -6217,43 +6147,48 @@ TimeLogger.prototype[LOGGER_PROPERTY] = LOGGER_NAME_TIMED;
|
|
|
6217
6147
|
Object.defineProperties(TimeLogger.prototype, {
|
|
6218
6148
|
active: {
|
|
6219
6149
|
enumerable: true,
|
|
6220
|
-
get
|
|
6221
|
-
return this[LOGGER_SYMBOL].isActive();
|
|
6222
|
-
}
|
|
6150
|
+
get: getTimeLoggerActive
|
|
6223
6151
|
},
|
|
6224
|
-
log: { get
|
|
6225
|
-
|
|
6226
|
-
return state.isActive() ? console.timeLog.bind(console, state.label) : noop;
|
|
6227
|
-
} },
|
|
6228
|
-
stop: { get() {
|
|
6229
|
-
const state = this[LOGGER_SYMBOL];
|
|
6230
|
-
if (state.isActive()) {
|
|
6231
|
-
state.stopped = true;
|
|
6232
|
-
return console.timeEnd.bind(console, state.label);
|
|
6233
|
-
}
|
|
6234
|
-
return noop;
|
|
6235
|
-
} }
|
|
6152
|
+
log: { get: getTimerLoggerLog },
|
|
6153
|
+
stop: { get: getTimeLoggerStop }
|
|
6236
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
|
+
}
|
|
6237
6179
|
function isLogger(value) {
|
|
6238
6180
|
return isLoggerInstance(LOGGER_NAME, value);
|
|
6239
6181
|
}
|
|
6240
6182
|
function isLoggerInstance(name, value) {
|
|
6241
|
-
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;
|
|
6242
6184
|
}
|
|
6243
6185
|
function isTimeLogger(value) {
|
|
6244
6186
|
return isLoggerInstance(LOGGER_NAME_TIMED, value);
|
|
6245
6187
|
}
|
|
6188
|
+
function setLoggerEnabled(value) {
|
|
6189
|
+
enabled = typeof value === "boolean" ? value : enabled;
|
|
6190
|
+
}
|
|
6246
6191
|
const LOGGER_SYMBOL = Symbol(LOGGER_PROPERTY);
|
|
6247
|
-
const methods = [
|
|
6248
|
-
"debug",
|
|
6249
|
-
"dir",
|
|
6250
|
-
"error",
|
|
6251
|
-
"info",
|
|
6252
|
-
"log",
|
|
6253
|
-
"table",
|
|
6254
|
-
"trace",
|
|
6255
|
-
"warn"
|
|
6256
|
-
];
|
|
6257
6192
|
/**
|
|
6258
6193
|
* A logger that can be used to log messages to the console
|
|
6259
6194
|
*
|
|
@@ -6418,83 +6353,63 @@ var QueueError = class extends Error {
|
|
|
6418
6353
|
}
|
|
6419
6354
|
};
|
|
6420
6355
|
function KeyedQueue(callback, options) {
|
|
6421
|
-
|
|
6356
|
+
this[QUEUE_SYMBOL] = {
|
|
6422
6357
|
callback,
|
|
6423
6358
|
options: createQueueOptions(options),
|
|
6424
6359
|
queues: /* @__PURE__ */ new Map()
|
|
6425
|
-
}
|
|
6360
|
+
};
|
|
6426
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;
|
|
6427
6369
|
Object.defineProperties(KeyedQueue.prototype, {
|
|
6428
|
-
[QUEUE_PROPERTY]: { value: QUEUE_NAME_KEYED },
|
|
6429
6370
|
active: {
|
|
6430
6371
|
enumerable: true,
|
|
6431
|
-
get
|
|
6432
|
-
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_ACTIVE);
|
|
6433
|
-
}
|
|
6372
|
+
get: getActiveQueues
|
|
6434
6373
|
},
|
|
6435
|
-
add: { value: addKeyedQueue },
|
|
6436
6374
|
autostart: {
|
|
6437
6375
|
enumerable: true,
|
|
6438
|
-
get
|
|
6439
|
-
return this[QUEUE_SYMBOL].options.autostart;
|
|
6440
|
-
}
|
|
6376
|
+
get: getQueueAutostart
|
|
6441
6377
|
},
|
|
6442
|
-
clear: { value: clearQueues },
|
|
6443
6378
|
concurrency: {
|
|
6444
6379
|
enumerable: true,
|
|
6445
|
-
get
|
|
6446
|
-
return this[QUEUE_SYMBOL].options.concurrency;
|
|
6447
|
-
}
|
|
6380
|
+
get: getQueueConcurrency
|
|
6448
6381
|
},
|
|
6449
6382
|
empty: {
|
|
6450
6383
|
enumerable: true,
|
|
6451
|
-
get
|
|
6452
|
-
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_EMPTY);
|
|
6453
|
-
}
|
|
6384
|
+
get: getEmptyQueues
|
|
6454
6385
|
},
|
|
6455
6386
|
full: {
|
|
6456
6387
|
enumerable: true,
|
|
6457
|
-
get
|
|
6458
|
-
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_FULL);
|
|
6459
|
-
}
|
|
6388
|
+
get: getFullQueues
|
|
6460
6389
|
},
|
|
6461
|
-
get: { value: getQueue },
|
|
6462
6390
|
items: {
|
|
6463
6391
|
enumerable: true,
|
|
6464
|
-
get
|
|
6465
|
-
return getQueueItems(this[QUEUE_SYMBOL]);
|
|
6466
|
-
}
|
|
6392
|
+
get: getKeyedQueueItems
|
|
6467
6393
|
},
|
|
6468
6394
|
keys: {
|
|
6469
6395
|
enumerable: true,
|
|
6470
|
-
get
|
|
6471
|
-
return [...this[QUEUE_SYMBOL].queues.keys()];
|
|
6472
|
-
}
|
|
6396
|
+
get: getQueueKeys
|
|
6473
6397
|
},
|
|
6474
6398
|
maximum: {
|
|
6475
6399
|
enumerable: true,
|
|
6476
|
-
get
|
|
6477
|
-
return this[QUEUE_SYMBOL].options.maximum;
|
|
6478
|
-
}
|
|
6400
|
+
get: getQueueMaximum
|
|
6479
6401
|
},
|
|
6480
|
-
pause: { value: pauseQueues },
|
|
6481
6402
|
paused: {
|
|
6482
6403
|
enumerable: true,
|
|
6483
|
-
get
|
|
6484
|
-
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_PAUSED);
|
|
6485
|
-
}
|
|
6404
|
+
get: getPausedQueues
|
|
6486
6405
|
},
|
|
6487
6406
|
queues: {
|
|
6488
6407
|
enumerable: true,
|
|
6489
|
-
get
|
|
6490
|
-
|
|
6491
|
-
}
|
|
6492
|
-
},
|
|
6493
|
-
remove: { value: removeQueue },
|
|
6494
|
-
resume: { value: resumeQueues }
|
|
6408
|
+
get: getKeyedQueueSize
|
|
6409
|
+
}
|
|
6495
6410
|
});
|
|
6496
6411
|
function Queue(callback, options, key) {
|
|
6497
|
-
|
|
6412
|
+
this[QUEUE_SYMBOL] = {
|
|
6498
6413
|
callback,
|
|
6499
6414
|
key,
|
|
6500
6415
|
options,
|
|
@@ -6503,63 +6418,46 @@ function Queue(callback, options, key) {
|
|
|
6503
6418
|
items: [],
|
|
6504
6419
|
paused: !options.autostart,
|
|
6505
6420
|
runners: 0
|
|
6506
|
-
}
|
|
6421
|
+
};
|
|
6507
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;
|
|
6508
6429
|
Object.defineProperties(Queue.prototype, {
|
|
6509
|
-
[QUEUE_PROPERTY]: { value: QUEUE_NAME_QUEUE },
|
|
6510
6430
|
active: {
|
|
6511
6431
|
enumerable: true,
|
|
6512
|
-
get
|
|
6513
|
-
return this[QUEUE_SYMBOL].runners > 0;
|
|
6514
|
-
}
|
|
6432
|
+
get: getQueueActive
|
|
6515
6433
|
},
|
|
6516
|
-
add: { value: addToQueue },
|
|
6517
6434
|
autostart: {
|
|
6518
6435
|
enumerable: true,
|
|
6519
|
-
get
|
|
6520
|
-
return this[QUEUE_SYMBOL].options.autostart;
|
|
6521
|
-
}
|
|
6436
|
+
get: getQueueAutostart
|
|
6522
6437
|
},
|
|
6523
|
-
clear: { value: clearQueue },
|
|
6524
6438
|
concurrency: {
|
|
6525
6439
|
enumerable: true,
|
|
6526
|
-
get
|
|
6527
|
-
return this[QUEUE_SYMBOL].options.concurrency;
|
|
6528
|
-
}
|
|
6440
|
+
get: getQueueConcurrency
|
|
6529
6441
|
},
|
|
6530
6442
|
empty: {
|
|
6531
6443
|
enumerable: true,
|
|
6532
|
-
get
|
|
6533
|
-
return this[QUEUE_SYMBOL].items.length === 0;
|
|
6534
|
-
}
|
|
6444
|
+
get: getQueueEmpty
|
|
6535
6445
|
},
|
|
6536
6446
|
full: {
|
|
6537
6447
|
enumerable: true,
|
|
6538
|
-
get
|
|
6539
|
-
const state = this[QUEUE_SYMBOL];
|
|
6540
|
-
return state.options.maximum > 0 && state.items.length >= state.options.maximum;
|
|
6541
|
-
}
|
|
6448
|
+
get: getQueueFull
|
|
6542
6449
|
},
|
|
6543
6450
|
maximum: {
|
|
6544
6451
|
enumerable: true,
|
|
6545
|
-
get
|
|
6546
|
-
return this[QUEUE_SYMBOL].options.maximum;
|
|
6547
|
-
}
|
|
6452
|
+
get: getQueueMaximum
|
|
6548
6453
|
},
|
|
6549
|
-
pause: { value: pauseQueue },
|
|
6550
6454
|
paused: {
|
|
6551
6455
|
enumerable: true,
|
|
6552
|
-
get
|
|
6553
|
-
return this[QUEUE_SYMBOL].paused;
|
|
6554
|
-
}
|
|
6456
|
+
get: getQueuePaused
|
|
6555
6457
|
},
|
|
6556
|
-
remove: { value: removeQueued },
|
|
6557
|
-
resume: { value: resumeQueue },
|
|
6558
6458
|
size: {
|
|
6559
6459
|
enumerable: true,
|
|
6560
|
-
get
|
|
6561
|
-
return this[QUEUE_SYMBOL].items.length;
|
|
6562
|
-
}
|
|
6460
|
+
get: getQueueSize
|
|
6563
6461
|
}
|
|
6564
6462
|
});
|
|
6565
6463
|
function addKeyedQueue(key, parameters, signal) {
|
|
@@ -6617,6 +6515,28 @@ function createQueueOptions(input) {
|
|
|
6617
6515
|
maximum: getNumberOrDefault(options.maximum, 0)
|
|
6618
6516
|
};
|
|
6619
6517
|
}
|
|
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
|
+
}
|
|
6620
6540
|
function getQueue(key, add) {
|
|
6621
6541
|
if (typeof key !== "string" || key.trim().length === 0) throw new TypeError(QUEUE_MESSAGE_KEY);
|
|
6622
6542
|
const state = this[QUEUE_SYMBOL];
|
|
@@ -6627,11 +6547,33 @@ function getQueue(key, add) {
|
|
|
6627
6547
|
}
|
|
6628
6548
|
return queue;
|
|
6629
6549
|
}
|
|
6630
|
-
function
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
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;
|
|
6635
6577
|
}
|
|
6636
6578
|
function getStatus(state, status) {
|
|
6637
6579
|
const queues = state.queues.entries();
|
|
@@ -6777,7 +6719,6 @@ const QUEUE_STATUS_FULL = "full";
|
|
|
6777
6719
|
const QUEUE_STATUS_PAUSED = "paused";
|
|
6778
6720
|
const QUEUE_SYMBOL = Symbol(QUEUE_PROPERTY);
|
|
6779
6721
|
queue.keyed = keyedQueue;
|
|
6780
|
-
Object.defineProperty(queue, "keyed", { value: keyedQueue });
|
|
6781
6722
|
//#endregion
|
|
6782
6723
|
//#region src/random.ts
|
|
6783
6724
|
/**
|