@tspro/ts-utils-lib 1.19.1 → 1.20.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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +481 -140
- package/dist/index.d.ts +481 -140
- package/dist/index.js +1418 -256
- package/dist/index.mjs +1411 -256
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* TsUtilsLib v1.
|
|
1
|
+
/* TsUtilsLib v1.20.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __export = (target, all) => {
|
|
@@ -64,6 +64,7 @@ __export(assert_exports, {
|
|
|
64
64
|
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined,
|
|
65
65
|
isNonEmptyString: () => isNonEmptyString,
|
|
66
66
|
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined,
|
|
67
|
+
isNotThrowing: () => isNotThrowing,
|
|
67
68
|
isNull: () => isNull,
|
|
68
69
|
isNullish: () => isNullish,
|
|
69
70
|
isNumber: () => isNumber,
|
|
@@ -459,6 +460,11 @@ function isThrowing(throwTestFn, msg) {
|
|
|
459
460
|
_fail(`Expected to throw`, msg);
|
|
460
461
|
return true;
|
|
461
462
|
}
|
|
463
|
+
function isNotThrowing(throwTestFn, msg) {
|
|
464
|
+
if (!guard_exports.isNotThrowing(throwTestFn))
|
|
465
|
+
_fail(`Expected to throw`, msg);
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
462
468
|
|
|
463
469
|
// src/web/cookies.ts
|
|
464
470
|
var cookies_exports = {};
|
|
@@ -706,6 +712,7 @@ __export(guard_exports, {
|
|
|
706
712
|
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined2,
|
|
707
713
|
isNonEmptyString: () => isNonEmptyString2,
|
|
708
714
|
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined2,
|
|
715
|
+
isNotThrowing: () => isNotThrowing2,
|
|
709
716
|
isNull: () => isNull2,
|
|
710
717
|
isNullish: () => isNullish2,
|
|
711
718
|
isNumber: () => isNumber2,
|
|
@@ -955,6 +962,14 @@ function isThrowing2(throwTestFn) {
|
|
|
955
962
|
return true;
|
|
956
963
|
}
|
|
957
964
|
}
|
|
965
|
+
function isNotThrowing2(throwTestFn) {
|
|
966
|
+
try {
|
|
967
|
+
throwTestFn();
|
|
968
|
+
return true;
|
|
969
|
+
} catch (err) {
|
|
970
|
+
return false;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
958
973
|
function tryOr(tryFn, orVal) {
|
|
959
974
|
try {
|
|
960
975
|
return tryFn();
|
|
@@ -1388,99 +1403,19 @@ __export(str_exports, {
|
|
|
1388
1403
|
removeAt: () => removeAt,
|
|
1389
1404
|
repeatString: () => repeatString,
|
|
1390
1405
|
replaceAt: () => replaceAt,
|
|
1406
|
+
stringify: () => stringify,
|
|
1391
1407
|
toCharArray: () => toCharArray
|
|
1392
1408
|
});
|
|
1393
|
-
function toCharArray(str2) {
|
|
1394
|
-
return str2.split("");
|
|
1395
|
-
}
|
|
1396
|
-
function repeatString(repeatString2, repeatCount) {
|
|
1397
|
-
if (!isInteger2(repeatCount) || repeatCount < 0) {
|
|
1398
|
-
throw new Error("repeatStr: Invalid repeatCount = " + repeatCount);
|
|
1399
|
-
}
|
|
1400
|
-
return new Array(repeatCount + 1).join(repeatString2);
|
|
1401
|
-
}
|
|
1402
|
-
function chunkString(str2, chunkSize) {
|
|
1403
|
-
if (!isInteger2(chunkSize) || chunkSize < 1) {
|
|
1404
|
-
throw new Error("chunckString: Invalid chuckSize = " + chunkSize);
|
|
1405
|
-
}
|
|
1406
|
-
let result = [];
|
|
1407
|
-
for (let i = 0; i < str2.length; i += chunkSize) {
|
|
1408
|
-
result.push(str2.slice(i, i + chunkSize));
|
|
1409
|
-
}
|
|
1410
|
-
return result;
|
|
1411
|
-
}
|
|
1412
|
-
function replaceAt(str2, pos, removeCount, insert) {
|
|
1413
|
-
if (!isInteger2(removeCount) || removeCount < 0) {
|
|
1414
|
-
throw new Error("replaceAt: Invalid removeCount = " + removeCount);
|
|
1415
|
-
} else if (!isInteger2(pos) || pos < 0 || pos + removeCount > str2.length) {
|
|
1416
|
-
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " + str2.length);
|
|
1417
|
-
} else {
|
|
1418
|
-
return str2.substring(0, pos) + insert + str2.substring(pos + removeCount);
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
|
-
function insertAt(str2, pos, insertStr) {
|
|
1422
|
-
return replaceAt(str2, pos, 0, insertStr);
|
|
1423
|
-
}
|
|
1424
|
-
function removeAt(str2, pos, removeCount) {
|
|
1425
|
-
return replaceAt(str2, pos, removeCount, "");
|
|
1426
|
-
}
|
|
1427
|
-
function charCount(str2, ch) {
|
|
1428
|
-
if (ch.length !== 1 || str2.length === 0) return 0;
|
|
1429
|
-
let count = 0;
|
|
1430
|
-
for (let i = 0; i < str2.length; i++) {
|
|
1431
|
-
if (str2[i] === ch) count++;
|
|
1432
|
-
}
|
|
1433
|
-
return count;
|
|
1434
|
-
}
|
|
1435
|
-
function makeSentenceFromPascal(PascalString) {
|
|
1436
|
-
if (PascalString === "") {
|
|
1437
|
-
return "";
|
|
1438
|
-
}
|
|
1439
|
-
let word = PascalString.charAt(0);
|
|
1440
|
-
let sentence = "";
|
|
1441
|
-
const addWord = () => {
|
|
1442
|
-
if (word !== "") {
|
|
1443
|
-
if (sentence === "") {
|
|
1444
|
-
sentence += word.charAt(0).toUpperCase() + word.substring(1);
|
|
1445
|
-
} else {
|
|
1446
|
-
sentence += " " + word;
|
|
1447
|
-
}
|
|
1448
|
-
word = "";
|
|
1449
|
-
}
|
|
1450
|
-
};
|
|
1451
|
-
const isLetterAndCapital = (c) => {
|
|
1452
|
-
return c.toUpperCase() !== c.toLowerCase() && c === c.toUpperCase();
|
|
1453
|
-
};
|
|
1454
|
-
for (let i = 1; i < PascalString.length; i++) {
|
|
1455
|
-
let c = PascalString.charAt(i);
|
|
1456
|
-
if (isLetterAndCapital(c)) {
|
|
1457
|
-
addWord();
|
|
1458
|
-
}
|
|
1459
|
-
word += c.toLowerCase();
|
|
1460
|
-
}
|
|
1461
|
-
addWord();
|
|
1462
|
-
return sentence;
|
|
1463
|
-
}
|
|
1464
|
-
|
|
1465
|
-
// src/utils/index.ts
|
|
1466
|
-
var Is = guard_exports;
|
|
1467
1409
|
|
|
1468
|
-
// src/core/
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
} else if (isArray2(value)) {
|
|
1473
|
-
return `[ ${value.map((e) => formatValue(e)).join(", ")} ]`.replaceAll(" ", " ");
|
|
1474
|
-
} else if (isFunction2(value.toString)) {
|
|
1475
|
-
return value.toString();
|
|
1476
|
-
} else {
|
|
1477
|
-
return JSON.stringify(value);
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1410
|
+
// src/core/base.ts
|
|
1411
|
+
var DefaultEqualityFn = (a, b) => a === b;
|
|
1412
|
+
var BaseContainer = class {
|
|
1413
|
+
};
|
|
1480
1414
|
|
|
1481
1415
|
// src/core/stack.ts
|
|
1482
|
-
var Stack = class {
|
|
1416
|
+
var Stack = class extends BaseContainer {
|
|
1483
1417
|
constructor() {
|
|
1418
|
+
super();
|
|
1484
1419
|
__publicField(this, "data", []);
|
|
1485
1420
|
}
|
|
1486
1421
|
assertId(id) {
|
|
@@ -1541,13 +1476,14 @@ var Stack = class {
|
|
|
1541
1476
|
this.data.length = 0;
|
|
1542
1477
|
}
|
|
1543
1478
|
toString() {
|
|
1544
|
-
return `Stack(${this.length})${
|
|
1479
|
+
return `Stack(${this.length})${stringify(this.data)}`;
|
|
1545
1480
|
}
|
|
1546
1481
|
};
|
|
1547
1482
|
|
|
1548
1483
|
// src/core/vec.ts
|
|
1549
|
-
var Vec = class _Vec {
|
|
1484
|
+
var Vec = class _Vec extends BaseContainer {
|
|
1550
1485
|
constructor(...coords) {
|
|
1486
|
+
super();
|
|
1551
1487
|
__publicField(this, "coords");
|
|
1552
1488
|
if (coords.length < 2) {
|
|
1553
1489
|
throw new TypeError("Vec needs minumum two coords!");
|
|
@@ -1748,19 +1684,31 @@ var DivRect = class _DivRect {
|
|
|
1748
1684
|
static createSections(leftw, rightw, toph, bottomh) {
|
|
1749
1685
|
return new _DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
|
|
1750
1686
|
}
|
|
1751
|
-
/**
|
|
1687
|
+
/**
|
|
1688
|
+
* @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
|
|
1689
|
+
* @private
|
|
1690
|
+
* */
|
|
1752
1691
|
get centerX() {
|
|
1753
1692
|
return this.anchorX;
|
|
1754
1693
|
}
|
|
1755
|
-
/**
|
|
1694
|
+
/**
|
|
1695
|
+
* @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
|
|
1696
|
+
* @private
|
|
1697
|
+
* */
|
|
1756
1698
|
set centerX(x) {
|
|
1757
1699
|
this.anchorX = x;
|
|
1758
1700
|
}
|
|
1759
|
-
/**
|
|
1701
|
+
/**
|
|
1702
|
+
* @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
|
|
1703
|
+
* @private
|
|
1704
|
+
* */
|
|
1760
1705
|
get centerY() {
|
|
1761
1706
|
return this.anchorY;
|
|
1762
1707
|
}
|
|
1763
|
-
/**
|
|
1708
|
+
/**
|
|
1709
|
+
* @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
|
|
1710
|
+
* @private
|
|
1711
|
+
* */
|
|
1764
1712
|
set centerY(y) {
|
|
1765
1713
|
this.anchorY = y;
|
|
1766
1714
|
}
|
|
@@ -1878,7 +1826,10 @@ var DivRect = class _DivRect {
|
|
|
1878
1826
|
equalsEdges(other) {
|
|
1879
1827
|
return _DivRect.equalsEdges(this, other);
|
|
1880
1828
|
}
|
|
1881
|
-
/**
|
|
1829
|
+
/**
|
|
1830
|
+
* @deprecated - Use `DivRect.equalsEdges()` instead. Will be removed in v2.0.0.
|
|
1831
|
+
* @private
|
|
1832
|
+
*/
|
|
1882
1833
|
static equalsFrame(a, b) {
|
|
1883
1834
|
return _DivRect.equalsEdges(a, b);
|
|
1884
1835
|
}
|
|
@@ -1997,9 +1948,10 @@ var DivRect = class _DivRect {
|
|
|
1997
1948
|
};
|
|
1998
1949
|
|
|
1999
1950
|
// src/core/LRU-cache.ts
|
|
2000
|
-
var LRUCache = class {
|
|
1951
|
+
var LRUCache = class extends BaseContainer {
|
|
2001
1952
|
// Maximum key length.
|
|
2002
1953
|
constructor(maxSize, maxKeyLength = Infinity) {
|
|
1954
|
+
super();
|
|
2003
1955
|
__publicField(this, "cache");
|
|
2004
1956
|
// Stores the actual key-value pairs
|
|
2005
1957
|
__publicField(this, "next");
|
|
@@ -2091,11 +2043,31 @@ var LRUCache = class {
|
|
|
2091
2043
|
}
|
|
2092
2044
|
this.tail = key;
|
|
2093
2045
|
}
|
|
2046
|
+
*keys() {
|
|
2047
|
+
for (let key = this.head; key != null; key = this.next[key])
|
|
2048
|
+
yield key;
|
|
2049
|
+
}
|
|
2050
|
+
*values() {
|
|
2051
|
+
for (let key = this.head; key != null; key = this.next[key])
|
|
2052
|
+
yield this.cache[key];
|
|
2053
|
+
}
|
|
2054
|
+
*entries() {
|
|
2055
|
+
for (let key = this.head; key != null; key = this.next[key])
|
|
2056
|
+
yield [key, this.cache[key]];
|
|
2057
|
+
}
|
|
2058
|
+
*[Symbol.iterator]() {
|
|
2059
|
+
yield* this.entries();
|
|
2060
|
+
}
|
|
2061
|
+
toString() {
|
|
2062
|
+
const entries = [...this.entries()];
|
|
2063
|
+
return entries.length === 0 ? `LRUCache(0){ }` : `LRUCache(${entries.length}){ ${entries.map((e) => `${stringify(e[0])}: ${stringify(e[1])}`).join(", ")} }`;
|
|
2064
|
+
}
|
|
2094
2065
|
};
|
|
2095
2066
|
|
|
2096
2067
|
// src/core/index-array.ts
|
|
2097
|
-
var IndexArray = class _IndexArray {
|
|
2068
|
+
var IndexArray = class _IndexArray extends BaseContainer {
|
|
2098
2069
|
constructor(entries) {
|
|
2070
|
+
super();
|
|
2099
2071
|
__publicField(this, "posVal");
|
|
2100
2072
|
__publicField(this, "hasPos");
|
|
2101
2073
|
// Number of values
|
|
@@ -2308,14 +2280,20 @@ var IndexArray = class _IndexArray {
|
|
|
2308
2280
|
return this.valuesArray();
|
|
2309
2281
|
}
|
|
2310
2282
|
toString() {
|
|
2311
|
-
|
|
2312
|
-
|
|
2283
|
+
let isRegularArray = true;
|
|
2284
|
+
for (let i = 0; i < this.hasPos.length && isRegularArray; i++)
|
|
2285
|
+
if (!this.hasPos[i]) isRegularArray = false;
|
|
2286
|
+
if (isRegularArray)
|
|
2287
|
+
return stringify(this.posVal.slice(0, this.hasPos.length));
|
|
2288
|
+
const entries = this.entriesArray().map(([id, v]) => `${stringify(id)}: ${stringify(v)}`).join(", ");
|
|
2289
|
+
return entries.length === 0 ? `[ ]` : `[ ${entries} ]`;
|
|
2313
2290
|
}
|
|
2314
2291
|
};
|
|
2315
2292
|
|
|
2316
2293
|
// src/core/signed-index-array.ts
|
|
2317
|
-
var SignedIndexArray = class _SignedIndexArray {
|
|
2294
|
+
var SignedIndexArray = class _SignedIndexArray extends BaseContainer {
|
|
2318
2295
|
constructor(entries) {
|
|
2296
|
+
super();
|
|
2319
2297
|
// For indexes >= 0
|
|
2320
2298
|
__publicField(this, "posVal");
|
|
2321
2299
|
__publicField(this, "hasPos");
|
|
@@ -2571,21 +2549,28 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
2571
2549
|
return this.valuesArray();
|
|
2572
2550
|
}
|
|
2573
2551
|
toString() {
|
|
2574
|
-
|
|
2575
|
-
|
|
2552
|
+
let isRegularArray = this.hasNeg.length === 0;
|
|
2553
|
+
for (let i = 0; i < this.hasPos.length && isRegularArray; i++)
|
|
2554
|
+
if (!this.hasPos[i]) isRegularArray = false;
|
|
2555
|
+
if (isRegularArray)
|
|
2556
|
+
return stringify(this.posVal.slice(0, this.hasPos.length));
|
|
2557
|
+
const entries = this.entriesArray().map(([id, v]) => `${stringify(id)}: ${stringify(v)}`).join(", ");
|
|
2558
|
+
return entries.length === 0 ? `[ ]` : `[ ${entries} ]`;
|
|
2576
2559
|
}
|
|
2577
2560
|
};
|
|
2578
2561
|
|
|
2579
2562
|
// src/core/default-array.ts
|
|
2580
|
-
var DefaultArray = class _DefaultArray {
|
|
2581
|
-
constructor(
|
|
2582
|
-
|
|
2563
|
+
var DefaultArray = class _DefaultArray extends BaseContainer {
|
|
2564
|
+
constructor(...args) {
|
|
2565
|
+
super();
|
|
2566
|
+
__publicField(this, "defaultValue");
|
|
2583
2567
|
__publicField(this, "data");
|
|
2584
|
-
|
|
2585
|
-
|
|
2568
|
+
this.defaultValue = args.pop();
|
|
2569
|
+
if (typeof args[0] === "number") {
|
|
2570
|
+
this.data = Array(args[0]).fill(this.defaultValue);
|
|
2586
2571
|
} else {
|
|
2587
|
-
this.data = Array.from(
|
|
2588
|
-
(v) => v === void 0 ? defaultValue : v
|
|
2572
|
+
this.data = Array.from(args[0]).map(
|
|
2573
|
+
(v) => v === void 0 ? this.defaultValue : v
|
|
2589
2574
|
);
|
|
2590
2575
|
}
|
|
2591
2576
|
}
|
|
@@ -2686,9 +2671,7 @@ var DefaultArray = class _DefaultArray {
|
|
|
2686
2671
|
}
|
|
2687
2672
|
clone() {
|
|
2688
2673
|
const ctor = this.constructor;
|
|
2689
|
-
|
|
2690
|
-
clone.data = this.data.slice();
|
|
2691
|
-
return clone;
|
|
2674
|
+
return new ctor(this.values(), this.defaultValue);
|
|
2692
2675
|
}
|
|
2693
2676
|
merge(other, conflictResolver) {
|
|
2694
2677
|
if (this.constructor !== other.constructor)
|
|
@@ -2774,62 +2757,92 @@ var DefaultArray = class _DefaultArray {
|
|
|
2774
2757
|
return this.valuesArray();
|
|
2775
2758
|
}
|
|
2776
2759
|
toString() {
|
|
2777
|
-
|
|
2778
|
-
return `DefaultArray[ ${entries} ]`.replaceAll(" ", " ");
|
|
2760
|
+
return stringify(this.data);
|
|
2779
2761
|
}
|
|
2780
2762
|
};
|
|
2781
2763
|
|
|
2782
|
-
// src/core/
|
|
2783
|
-
var
|
|
2784
|
-
constructor(
|
|
2785
|
-
|
|
2786
|
-
this
|
|
2764
|
+
// src/core/uni-map.ts
|
|
2765
|
+
var UniMap = class _UniMap extends BaseContainer {
|
|
2766
|
+
constructor(...args) {
|
|
2767
|
+
super();
|
|
2768
|
+
__publicField(this, "map");
|
|
2769
|
+
__publicField(this, "keyEquals");
|
|
2770
|
+
const maybeEquals = args.at(-1);
|
|
2771
|
+
this.keyEquals = isFunction2(maybeEquals) ? args.pop() : DefaultEqualityFn;
|
|
2772
|
+
const entries = args[0];
|
|
2773
|
+
this.map = new Map(entries);
|
|
2787
2774
|
}
|
|
2788
|
-
|
|
2789
|
-
return
|
|
2775
|
+
static createDeep(arg) {
|
|
2776
|
+
return arg ? new _UniMap(arg, isDeepEqual2) : new _UniMap(isDeepEqual2);
|
|
2790
2777
|
}
|
|
2791
|
-
|
|
2792
|
-
this.
|
|
2778
|
+
has(key) {
|
|
2779
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
|
|
2780
|
+
return this.map.has(key);
|
|
2781
|
+
for (const [k, v] of this.map)
|
|
2782
|
+
if (this.keyEquals(k, key))
|
|
2783
|
+
return true;
|
|
2784
|
+
return false;
|
|
2785
|
+
}
|
|
2786
|
+
set(key, value) {
|
|
2787
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key)) {
|
|
2788
|
+
this.map.set(key, value);
|
|
2789
|
+
return value;
|
|
2790
|
+
}
|
|
2791
|
+
for (const key2 of this.map.keys())
|
|
2792
|
+
if (this.keyEquals(key2, key)) {
|
|
2793
|
+
this.map.set(key2, value);
|
|
2794
|
+
return value;
|
|
2795
|
+
}
|
|
2796
|
+
this.map.set(key, value);
|
|
2793
2797
|
return value;
|
|
2794
2798
|
}
|
|
2795
|
-
get(
|
|
2796
|
-
|
|
2799
|
+
get(key) {
|
|
2800
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
|
|
2801
|
+
return this.map.get(key);
|
|
2802
|
+
for (const [k, v] of this.map)
|
|
2803
|
+
if (this.keyEquals(k, key))
|
|
2804
|
+
return v;
|
|
2805
|
+
return void 0;
|
|
2797
2806
|
}
|
|
2798
|
-
|
|
2799
|
-
|
|
2807
|
+
delete(key) {
|
|
2808
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
|
|
2809
|
+
return this.map.delete(key);
|
|
2810
|
+
for (const k of this.map.keys())
|
|
2811
|
+
if (this.keyEquals(k, key))
|
|
2812
|
+
return this.map.delete(k);
|
|
2813
|
+
return this.map.delete(key);
|
|
2800
2814
|
}
|
|
2801
|
-
|
|
2802
|
-
|
|
2815
|
+
getOrDefault(key, defaultValue) {
|
|
2816
|
+
return this.get(key) ?? defaultValue;
|
|
2817
|
+
}
|
|
2818
|
+
getOrCreate(key, creatorOrValue) {
|
|
2819
|
+
if (!this.has(key)) {
|
|
2803
2820
|
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2804
|
-
this.set(
|
|
2805
|
-
return value;
|
|
2821
|
+
return this.set(key, value);
|
|
2806
2822
|
}
|
|
2807
|
-
return this.get(
|
|
2808
|
-
}
|
|
2809
|
-
delete(key1) {
|
|
2810
|
-
return this.map1.delete(key1);
|
|
2823
|
+
return this.get(key);
|
|
2811
2824
|
}
|
|
2812
2825
|
clear() {
|
|
2813
|
-
this.
|
|
2826
|
+
this.map.clear();
|
|
2814
2827
|
}
|
|
2815
2828
|
get size() {
|
|
2816
|
-
return this.
|
|
2829
|
+
return this.map.size;
|
|
2817
2830
|
}
|
|
2818
2831
|
isEmpty() {
|
|
2819
2832
|
return this.size === 0;
|
|
2820
2833
|
}
|
|
2821
2834
|
forEach(callbackfn, thisArg) {
|
|
2822
|
-
this.
|
|
2835
|
+
this.map.forEach((value, key) => callbackfn.call(thisArg, value, key, this));
|
|
2823
2836
|
}
|
|
2824
2837
|
*keys() {
|
|
2825
|
-
yield* this.
|
|
2838
|
+
yield* this.map.keys();
|
|
2826
2839
|
}
|
|
2827
2840
|
*values() {
|
|
2828
|
-
yield* this.
|
|
2841
|
+
yield* this.map.values();
|
|
2829
2842
|
}
|
|
2830
2843
|
*entries() {
|
|
2831
|
-
for (const [
|
|
2832
|
-
yield [
|
|
2844
|
+
for (const [key, value] of this.map)
|
|
2845
|
+
yield [key, value];
|
|
2833
2846
|
}
|
|
2834
2847
|
keysArray() {
|
|
2835
2848
|
return [...this.keys()];
|
|
@@ -2859,34 +2872,34 @@ var Map1 = class _Map1 {
|
|
|
2859
2872
|
yield* this.entries();
|
|
2860
2873
|
}
|
|
2861
2874
|
clone() {
|
|
2862
|
-
return new
|
|
2875
|
+
return new _UniMap(this, this.keyEquals);
|
|
2863
2876
|
}
|
|
2864
2877
|
merge(other, conflictResolver) {
|
|
2865
|
-
for (const [
|
|
2866
|
-
if (this.has(
|
|
2867
|
-
this.set(
|
|
2878
|
+
for (const [key, value] of other.entries()) {
|
|
2879
|
+
if (this.has(key) && conflictResolver) {
|
|
2880
|
+
this.set(key, conflictResolver(this.get(key), value, key));
|
|
2868
2881
|
} else {
|
|
2869
|
-
this.set(
|
|
2882
|
+
this.set(key, value);
|
|
2870
2883
|
}
|
|
2871
2884
|
}
|
|
2872
2885
|
return this;
|
|
2873
2886
|
}
|
|
2874
2887
|
some(fn) {
|
|
2875
|
-
for (const [
|
|
2876
|
-
if (fn(value,
|
|
2888
|
+
for (const [key, value] of this.map) {
|
|
2889
|
+
if (fn(value, key)) return true;
|
|
2877
2890
|
}
|
|
2878
2891
|
return false;
|
|
2879
2892
|
}
|
|
2880
2893
|
every(fn) {
|
|
2881
|
-
for (const [
|
|
2882
|
-
if (!fn(value,
|
|
2894
|
+
for (const [key, value] of this.map) {
|
|
2895
|
+
if (!fn(value, key)) return false;
|
|
2883
2896
|
}
|
|
2884
2897
|
return true;
|
|
2885
2898
|
}
|
|
2886
2899
|
filter(predicate) {
|
|
2887
2900
|
const result = new this.constructor();
|
|
2888
|
-
for (const [
|
|
2889
|
-
if (predicate(value,
|
|
2901
|
+
for (const [key, value] of this.map) {
|
|
2902
|
+
if (predicate(value, key, this)) result.set(key, value);
|
|
2890
2903
|
}
|
|
2891
2904
|
return result;
|
|
2892
2905
|
}
|
|
@@ -2909,41 +2922,48 @@ var Map1 = class _Map1 {
|
|
|
2909
2922
|
start = first;
|
|
2910
2923
|
}
|
|
2911
2924
|
for (let current = start; !current.done; current = iterator.next()) {
|
|
2912
|
-
const [
|
|
2913
|
-
acc = fn(acc, value,
|
|
2925
|
+
const [key, value] = current.value;
|
|
2926
|
+
acc = fn(acc, value, key);
|
|
2914
2927
|
}
|
|
2915
2928
|
return acc;
|
|
2916
2929
|
}
|
|
2917
2930
|
mapEntries(fn) {
|
|
2918
2931
|
let result = [];
|
|
2919
|
-
for (const [
|
|
2920
|
-
result.push(fn(value,
|
|
2932
|
+
for (const [key, value] of this.map) {
|
|
2933
|
+
result.push(fn(value, key));
|
|
2921
2934
|
}
|
|
2922
2935
|
return result;
|
|
2923
2936
|
}
|
|
2924
2937
|
mapValues(fn) {
|
|
2925
|
-
let result = new
|
|
2926
|
-
for (const [
|
|
2927
|
-
result.set(
|
|
2938
|
+
let result = new _UniMap();
|
|
2939
|
+
for (const [key, value] of this.map) {
|
|
2940
|
+
result.set(key, fn(value, key));
|
|
2928
2941
|
}
|
|
2929
2942
|
return result;
|
|
2930
2943
|
}
|
|
2931
2944
|
toMap() {
|
|
2932
|
-
return new Map(this.
|
|
2945
|
+
return new Map(this.map);
|
|
2933
2946
|
}
|
|
2934
2947
|
toString() {
|
|
2935
|
-
const entries = [...this.
|
|
2936
|
-
return `
|
|
2948
|
+
const entries = [...this.map].map(([k, v]) => `${stringify(k)} => ${stringify(v)}`).join(", ");
|
|
2949
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
|
|
2937
2950
|
}
|
|
2938
2951
|
};
|
|
2939
2952
|
|
|
2940
|
-
// src/core/
|
|
2941
|
-
var
|
|
2953
|
+
// src/core/bi-map.ts
|
|
2954
|
+
var BiMap = class _BiMap extends BaseContainer {
|
|
2942
2955
|
constructor(entries) {
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2956
|
+
super();
|
|
2957
|
+
__publicField(this, "map1");
|
|
2958
|
+
__publicField(this, "key1Equals", DefaultEqualityFn);
|
|
2959
|
+
__publicField(this, "key2Equals", DefaultEqualityFn);
|
|
2960
|
+
this.map1 = new UniMap(this.key1Equals);
|
|
2961
|
+
if (entries instanceof _BiMap) {
|
|
2962
|
+
for (const [key1, map2] of entries.map1) {
|
|
2963
|
+
const newMap2 = this.map1.set(key1, new UniMap(this.key2Equals));
|
|
2964
|
+
for (const [key2, value] of map2) {
|
|
2965
|
+
newMap2.set(key2, value);
|
|
2966
|
+
}
|
|
2947
2967
|
}
|
|
2948
2968
|
} else if (entries) {
|
|
2949
2969
|
for (const [key1, key2, value] of entries) {
|
|
@@ -2955,9 +2975,7 @@ var Map2 = class _Map2 {
|
|
|
2955
2975
|
return this.map1.get(key1)?.has(key2) ?? false;
|
|
2956
2976
|
}
|
|
2957
2977
|
set(key1, key2, value) {
|
|
2958
|
-
|
|
2959
|
-
map2.set(key2, value);
|
|
2960
|
-
return value;
|
|
2978
|
+
return this.map1.getOrCreate(key1, () => new UniMap(this.key2Equals)).set(key2, value);
|
|
2961
2979
|
}
|
|
2962
2980
|
get(key1, key2) {
|
|
2963
2981
|
return this.map1.get(key1)?.get(key2);
|
|
@@ -3035,7 +3053,7 @@ var Map2 = class _Map2 {
|
|
|
3035
3053
|
yield* this.entries();
|
|
3036
3054
|
}
|
|
3037
3055
|
clone() {
|
|
3038
|
-
return new
|
|
3056
|
+
return new _BiMap(this);
|
|
3039
3057
|
}
|
|
3040
3058
|
merge(other, conflictResolver) {
|
|
3041
3059
|
for (const [key1, key2, value] of other.entries()) {
|
|
@@ -3106,7 +3124,7 @@ var Map2 = class _Map2 {
|
|
|
3106
3124
|
return result;
|
|
3107
3125
|
}
|
|
3108
3126
|
mapValues(fn) {
|
|
3109
|
-
let result = new
|
|
3127
|
+
let result = new _BiMap();
|
|
3110
3128
|
for (const [key1, map2] of this.map1) {
|
|
3111
3129
|
for (const [key2, value] of map2) {
|
|
3112
3130
|
result.set(key1, key2, fn(value, key1, key2));
|
|
@@ -3126,24 +3144,28 @@ var Map2 = class _Map2 {
|
|
|
3126
3144
|
toString() {
|
|
3127
3145
|
const entries = [];
|
|
3128
3146
|
for (const [key1, map2] of this.map1) {
|
|
3129
|
-
const inner = [...map2].map(([key2, v]) => `${
|
|
3130
|
-
entries.push(`${
|
|
3147
|
+
const inner = [...map2].map(([key2, v]) => `${stringify(key2)} => ${stringify(v)}`).join(", ");
|
|
3148
|
+
entries.push(`${stringify(key1)} => { ${inner} }`);
|
|
3131
3149
|
}
|
|
3132
|
-
return `
|
|
3150
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
|
|
3133
3151
|
}
|
|
3134
3152
|
};
|
|
3135
3153
|
|
|
3136
|
-
// src/core/
|
|
3137
|
-
var
|
|
3154
|
+
// src/core/tri-map.ts
|
|
3155
|
+
var TriMap = class _TriMap extends BaseContainer {
|
|
3138
3156
|
constructor(entries) {
|
|
3139
|
-
|
|
3140
|
-
|
|
3157
|
+
super();
|
|
3158
|
+
__publicField(this, "map1");
|
|
3159
|
+
__publicField(this, "key1Equals", DefaultEqualityFn);
|
|
3160
|
+
__publicField(this, "key2Equals", DefaultEqualityFn);
|
|
3161
|
+
__publicField(this, "key3Equals", DefaultEqualityFn);
|
|
3162
|
+
this.map1 = new UniMap(this.key1Equals);
|
|
3163
|
+
if (entries instanceof _TriMap) {
|
|
3141
3164
|
for (const [key1, map2] of entries.map1) {
|
|
3142
|
-
const newMap2 =
|
|
3165
|
+
const newMap2 = this.map1.set(key1, new UniMap(this.key2Equals));
|
|
3143
3166
|
for (const [key2, map3] of map2) {
|
|
3144
|
-
newMap2.set(key2, new
|
|
3167
|
+
newMap2.set(key2, new UniMap(map3, this.key3Equals));
|
|
3145
3168
|
}
|
|
3146
|
-
this.map1.set(key1, newMap2);
|
|
3147
3169
|
}
|
|
3148
3170
|
} else if (entries) {
|
|
3149
3171
|
for (const [key1, key2, key3, value] of entries) {
|
|
@@ -3155,10 +3177,8 @@ var Map3 = class _Map3 {
|
|
|
3155
3177
|
return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
|
|
3156
3178
|
}
|
|
3157
3179
|
set(key1, key2, key3, value) {
|
|
3158
|
-
let map2 = this.map1.
|
|
3159
|
-
|
|
3160
|
-
let map3 = map2.get(key2);
|
|
3161
|
-
if (!map3) map2.set(key2, map3 = /* @__PURE__ */ new Map());
|
|
3180
|
+
let map2 = this.map1.getOrCreate(key1, () => new UniMap(this.key2Equals));
|
|
3181
|
+
let map3 = map2.getOrCreate(key2, () => new UniMap(this.key3Equals));
|
|
3162
3182
|
map3.set(key3, value);
|
|
3163
3183
|
return value;
|
|
3164
3184
|
}
|
|
@@ -3250,7 +3270,7 @@ var Map3 = class _Map3 {
|
|
|
3250
3270
|
yield* this.entries();
|
|
3251
3271
|
}
|
|
3252
3272
|
clone() {
|
|
3253
|
-
return new
|
|
3273
|
+
return new _TriMap(this);
|
|
3254
3274
|
}
|
|
3255
3275
|
merge(other, conflictResolver) {
|
|
3256
3276
|
for (const [key1, key2, key3, value] of other.entries()) {
|
|
@@ -3329,7 +3349,7 @@ var Map3 = class _Map3 {
|
|
|
3329
3349
|
return result;
|
|
3330
3350
|
}
|
|
3331
3351
|
mapValues(fn) {
|
|
3332
|
-
let result = new
|
|
3352
|
+
let result = new _TriMap();
|
|
3333
3353
|
for (const [key1, map2] of this.map1) {
|
|
3334
3354
|
for (const [key2, map3] of map2) {
|
|
3335
3355
|
for (const [key3, value] of map3) {
|
|
@@ -3354,22 +3374,32 @@ var Map3 = class _Map3 {
|
|
|
3354
3374
|
const entries = [];
|
|
3355
3375
|
for (const [key1, map2] of this.map1) {
|
|
3356
3376
|
for (const [key2, map3] of map2) {
|
|
3357
|
-
const inner = [...map3].map(([key3, v]) => `${
|
|
3358
|
-
entries.push(`${
|
|
3377
|
+
const inner = [...map3].map(([key3, v]) => `${stringify(key3)} => ${stringify(v)}`).join(", ");
|
|
3378
|
+
entries.push(`${stringify(key1)} => ${stringify(key2)} => { ${inner} }`);
|
|
3359
3379
|
}
|
|
3360
3380
|
}
|
|
3361
|
-
return `
|
|
3381
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries.join(", ")} }`;
|
|
3362
3382
|
}
|
|
3363
3383
|
};
|
|
3364
3384
|
|
|
3365
3385
|
// src/core/set.ts
|
|
3366
|
-
var
|
|
3367
|
-
constructor(
|
|
3386
|
+
var ValueSet = class _ValueSet extends BaseContainer {
|
|
3387
|
+
constructor(...args) {
|
|
3388
|
+
super();
|
|
3368
3389
|
__publicField(this, "data");
|
|
3369
|
-
this
|
|
3390
|
+
__publicField(this, "equals");
|
|
3391
|
+
const maybeEquals = args.at(-1);
|
|
3392
|
+
this.equals = isFunction2(maybeEquals) ? args.pop() : DefaultEqualityFn;
|
|
3393
|
+
const entries = args[0];
|
|
3394
|
+
this.data = new Set(entries);
|
|
3395
|
+
}
|
|
3396
|
+
static createDeep(arg) {
|
|
3397
|
+
return arg ? new _ValueSet(arg, isDeepEqual2) : new _ValueSet(isDeepEqual2);
|
|
3370
3398
|
}
|
|
3371
3399
|
has(value) {
|
|
3372
|
-
|
|
3400
|
+
if (this.equals === DefaultEqualityFn)
|
|
3401
|
+
return this.data.has(value);
|
|
3402
|
+
return this.some((v) => this.equals(v, value));
|
|
3373
3403
|
}
|
|
3374
3404
|
add(value) {
|
|
3375
3405
|
if (!this.has(value))
|
|
@@ -3378,8 +3408,8 @@ var SetBase = class {
|
|
|
3378
3408
|
}
|
|
3379
3409
|
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
3380
3410
|
set(key, value) {
|
|
3381
|
-
if (!this.
|
|
3382
|
-
throw new TypeError("
|
|
3411
|
+
if (!this.equals(key, value))
|
|
3412
|
+
throw new TypeError("ValueSet.set() requires key === value.");
|
|
3383
3413
|
this.add(value);
|
|
3384
3414
|
}
|
|
3385
3415
|
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
@@ -3399,9 +3429,10 @@ var SetBase = class {
|
|
|
3399
3429
|
return this.get(key);
|
|
3400
3430
|
}
|
|
3401
3431
|
delete(value) {
|
|
3402
|
-
if (
|
|
3432
|
+
if (this.equals === DefaultEqualityFn || this.data.has(value))
|
|
3433
|
+
return this.data.delete(value);
|
|
3403
3434
|
for (const v of this.values()) {
|
|
3404
|
-
if (this.
|
|
3435
|
+
if (this.equals(v, value)) {
|
|
3405
3436
|
this.data.delete(v);
|
|
3406
3437
|
return true;
|
|
3407
3438
|
}
|
|
@@ -3448,7 +3479,7 @@ var SetBase = class {
|
|
|
3448
3479
|
yield* this.values();
|
|
3449
3480
|
}
|
|
3450
3481
|
clone() {
|
|
3451
|
-
const result =
|
|
3482
|
+
const result = new _ValueSet();
|
|
3452
3483
|
for (const v of this.values()) result.add(v);
|
|
3453
3484
|
return result;
|
|
3454
3485
|
}
|
|
@@ -3471,7 +3502,7 @@ var SetBase = class {
|
|
|
3471
3502
|
return true;
|
|
3472
3503
|
}
|
|
3473
3504
|
filter(predicate) {
|
|
3474
|
-
const result =
|
|
3505
|
+
const result = new _ValueSet();
|
|
3475
3506
|
for (const value of this.data)
|
|
3476
3507
|
if (predicate(value, this)) result.add(value);
|
|
3477
3508
|
return result;
|
|
@@ -3481,7 +3512,7 @@ var SetBase = class {
|
|
|
3481
3512
|
let first = iterator.next();
|
|
3482
3513
|
if (first.done) {
|
|
3483
3514
|
if (arguments.length < 2) {
|
|
3484
|
-
throw new TypeError("Reduce of empty
|
|
3515
|
+
throw new TypeError("Reduce of empty ValueSet with no initial value!");
|
|
3485
3516
|
}
|
|
3486
3517
|
return init;
|
|
3487
3518
|
}
|
|
@@ -3501,7 +3532,7 @@ var SetBase = class {
|
|
|
3501
3532
|
return acc;
|
|
3502
3533
|
}
|
|
3503
3534
|
mapValues(fn) {
|
|
3504
|
-
let result =
|
|
3535
|
+
let result = new _ValueSet();
|
|
3505
3536
|
for (const value of this.data) {
|
|
3506
3537
|
result.add(fn(value));
|
|
3507
3538
|
}
|
|
@@ -3515,7 +3546,7 @@ var SetBase = class {
|
|
|
3515
3546
|
return result;
|
|
3516
3547
|
}
|
|
3517
3548
|
map(fn) {
|
|
3518
|
-
let result =
|
|
3549
|
+
let result = new _ValueSet();
|
|
3519
3550
|
for (const value of this.values()) {
|
|
3520
3551
|
result.add(fn(value));
|
|
3521
3552
|
}
|
|
@@ -3528,41 +3559,14 @@ var SetBase = class {
|
|
|
3528
3559
|
return [...this.values()];
|
|
3529
3560
|
}
|
|
3530
3561
|
toString() {
|
|
3531
|
-
return
|
|
3532
|
-
}
|
|
3533
|
-
};
|
|
3534
|
-
var Set1 = class _Set1 extends SetBase {
|
|
3535
|
-
constructor(entries) {
|
|
3536
|
-
super(entries);
|
|
3537
|
-
}
|
|
3538
|
-
createEmpty() {
|
|
3539
|
-
return new _Set1();
|
|
3540
|
-
}
|
|
3541
|
-
valueEquals(a, b) {
|
|
3542
|
-
return a === b;
|
|
3543
|
-
}
|
|
3544
|
-
getName() {
|
|
3545
|
-
return "Set1";
|
|
3546
|
-
}
|
|
3547
|
-
};
|
|
3548
|
-
var DeepSet = class _DeepSet extends SetBase {
|
|
3549
|
-
constructor(entries) {
|
|
3550
|
-
super(entries);
|
|
3551
|
-
}
|
|
3552
|
-
createEmpty() {
|
|
3553
|
-
return new _DeepSet();
|
|
3554
|
-
}
|
|
3555
|
-
valueEquals(a, b) {
|
|
3556
|
-
return isDeepEqual2(a, b);
|
|
3557
|
-
}
|
|
3558
|
-
getName() {
|
|
3559
|
-
return "DeepSet";
|
|
3562
|
+
return stringify(this.data);
|
|
3560
3563
|
}
|
|
3561
3564
|
};
|
|
3562
3565
|
|
|
3563
3566
|
// src/core/multi-container.ts
|
|
3564
|
-
var MultiContainer = class {
|
|
3567
|
+
var MultiContainer = class extends BaseContainer {
|
|
3565
3568
|
constructor(base) {
|
|
3569
|
+
super();
|
|
3566
3570
|
this.base = base;
|
|
3567
3571
|
}
|
|
3568
3572
|
isEmpty() {
|
|
@@ -3618,39 +3622,404 @@ var MultiContainer = class {
|
|
|
3618
3622
|
const entries = [];
|
|
3619
3623
|
for (const keys of this.keys()) {
|
|
3620
3624
|
const arr = this.getAll(...keys);
|
|
3621
|
-
const keyStr = Array.isArray(keys) ?
|
|
3622
|
-
const valuesStr = Array.isArray(arr) ?
|
|
3625
|
+
const keyStr = Array.isArray(keys) ? stringify(keys) : "[ ]";
|
|
3626
|
+
const valuesStr = Array.isArray(arr) ? stringify(arr) : "[ ]";
|
|
3623
3627
|
entries.push(`${keyStr} => ${valuesStr}`);
|
|
3624
3628
|
}
|
|
3625
|
-
return `MultiContainer{ ${entries.join(", ")} }
|
|
3629
|
+
return entries.length === 0 ? `MultiContainer{ }` : `MultiContainer{ ${entries.join(", ")} }`;
|
|
3626
3630
|
}
|
|
3627
3631
|
};
|
|
3628
3632
|
function asMulti(base) {
|
|
3629
3633
|
return new MultiContainer(base);
|
|
3630
3634
|
}
|
|
3631
3635
|
|
|
3632
|
-
// src/
|
|
3633
|
-
var
|
|
3634
|
-
constructor(
|
|
3635
|
-
|
|
3636
|
-
__publicField(this, "
|
|
3637
|
-
this
|
|
3638
|
-
this.y = y ?? 0;
|
|
3636
|
+
// src/core/linked-list.ts
|
|
3637
|
+
var LinkedListNode = class {
|
|
3638
|
+
constructor(value) {
|
|
3639
|
+
this.value = value;
|
|
3640
|
+
__publicField(this, "next", null);
|
|
3641
|
+
__publicField(this, "prev", null);
|
|
3639
3642
|
}
|
|
3640
|
-
|
|
3641
|
-
|
|
3643
|
+
};
|
|
3644
|
+
var LinkedList = class _LinkedList extends BaseContainer {
|
|
3645
|
+
constructor(...args) {
|
|
3646
|
+
super();
|
|
3647
|
+
__publicField(this, "_head", null);
|
|
3648
|
+
__publicField(this, "_tail", null);
|
|
3649
|
+
__publicField(this, "_size", 0);
|
|
3650
|
+
__publicField(this, "equals");
|
|
3651
|
+
const maybeEquals = args.at(-1);
|
|
3652
|
+
this.equals = isFunction2(maybeEquals) ? args.pop() : DefaultEqualityFn;
|
|
3653
|
+
const entries = args[0];
|
|
3654
|
+
if (entries) {
|
|
3655
|
+
for (const v of entries) {
|
|
3656
|
+
this.push(v);
|
|
3657
|
+
}
|
|
3658
|
+
}
|
|
3642
3659
|
}
|
|
3643
|
-
|
|
3644
|
-
|
|
3660
|
+
static createDeep(entries) {
|
|
3661
|
+
if (entries) {
|
|
3662
|
+
return new _LinkedList(entries, isDeepEqual2);
|
|
3663
|
+
} else {
|
|
3664
|
+
return new _LinkedList(isDeepEqual2);
|
|
3665
|
+
}
|
|
3645
3666
|
}
|
|
3646
|
-
|
|
3647
|
-
return
|
|
3667
|
+
get length() {
|
|
3668
|
+
return this._size;
|
|
3648
3669
|
}
|
|
3649
|
-
|
|
3650
|
-
return
|
|
3670
|
+
get first() {
|
|
3671
|
+
return this._head?.value;
|
|
3651
3672
|
}
|
|
3652
|
-
|
|
3653
|
-
return
|
|
3673
|
+
get last() {
|
|
3674
|
+
return this._tail?.value;
|
|
3675
|
+
}
|
|
3676
|
+
/** Add item to the end of the list */
|
|
3677
|
+
push(value) {
|
|
3678
|
+
const node = new LinkedListNode(value);
|
|
3679
|
+
if (!this._tail) {
|
|
3680
|
+
this._head = this._tail = node;
|
|
3681
|
+
} else {
|
|
3682
|
+
node.prev = this._tail;
|
|
3683
|
+
this._tail.next = node;
|
|
3684
|
+
this._tail = node;
|
|
3685
|
+
}
|
|
3686
|
+
this._size++;
|
|
3687
|
+
}
|
|
3688
|
+
/** Remove item from the end of the list */
|
|
3689
|
+
pop() {
|
|
3690
|
+
if (!this._tail) return void 0;
|
|
3691
|
+
const value = this._tail.value;
|
|
3692
|
+
this._tail = this._tail.prev;
|
|
3693
|
+
if (this._tail) this._tail.next = null;
|
|
3694
|
+
else this._head = null;
|
|
3695
|
+
this._size--;
|
|
3696
|
+
return value;
|
|
3697
|
+
}
|
|
3698
|
+
/** Add item to the beginning of the list */
|
|
3699
|
+
unshift(value) {
|
|
3700
|
+
const node = new LinkedListNode(value);
|
|
3701
|
+
if (!this._head) {
|
|
3702
|
+
this._head = this._tail = node;
|
|
3703
|
+
} else {
|
|
3704
|
+
node.next = this._head;
|
|
3705
|
+
this._head.prev = node;
|
|
3706
|
+
this._head = node;
|
|
3707
|
+
}
|
|
3708
|
+
this._size++;
|
|
3709
|
+
}
|
|
3710
|
+
/** Remove item from the beginning of the list */
|
|
3711
|
+
shift() {
|
|
3712
|
+
if (!this._head) return void 0;
|
|
3713
|
+
const value = this._head.value;
|
|
3714
|
+
this._head = this._head.next;
|
|
3715
|
+
if (this._head) this._head.prev = null;
|
|
3716
|
+
else this._tail = null;
|
|
3717
|
+
this._size--;
|
|
3718
|
+
return value;
|
|
3719
|
+
}
|
|
3720
|
+
/** Check if value exists in the list */
|
|
3721
|
+
has(value) {
|
|
3722
|
+
for (let node = this._head; node; node = node.next) {
|
|
3723
|
+
if (this.equals(node.value, value)) return true;
|
|
3724
|
+
}
|
|
3725
|
+
return false;
|
|
3726
|
+
}
|
|
3727
|
+
/** Get value at index (O(n/2)) */
|
|
3728
|
+
get(index) {
|
|
3729
|
+
return this.nodeAt(index)?.value;
|
|
3730
|
+
}
|
|
3731
|
+
/** Set value at index (O(n/2)) */
|
|
3732
|
+
set(index, value) {
|
|
3733
|
+
const node = this.nodeAt(index);
|
|
3734
|
+
if (!node) return false;
|
|
3735
|
+
node.value = value;
|
|
3736
|
+
return true;
|
|
3737
|
+
}
|
|
3738
|
+
/** Insert value at index (O(n/2)) */
|
|
3739
|
+
insertAt(index, value) {
|
|
3740
|
+
if (index < 0 || index > this._size) return false;
|
|
3741
|
+
if (index === 0) {
|
|
3742
|
+
this.unshift(value);
|
|
3743
|
+
return true;
|
|
3744
|
+
}
|
|
3745
|
+
if (index === this._size) {
|
|
3746
|
+
this.push(value);
|
|
3747
|
+
return true;
|
|
3748
|
+
}
|
|
3749
|
+
const nextNode = this.nodeAt(index);
|
|
3750
|
+
if (!nextNode) return false;
|
|
3751
|
+
const prevNode = nextNode.prev;
|
|
3752
|
+
const newNode = new LinkedListNode(value);
|
|
3753
|
+
newNode.next = nextNode;
|
|
3754
|
+
newNode.prev = prevNode;
|
|
3755
|
+
if (prevNode) prevNode.next = newNode;
|
|
3756
|
+
nextNode.prev = newNode;
|
|
3757
|
+
this._size++;
|
|
3758
|
+
return true;
|
|
3759
|
+
}
|
|
3760
|
+
/** Remove value at index (O(n/2)) */
|
|
3761
|
+
removeAt(index) {
|
|
3762
|
+
const node = this.nodeAt(index);
|
|
3763
|
+
if (!node) return void 0;
|
|
3764
|
+
if (node.prev) node.prev.next = node.next;
|
|
3765
|
+
else this._head = node.next;
|
|
3766
|
+
if (node.next) node.next.prev = node.prev;
|
|
3767
|
+
else this._tail = node.prev;
|
|
3768
|
+
this._size--;
|
|
3769
|
+
return node.value;
|
|
3770
|
+
}
|
|
3771
|
+
/** Remove first matching value (O(n)) */
|
|
3772
|
+
remove(value) {
|
|
3773
|
+
for (let node = this._head; node; node = node.next) {
|
|
3774
|
+
if (this.equals(node.value, value)) {
|
|
3775
|
+
if (node.prev) node.prev.next = node.next;
|
|
3776
|
+
else this._head = node.next;
|
|
3777
|
+
if (node.next) node.next.prev = node.prev;
|
|
3778
|
+
else this._tail = node.prev;
|
|
3779
|
+
this._size--;
|
|
3780
|
+
return true;
|
|
3781
|
+
}
|
|
3782
|
+
}
|
|
3783
|
+
return false;
|
|
3784
|
+
}
|
|
3785
|
+
/** Convert to array */
|
|
3786
|
+
toArray() {
|
|
3787
|
+
const result = [];
|
|
3788
|
+
for (const v of this) result.push(v);
|
|
3789
|
+
return result;
|
|
3790
|
+
}
|
|
3791
|
+
/** Replace contents from array */
|
|
3792
|
+
fromArray(values) {
|
|
3793
|
+
this.clear();
|
|
3794
|
+
for (const v of values) this.push(v);
|
|
3795
|
+
}
|
|
3796
|
+
/** Clear all nodes */
|
|
3797
|
+
clear() {
|
|
3798
|
+
this._head = this._tail = null;
|
|
3799
|
+
this._size = 0;
|
|
3800
|
+
}
|
|
3801
|
+
/** Iterator support */
|
|
3802
|
+
*[Symbol.iterator]() {
|
|
3803
|
+
yield* this.values();
|
|
3804
|
+
}
|
|
3805
|
+
*keys() {
|
|
3806
|
+
for (let id = 0; id < this._size; id++)
|
|
3807
|
+
yield id;
|
|
3808
|
+
}
|
|
3809
|
+
*values() {
|
|
3810
|
+
let node = this._head;
|
|
3811
|
+
while (node) {
|
|
3812
|
+
yield node.value;
|
|
3813
|
+
node = node.next;
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
*entries() {
|
|
3817
|
+
let node = this._head;
|
|
3818
|
+
let id = 0;
|
|
3819
|
+
while (node) {
|
|
3820
|
+
yield [id++, node.value];
|
|
3821
|
+
node = node.next;
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
toString() {
|
|
3825
|
+
return this._size === 0 ? `LinkedList(0)[ ]` : `LinkedList(${this._size})[ ${this.toArray().join(", ")} ]`;
|
|
3826
|
+
}
|
|
3827
|
+
// ---- Private helpers ----
|
|
3828
|
+
nodeAt(index) {
|
|
3829
|
+
if (index < 0 || index >= this._size) return null;
|
|
3830
|
+
let node;
|
|
3831
|
+
if (index < this._size / 2) {
|
|
3832
|
+
node = this._head;
|
|
3833
|
+
for (let i = 0; i < index; i++) node = node.next;
|
|
3834
|
+
} else {
|
|
3835
|
+
node = this._tail;
|
|
3836
|
+
for (let i = this._size - 1; i > index; i--) node = node.prev;
|
|
3837
|
+
}
|
|
3838
|
+
return node;
|
|
3839
|
+
}
|
|
3840
|
+
clone() {
|
|
3841
|
+
return new _LinkedList(this);
|
|
3842
|
+
}
|
|
3843
|
+
};
|
|
3844
|
+
|
|
3845
|
+
// src/utils/str/index.ts
|
|
3846
|
+
function toCharArray(str2) {
|
|
3847
|
+
return str2.split("");
|
|
3848
|
+
}
|
|
3849
|
+
function repeatString(repeatString2, repeatCount) {
|
|
3850
|
+
if (!isInteger2(repeatCount) || repeatCount < 0) {
|
|
3851
|
+
throw new Error("repeatStr: Invalid repeatCount = " + repeatCount);
|
|
3852
|
+
}
|
|
3853
|
+
return new Array(repeatCount + 1).join(repeatString2);
|
|
3854
|
+
}
|
|
3855
|
+
function chunkString(str2, chunkSize) {
|
|
3856
|
+
if (!isInteger2(chunkSize) || chunkSize < 1) {
|
|
3857
|
+
throw new Error("chunckString: Invalid chuckSize = " + chunkSize);
|
|
3858
|
+
}
|
|
3859
|
+
let result = [];
|
|
3860
|
+
for (let i = 0; i < str2.length; i += chunkSize) {
|
|
3861
|
+
result.push(str2.slice(i, i + chunkSize));
|
|
3862
|
+
}
|
|
3863
|
+
return result;
|
|
3864
|
+
}
|
|
3865
|
+
function replaceAt(str2, pos, removeCount, insert) {
|
|
3866
|
+
if (!isInteger2(removeCount) || removeCount < 0) {
|
|
3867
|
+
throw new Error("replaceAt: Invalid removeCount = " + removeCount);
|
|
3868
|
+
} else if (!isInteger2(pos) || pos < 0 || pos + removeCount > str2.length) {
|
|
3869
|
+
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " + str2.length);
|
|
3870
|
+
} else {
|
|
3871
|
+
return str2.substring(0, pos) + insert + str2.substring(pos + removeCount);
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
function insertAt(str2, pos, insertStr) {
|
|
3875
|
+
return replaceAt(str2, pos, 0, insertStr);
|
|
3876
|
+
}
|
|
3877
|
+
function removeAt(str2, pos, removeCount) {
|
|
3878
|
+
return replaceAt(str2, pos, removeCount, "");
|
|
3879
|
+
}
|
|
3880
|
+
function charCount(str2, ch) {
|
|
3881
|
+
if (ch.length !== 1 || str2.length === 0) return 0;
|
|
3882
|
+
let count = 0;
|
|
3883
|
+
for (let i = 0; i < str2.length; i++) {
|
|
3884
|
+
if (str2[i] === ch) count++;
|
|
3885
|
+
}
|
|
3886
|
+
return count;
|
|
3887
|
+
}
|
|
3888
|
+
function makeSentenceFromPascal(PascalString) {
|
|
3889
|
+
if (PascalString === "") {
|
|
3890
|
+
return "";
|
|
3891
|
+
}
|
|
3892
|
+
let word = PascalString.charAt(0);
|
|
3893
|
+
let sentence = "";
|
|
3894
|
+
const addWord = () => {
|
|
3895
|
+
if (word !== "") {
|
|
3896
|
+
if (sentence === "") {
|
|
3897
|
+
sentence += word.charAt(0).toUpperCase() + word.substring(1);
|
|
3898
|
+
} else {
|
|
3899
|
+
sentence += " " + word;
|
|
3900
|
+
}
|
|
3901
|
+
word = "";
|
|
3902
|
+
}
|
|
3903
|
+
};
|
|
3904
|
+
const isLetterAndCapital = (c) => {
|
|
3905
|
+
return c.toUpperCase() !== c.toLowerCase() && c === c.toUpperCase();
|
|
3906
|
+
};
|
|
3907
|
+
for (let i = 1; i < PascalString.length; i++) {
|
|
3908
|
+
let c = PascalString.charAt(i);
|
|
3909
|
+
if (isLetterAndCapital(c)) {
|
|
3910
|
+
addWord();
|
|
3911
|
+
}
|
|
3912
|
+
word += c.toLowerCase();
|
|
3913
|
+
}
|
|
3914
|
+
addWord();
|
|
3915
|
+
return sentence;
|
|
3916
|
+
}
|
|
3917
|
+
function stringify(value, maxDepth = 5, seen = /* @__PURE__ */ new WeakSet()) {
|
|
3918
|
+
if (value === null) return "null";
|
|
3919
|
+
if (value === void 0) return "undefined";
|
|
3920
|
+
const t = typeof value;
|
|
3921
|
+
switch (t) {
|
|
3922
|
+
case "boolean":
|
|
3923
|
+
return value ? "true" : "false";
|
|
3924
|
+
case "number":
|
|
3925
|
+
if (isNaNValue2(value)) return "NaN";
|
|
3926
|
+
if (!isFinite3(value))
|
|
3927
|
+
return value < 0 ? "-Infinity" : "Infinity";
|
|
3928
|
+
return value.toString();
|
|
3929
|
+
case "bigint":
|
|
3930
|
+
return `${value}n`;
|
|
3931
|
+
case "string":
|
|
3932
|
+
return `"${value}"`;
|
|
3933
|
+
case "symbol":
|
|
3934
|
+
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
3935
|
+
case "function":
|
|
3936
|
+
return `[Function${value.name ? ` ${value.name}` : ""}]`;
|
|
3937
|
+
}
|
|
3938
|
+
if (seen.has(value))
|
|
3939
|
+
return "[Circular]";
|
|
3940
|
+
if (maxDepth <= 0)
|
|
3941
|
+
return "[Depth limit]";
|
|
3942
|
+
maxDepth--;
|
|
3943
|
+
seen.add(value);
|
|
3944
|
+
const strfy = (v) => stringify(v, maxDepth, seen);
|
|
3945
|
+
if (isArray2(value)) {
|
|
3946
|
+
const inner = value.map((v) => strfy(v)).join(", ");
|
|
3947
|
+
return inner.length === 0 ? "[ ]" : `[ ${inner} ]`;
|
|
3948
|
+
}
|
|
3949
|
+
if (ArrayBuffer.isView(value)) {
|
|
3950
|
+
if (value instanceof DataView)
|
|
3951
|
+
return `DataView(${value.byteLength})`;
|
|
3952
|
+
const inner = Array.from(value).map((v) => strfy(v)).join(", ");
|
|
3953
|
+
return `${value.constructor.name}[ ${inner} ]`;
|
|
3954
|
+
}
|
|
3955
|
+
if (value instanceof ArrayBuffer)
|
|
3956
|
+
return `ArrayBuffer(${value.byteLength})`;
|
|
3957
|
+
if (value instanceof Map) {
|
|
3958
|
+
const entries = Array.from(value.entries()).map(([k, v]) => `${strfy(k)} => ${strfy(v)}`).join(", ");
|
|
3959
|
+
return entries.length === 0 ? `Map(${value.size}){ }` : `Map(${value.size}){ ${entries} }`;
|
|
3960
|
+
}
|
|
3961
|
+
if (value instanceof Set) {
|
|
3962
|
+
const entries = Array.from(value.values()).map((v) => strfy(v)).join(", ");
|
|
3963
|
+
return entries.length === 0 ? `Set(${value.size}){ }` : `Set(${value.size}){ ${entries} }`;
|
|
3964
|
+
}
|
|
3965
|
+
if (value instanceof WeakMap)
|
|
3966
|
+
return "WeakMap{ ? }";
|
|
3967
|
+
if (value instanceof WeakSet)
|
|
3968
|
+
return "WeakSet{ ? }";
|
|
3969
|
+
if (typeof BaseContainer !== "undefined" && value instanceof BaseContainer)
|
|
3970
|
+
return value.toString();
|
|
3971
|
+
if (value instanceof Date)
|
|
3972
|
+
return `Date("${value.toISOString()}")`;
|
|
3973
|
+
if (value instanceof RegExp)
|
|
3974
|
+
return value.toString();
|
|
3975
|
+
if (value instanceof Error)
|
|
3976
|
+
return `${value.name}("${value.message}")`;
|
|
3977
|
+
if (value instanceof Promise)
|
|
3978
|
+
return "Promise{ ? }";
|
|
3979
|
+
if (value instanceof URL)
|
|
3980
|
+
return `URL("${value.href}")`;
|
|
3981
|
+
if (value instanceof URLSearchParams)
|
|
3982
|
+
return `URLSearchParams("${value.toString()}")`;
|
|
3983
|
+
if (value === Math) return "Math";
|
|
3984
|
+
if (value === JSON) return "JSON";
|
|
3985
|
+
if (value === Reflect) return "Reflect";
|
|
3986
|
+
if (value === Intl) return "Intl";
|
|
3987
|
+
if (t === "object") {
|
|
3988
|
+
const ctorName = value.constructor?.name ?? "Object";
|
|
3989
|
+
const entries = Object.entries(value).map(
|
|
3990
|
+
([key, val]) => `${strfy(key)}: ${strfy(val)}`
|
|
3991
|
+
);
|
|
3992
|
+
if (entries.length === 0) return `${ctorName}{ }`;
|
|
3993
|
+
return `${ctorName}{ ${entries.join(", ")} }`;
|
|
3994
|
+
}
|
|
3995
|
+
return String(value);
|
|
3996
|
+
}
|
|
3997
|
+
|
|
3998
|
+
// src/utils/index.ts
|
|
3999
|
+
var Is = guard_exports;
|
|
4000
|
+
|
|
4001
|
+
// src/deprecated/vec2.ts
|
|
4002
|
+
var Vec2 = class _Vec2 {
|
|
4003
|
+
constructor(x, y) {
|
|
4004
|
+
__publicField(this, "x");
|
|
4005
|
+
__publicField(this, "y");
|
|
4006
|
+
this.x = x ?? 0;
|
|
4007
|
+
this.y = y ?? 0;
|
|
4008
|
+
}
|
|
4009
|
+
length() {
|
|
4010
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
4011
|
+
}
|
|
4012
|
+
add(a) {
|
|
4013
|
+
return new _Vec2(this.x + a.x, this.y + a.y);
|
|
4014
|
+
}
|
|
4015
|
+
sub(a) {
|
|
4016
|
+
return new _Vec2(this.x - a.x, this.y - a.y);
|
|
4017
|
+
}
|
|
4018
|
+
mul(a) {
|
|
4019
|
+
return new _Vec2(this.x * a, this.y * a);
|
|
4020
|
+
}
|
|
4021
|
+
div(a) {
|
|
4022
|
+
return new _Vec2(this.x / a, this.y / a);
|
|
3654
4023
|
}
|
|
3655
4024
|
};
|
|
3656
4025
|
|
|
@@ -3705,16 +4074,799 @@ var SmallIntCache = class {
|
|
|
3705
4074
|
this.neg = [];
|
|
3706
4075
|
}
|
|
3707
4076
|
};
|
|
4077
|
+
|
|
4078
|
+
// src/deprecated/map1.ts
|
|
4079
|
+
var Map1 = class _Map1 extends BaseContainer {
|
|
4080
|
+
constructor(entries) {
|
|
4081
|
+
super();
|
|
4082
|
+
__publicField(this, "map1");
|
|
4083
|
+
this.map1 = entries instanceof _Map1 ? new Map(entries.map1) : new Map(entries);
|
|
4084
|
+
}
|
|
4085
|
+
has(key1) {
|
|
4086
|
+
return this.map1.has(key1);
|
|
4087
|
+
}
|
|
4088
|
+
set(key1, value) {
|
|
4089
|
+
this.map1.set(key1, value);
|
|
4090
|
+
return value;
|
|
4091
|
+
}
|
|
4092
|
+
get(key1) {
|
|
4093
|
+
return this.map1.get(key1);
|
|
4094
|
+
}
|
|
4095
|
+
getOrDefault(key1, defaultValue) {
|
|
4096
|
+
return this.get(key1) ?? defaultValue;
|
|
4097
|
+
}
|
|
4098
|
+
getOrCreate(key1, creatorOrValue) {
|
|
4099
|
+
if (!this.has(key1)) {
|
|
4100
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
4101
|
+
this.set(key1, value);
|
|
4102
|
+
return value;
|
|
4103
|
+
}
|
|
4104
|
+
return this.get(key1);
|
|
4105
|
+
}
|
|
4106
|
+
delete(key1) {
|
|
4107
|
+
return this.map1.delete(key1);
|
|
4108
|
+
}
|
|
4109
|
+
clear() {
|
|
4110
|
+
this.map1.clear();
|
|
4111
|
+
}
|
|
4112
|
+
get size() {
|
|
4113
|
+
return this.map1.size;
|
|
4114
|
+
}
|
|
4115
|
+
isEmpty() {
|
|
4116
|
+
return this.size === 0;
|
|
4117
|
+
}
|
|
4118
|
+
forEach(callbackfn, thisArg) {
|
|
4119
|
+
this.map1.forEach((value, key1) => callbackfn.call(thisArg, value, key1, this));
|
|
4120
|
+
}
|
|
4121
|
+
*keys() {
|
|
4122
|
+
yield* this.map1.keys();
|
|
4123
|
+
}
|
|
4124
|
+
*values() {
|
|
4125
|
+
yield* this.map1.values();
|
|
4126
|
+
}
|
|
4127
|
+
*entries() {
|
|
4128
|
+
for (const [key1, value] of this.map1)
|
|
4129
|
+
yield [key1, value];
|
|
4130
|
+
}
|
|
4131
|
+
keysArray() {
|
|
4132
|
+
return [...this.keys()];
|
|
4133
|
+
}
|
|
4134
|
+
valuesArray() {
|
|
4135
|
+
return [...this.values()];
|
|
4136
|
+
}
|
|
4137
|
+
entriesArray() {
|
|
4138
|
+
return [...this.entries()];
|
|
4139
|
+
}
|
|
4140
|
+
*kvKeys() {
|
|
4141
|
+
for (const key of this.keys()) {
|
|
4142
|
+
yield [key];
|
|
4143
|
+
}
|
|
4144
|
+
}
|
|
4145
|
+
*kvValues() {
|
|
4146
|
+
for (const el of this.values()) {
|
|
4147
|
+
yield el;
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
*kvEntries() {
|
|
4151
|
+
for (const [key, el] of this.entries()) {
|
|
4152
|
+
yield [[key], el];
|
|
4153
|
+
}
|
|
4154
|
+
}
|
|
4155
|
+
*[Symbol.iterator]() {
|
|
4156
|
+
yield* this.entries();
|
|
4157
|
+
}
|
|
4158
|
+
clone() {
|
|
4159
|
+
return new _Map1(this);
|
|
4160
|
+
}
|
|
4161
|
+
merge(other, conflictResolver) {
|
|
4162
|
+
for (const [key1, value] of other.entries()) {
|
|
4163
|
+
if (this.has(key1) && conflictResolver) {
|
|
4164
|
+
this.set(key1, conflictResolver(this.get(key1), value, key1));
|
|
4165
|
+
} else {
|
|
4166
|
+
this.set(key1, value);
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4169
|
+
return this;
|
|
4170
|
+
}
|
|
4171
|
+
some(fn) {
|
|
4172
|
+
for (const [key1, value] of this.map1) {
|
|
4173
|
+
if (fn(value, key1)) return true;
|
|
4174
|
+
}
|
|
4175
|
+
return false;
|
|
4176
|
+
}
|
|
4177
|
+
every(fn) {
|
|
4178
|
+
for (const [key1, value] of this.map1) {
|
|
4179
|
+
if (!fn(value, key1)) return false;
|
|
4180
|
+
}
|
|
4181
|
+
return true;
|
|
4182
|
+
}
|
|
4183
|
+
filter(predicate) {
|
|
4184
|
+
const result = new this.constructor();
|
|
4185
|
+
for (const [key1, value] of this.map1) {
|
|
4186
|
+
if (predicate(value, key1, this)) result.set(key1, value);
|
|
4187
|
+
}
|
|
4188
|
+
return result;
|
|
4189
|
+
}
|
|
4190
|
+
reduce(fn, init) {
|
|
4191
|
+
let iterator = this.entries();
|
|
4192
|
+
let first = iterator.next();
|
|
4193
|
+
if (first.done) {
|
|
4194
|
+
if (arguments.length < 2) {
|
|
4195
|
+
throw new TypeError("Reduce of empty Map1 with no initial value!");
|
|
4196
|
+
}
|
|
4197
|
+
return init;
|
|
4198
|
+
}
|
|
4199
|
+
let acc;
|
|
4200
|
+
let start;
|
|
4201
|
+
if (arguments.length < 2) {
|
|
4202
|
+
acc = first.value[1];
|
|
4203
|
+
start = iterator.next();
|
|
4204
|
+
} else {
|
|
4205
|
+
acc = init;
|
|
4206
|
+
start = first;
|
|
4207
|
+
}
|
|
4208
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
4209
|
+
const [key1, value] = current.value;
|
|
4210
|
+
acc = fn(acc, value, key1);
|
|
4211
|
+
}
|
|
4212
|
+
return acc;
|
|
4213
|
+
}
|
|
4214
|
+
mapEntries(fn) {
|
|
4215
|
+
let result = [];
|
|
4216
|
+
for (const [key1, value] of this.map1) {
|
|
4217
|
+
result.push(fn(value, key1));
|
|
4218
|
+
}
|
|
4219
|
+
return result;
|
|
4220
|
+
}
|
|
4221
|
+
mapValues(fn) {
|
|
4222
|
+
let result = new _Map1();
|
|
4223
|
+
for (const [key1, value] of this.map1) {
|
|
4224
|
+
result.set(key1, fn(value, key1));
|
|
4225
|
+
}
|
|
4226
|
+
return result;
|
|
4227
|
+
}
|
|
4228
|
+
toMap() {
|
|
4229
|
+
return new Map(this.map1);
|
|
4230
|
+
}
|
|
4231
|
+
toString() {
|
|
4232
|
+
const entries = [...this.map1].map(([k, v]) => `${stringify(k)} => ${stringify(v)}`).join(", ");
|
|
4233
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
|
|
4234
|
+
}
|
|
4235
|
+
};
|
|
4236
|
+
|
|
4237
|
+
// src/deprecated/map2.ts
|
|
4238
|
+
var Map2 = class _Map2 extends BaseContainer {
|
|
4239
|
+
constructor(entries) {
|
|
4240
|
+
super();
|
|
4241
|
+
__publicField(this, "map1", /* @__PURE__ */ new Map());
|
|
4242
|
+
if (entries instanceof _Map2) {
|
|
4243
|
+
for (const [key1, inner] of entries.map1) {
|
|
4244
|
+
this.map1.set(key1, new Map(inner));
|
|
4245
|
+
}
|
|
4246
|
+
} else if (entries) {
|
|
4247
|
+
for (const [key1, key2, value] of entries) {
|
|
4248
|
+
this.set(key1, key2, value);
|
|
4249
|
+
}
|
|
4250
|
+
}
|
|
4251
|
+
}
|
|
4252
|
+
has(key1, key2) {
|
|
4253
|
+
return this.map1.get(key1)?.has(key2) ?? false;
|
|
4254
|
+
}
|
|
4255
|
+
set(key1, key2, value) {
|
|
4256
|
+
let map2 = this.map1.get(key1) ?? this.map1.set(key1, /* @__PURE__ */ new Map()).get(key1);
|
|
4257
|
+
map2.set(key2, value);
|
|
4258
|
+
return value;
|
|
4259
|
+
}
|
|
4260
|
+
get(key1, key2) {
|
|
4261
|
+
return this.map1.get(key1)?.get(key2);
|
|
4262
|
+
}
|
|
4263
|
+
getOrDefault(key1, key2, defaultValue) {
|
|
4264
|
+
return this.get(key1, key2) ?? defaultValue;
|
|
4265
|
+
}
|
|
4266
|
+
getOrCreate(key1, key2, creatorOrValue) {
|
|
4267
|
+
if (!this.has(key1, key2)) {
|
|
4268
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
4269
|
+
this.set(key1, key2, value);
|
|
4270
|
+
return value;
|
|
4271
|
+
}
|
|
4272
|
+
return this.get(key1, key2);
|
|
4273
|
+
}
|
|
4274
|
+
delete(key1, key2) {
|
|
4275
|
+
if (key2 === void 0) return this.map1.delete(key1);
|
|
4276
|
+
const map2 = this.map1.get(key1);
|
|
4277
|
+
if (!map2) return false;
|
|
4278
|
+
return map2.delete(key2);
|
|
4279
|
+
}
|
|
4280
|
+
clear() {
|
|
4281
|
+
this.map1.clear();
|
|
4282
|
+
}
|
|
4283
|
+
get size() {
|
|
4284
|
+
let count = 0;
|
|
4285
|
+
for (const map2 of this.map1.values()) {
|
|
4286
|
+
count += map2.size;
|
|
4287
|
+
}
|
|
4288
|
+
return count;
|
|
4289
|
+
}
|
|
4290
|
+
isEmpty() {
|
|
4291
|
+
return this.size === 0;
|
|
4292
|
+
}
|
|
4293
|
+
forEach(callbackfn, thisArg) {
|
|
4294
|
+
this.map1.forEach((map2, key1) => map2.forEach((value, key2) => callbackfn.call(thisArg, value, key1, key2, this)));
|
|
4295
|
+
}
|
|
4296
|
+
*keys() {
|
|
4297
|
+
for (const [key1, map2] of this.map1)
|
|
4298
|
+
for (const key2 of map2.keys())
|
|
4299
|
+
yield [key1, key2];
|
|
4300
|
+
}
|
|
4301
|
+
*values() {
|
|
4302
|
+
for (const map2 of this.map1.values())
|
|
4303
|
+
for (const value of map2.values())
|
|
4304
|
+
yield value;
|
|
4305
|
+
}
|
|
4306
|
+
*entries() {
|
|
4307
|
+
for (const [key1, map2] of this.map1)
|
|
4308
|
+
for (const [key2, value] of map2)
|
|
4309
|
+
yield [key1, key2, value];
|
|
4310
|
+
}
|
|
4311
|
+
keysArray() {
|
|
4312
|
+
return [...this.keys()];
|
|
4313
|
+
}
|
|
4314
|
+
valuesArray() {
|
|
4315
|
+
return [...this.values()];
|
|
4316
|
+
}
|
|
4317
|
+
entriesArray() {
|
|
4318
|
+
return [...this.entries()];
|
|
4319
|
+
}
|
|
4320
|
+
*kvKeys() {
|
|
4321
|
+
for (const [key1, key2] of this.keys())
|
|
4322
|
+
yield [key1, key2];
|
|
4323
|
+
}
|
|
4324
|
+
*kvValues() {
|
|
4325
|
+
for (const el of this.values())
|
|
4326
|
+
yield el;
|
|
4327
|
+
}
|
|
4328
|
+
*kvEntries() {
|
|
4329
|
+
for (const [key1, key2, el] of this.entries())
|
|
4330
|
+
yield [[key1, key2], el];
|
|
4331
|
+
}
|
|
4332
|
+
*[Symbol.iterator]() {
|
|
4333
|
+
yield* this.entries();
|
|
4334
|
+
}
|
|
4335
|
+
clone() {
|
|
4336
|
+
return new _Map2(this);
|
|
4337
|
+
}
|
|
4338
|
+
merge(other, conflictResolver) {
|
|
4339
|
+
for (const [key1, key2, value] of other.entries()) {
|
|
4340
|
+
if (this.has(key1, key2) && conflictResolver) {
|
|
4341
|
+
this.set(key1, key2, conflictResolver(this.get(key1, key2), value, key1, key2));
|
|
4342
|
+
} else {
|
|
4343
|
+
this.set(key1, key2, value);
|
|
4344
|
+
}
|
|
4345
|
+
}
|
|
4346
|
+
return this;
|
|
4347
|
+
}
|
|
4348
|
+
some(fn) {
|
|
4349
|
+
for (const [key1, map2] of this.map1) {
|
|
4350
|
+
for (const [key2, value] of map2) {
|
|
4351
|
+
if (fn(value, key1, key2)) return true;
|
|
4352
|
+
}
|
|
4353
|
+
}
|
|
4354
|
+
return false;
|
|
4355
|
+
}
|
|
4356
|
+
every(fn) {
|
|
4357
|
+
for (const [key1, map2] of this.map1) {
|
|
4358
|
+
for (const [key2, value] of map2) {
|
|
4359
|
+
if (!fn(value, key1, key2)) return false;
|
|
4360
|
+
}
|
|
4361
|
+
}
|
|
4362
|
+
return true;
|
|
4363
|
+
}
|
|
4364
|
+
filter(predicate) {
|
|
4365
|
+
const result = new this.constructor();
|
|
4366
|
+
for (const [key1, map2] of this.map1) {
|
|
4367
|
+
for (const [key2, value] of map2) {
|
|
4368
|
+
if (predicate(value, key1, key2, this)) result.set(key1, key2, value);
|
|
4369
|
+
}
|
|
4370
|
+
}
|
|
4371
|
+
return result;
|
|
4372
|
+
}
|
|
4373
|
+
reduce(fn, init) {
|
|
4374
|
+
let iterator = this.entries();
|
|
4375
|
+
let first = iterator.next();
|
|
4376
|
+
if (first.done) {
|
|
4377
|
+
if (arguments.length < 2) {
|
|
4378
|
+
throw new TypeError("Reduce of empty Map2 with no initial value!");
|
|
4379
|
+
}
|
|
4380
|
+
return init;
|
|
4381
|
+
}
|
|
4382
|
+
let acc;
|
|
4383
|
+
let start;
|
|
4384
|
+
if (arguments.length < 2) {
|
|
4385
|
+
acc = first.value[2];
|
|
4386
|
+
start = iterator.next();
|
|
4387
|
+
} else {
|
|
4388
|
+
acc = init;
|
|
4389
|
+
start = first;
|
|
4390
|
+
}
|
|
4391
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
4392
|
+
const [key1, key2, value] = current.value;
|
|
4393
|
+
acc = fn(acc, value, key1, key2);
|
|
4394
|
+
}
|
|
4395
|
+
return acc;
|
|
4396
|
+
}
|
|
4397
|
+
mapEntries(fn) {
|
|
4398
|
+
let result = [];
|
|
4399
|
+
for (const [key1, map2] of this.map1) {
|
|
4400
|
+
for (const [key2, value] of map2) {
|
|
4401
|
+
result.push(fn(value, key1, key2));
|
|
4402
|
+
}
|
|
4403
|
+
}
|
|
4404
|
+
return result;
|
|
4405
|
+
}
|
|
4406
|
+
mapValues(fn) {
|
|
4407
|
+
let result = new _Map2();
|
|
4408
|
+
for (const [key1, map2] of this.map1) {
|
|
4409
|
+
for (const [key2, value] of map2) {
|
|
4410
|
+
result.set(key1, key2, fn(value, key1, key2));
|
|
4411
|
+
}
|
|
4412
|
+
}
|
|
4413
|
+
return result;
|
|
4414
|
+
}
|
|
4415
|
+
toMap() {
|
|
4416
|
+
let result = /* @__PURE__ */ new Map();
|
|
4417
|
+
for (const [key1, map2] of this.map1) {
|
|
4418
|
+
for (const [key2, value] of map2) {
|
|
4419
|
+
result.set([key1, key2], value);
|
|
4420
|
+
}
|
|
4421
|
+
}
|
|
4422
|
+
return result;
|
|
4423
|
+
}
|
|
4424
|
+
toString() {
|
|
4425
|
+
const entries = [];
|
|
4426
|
+
for (const [key1, map2] of this.map1) {
|
|
4427
|
+
const inner = [...map2].map(([key2, v]) => `${stringify(key2)} => ${stringify(v)}`).join(", ");
|
|
4428
|
+
entries.push(`${stringify(key1)} => { ${inner} }`);
|
|
4429
|
+
}
|
|
4430
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
|
|
4431
|
+
}
|
|
4432
|
+
};
|
|
4433
|
+
|
|
4434
|
+
// src/deprecated/map3.ts
|
|
4435
|
+
var Map3 = class _Map3 extends BaseContainer {
|
|
4436
|
+
constructor(entries) {
|
|
4437
|
+
super();
|
|
4438
|
+
__publicField(this, "map1", /* @__PURE__ */ new Map());
|
|
4439
|
+
if (entries instanceof _Map3) {
|
|
4440
|
+
for (const [key1, map2] of entries.map1) {
|
|
4441
|
+
const newMap2 = /* @__PURE__ */ new Map();
|
|
4442
|
+
for (const [key2, map3] of map2) {
|
|
4443
|
+
newMap2.set(key2, new Map(map3));
|
|
4444
|
+
}
|
|
4445
|
+
this.map1.set(key1, newMap2);
|
|
4446
|
+
}
|
|
4447
|
+
} else if (entries) {
|
|
4448
|
+
for (const [key1, key2, key3, value] of entries) {
|
|
4449
|
+
this.set(key1, key2, key3, value);
|
|
4450
|
+
}
|
|
4451
|
+
}
|
|
4452
|
+
}
|
|
4453
|
+
has(key1, key2, key3) {
|
|
4454
|
+
return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
|
|
4455
|
+
}
|
|
4456
|
+
set(key1, key2, key3, value) {
|
|
4457
|
+
let map2 = this.map1.get(key1);
|
|
4458
|
+
if (!map2) this.map1.set(key1, map2 = /* @__PURE__ */ new Map());
|
|
4459
|
+
let map3 = map2.get(key2);
|
|
4460
|
+
if (!map3) map2.set(key2, map3 = /* @__PURE__ */ new Map());
|
|
4461
|
+
map3.set(key3, value);
|
|
4462
|
+
return value;
|
|
4463
|
+
}
|
|
4464
|
+
get(key1, key2, key3) {
|
|
4465
|
+
return this.map1.get(key1)?.get(key2)?.get(key3);
|
|
4466
|
+
}
|
|
4467
|
+
getOrDefault(key1, key2, key3, defaultValue) {
|
|
4468
|
+
return this.get(key1, key2, key3) ?? defaultValue;
|
|
4469
|
+
}
|
|
4470
|
+
getOrCreate(key1, key2, key3, creatorOrValue) {
|
|
4471
|
+
if (!this.has(key1, key2, key3)) {
|
|
4472
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
4473
|
+
this.set(key1, key2, key3, value);
|
|
4474
|
+
return value;
|
|
4475
|
+
}
|
|
4476
|
+
return this.get(key1, key2, key3);
|
|
4477
|
+
}
|
|
4478
|
+
delete(key1, key2, key3) {
|
|
4479
|
+
if (key3 === void 0) {
|
|
4480
|
+
if (key2 === void 0) return this.map1.delete(key1);
|
|
4481
|
+
const map2 = this.map1.get(key1);
|
|
4482
|
+
if (!map2) return false;
|
|
4483
|
+
return map2.delete(key2);
|
|
4484
|
+
} else {
|
|
4485
|
+
if (key2 === void 0) return this.map1.delete(key1);
|
|
4486
|
+
const map3 = this.map1.get(key1)?.get(key2);
|
|
4487
|
+
if (!map3) return false;
|
|
4488
|
+
return map3.delete(key3);
|
|
4489
|
+
}
|
|
4490
|
+
}
|
|
4491
|
+
clear() {
|
|
4492
|
+
this.map1.clear();
|
|
4493
|
+
}
|
|
4494
|
+
get size() {
|
|
4495
|
+
let count = 0;
|
|
4496
|
+
for (const map2 of this.map1.values()) {
|
|
4497
|
+
for (const map3 of map2.values()) {
|
|
4498
|
+
count += map3.size;
|
|
4499
|
+
}
|
|
4500
|
+
}
|
|
4501
|
+
return count;
|
|
4502
|
+
}
|
|
4503
|
+
isEmpty() {
|
|
4504
|
+
return this.size === 0;
|
|
4505
|
+
}
|
|
4506
|
+
forEach(callbackfn, thisArg) {
|
|
4507
|
+
this.map1.forEach((map2, key1) => map2.forEach((map3, key2) => map3.forEach((value, key3) => callbackfn.call(thisArg, value, key1, key2, key3, this))));
|
|
4508
|
+
}
|
|
4509
|
+
*keys() {
|
|
4510
|
+
for (const [key1, map2] of this.map1)
|
|
4511
|
+
for (const [key2, map3] of map2)
|
|
4512
|
+
for (const key3 of map3.keys())
|
|
4513
|
+
yield [key1, key2, key3];
|
|
4514
|
+
}
|
|
4515
|
+
*values() {
|
|
4516
|
+
for (const map2 of this.map1.values())
|
|
4517
|
+
for (const map3 of map2.values())
|
|
4518
|
+
for (const value of map3.values())
|
|
4519
|
+
yield value;
|
|
4520
|
+
}
|
|
4521
|
+
*entries() {
|
|
4522
|
+
for (const [key1, map2] of this.map1)
|
|
4523
|
+
for (const [key2, map3] of map2)
|
|
4524
|
+
for (const [key3, value] of map3)
|
|
4525
|
+
yield [key1, key2, key3, value];
|
|
4526
|
+
}
|
|
4527
|
+
keysArray() {
|
|
4528
|
+
return [...this.keys()];
|
|
4529
|
+
}
|
|
4530
|
+
valuesArray() {
|
|
4531
|
+
return [...this.values()];
|
|
4532
|
+
}
|
|
4533
|
+
entriesArray() {
|
|
4534
|
+
return [...this.entries()];
|
|
4535
|
+
}
|
|
4536
|
+
*kvKeys() {
|
|
4537
|
+
for (const [key1, key2, key3] of this.keys())
|
|
4538
|
+
yield [key1, key2, key3];
|
|
4539
|
+
}
|
|
4540
|
+
*kvValues() {
|
|
4541
|
+
for (const el of this.values())
|
|
4542
|
+
yield el;
|
|
4543
|
+
}
|
|
4544
|
+
*kvEntries() {
|
|
4545
|
+
for (const [key1, key2, key3, el] of this.entries())
|
|
4546
|
+
yield [[key1, key2, key3], el];
|
|
4547
|
+
}
|
|
4548
|
+
*[Symbol.iterator]() {
|
|
4549
|
+
yield* this.entries();
|
|
4550
|
+
}
|
|
4551
|
+
clone() {
|
|
4552
|
+
return new _Map3(this);
|
|
4553
|
+
}
|
|
4554
|
+
merge(other, conflictResolver) {
|
|
4555
|
+
for (const [key1, key2, key3, value] of other.entries()) {
|
|
4556
|
+
if (this.has(key1, key2, key3) && conflictResolver) {
|
|
4557
|
+
this.set(key1, key2, key3, conflictResolver(this.get(key1, key2, key3), value, key1, key2, key3));
|
|
4558
|
+
} else {
|
|
4559
|
+
this.set(key1, key2, key3, value);
|
|
4560
|
+
}
|
|
4561
|
+
}
|
|
4562
|
+
return this;
|
|
4563
|
+
}
|
|
4564
|
+
some(fn) {
|
|
4565
|
+
for (const [key1, map2] of this.map1) {
|
|
4566
|
+
for (const [key2, map3] of map2) {
|
|
4567
|
+
for (const [key3, value] of map3) {
|
|
4568
|
+
if (fn(value, key1, key2, key3)) return true;
|
|
4569
|
+
}
|
|
4570
|
+
}
|
|
4571
|
+
}
|
|
4572
|
+
return false;
|
|
4573
|
+
}
|
|
4574
|
+
every(fn) {
|
|
4575
|
+
for (const [key1, map2] of this.map1) {
|
|
4576
|
+
for (const [key2, map3] of map2) {
|
|
4577
|
+
for (const [key3, value] of map3) {
|
|
4578
|
+
if (!fn(value, key1, key2, key3)) return false;
|
|
4579
|
+
}
|
|
4580
|
+
}
|
|
4581
|
+
}
|
|
4582
|
+
return true;
|
|
4583
|
+
}
|
|
4584
|
+
filter(predicate) {
|
|
4585
|
+
const result = new this.constructor();
|
|
4586
|
+
for (const [key1, map2] of this.map1) {
|
|
4587
|
+
for (const [key2, map3] of map2) {
|
|
4588
|
+
for (const [key3, value] of map3) {
|
|
4589
|
+
if (predicate(value, key1, key2, key3, this)) result.set(key1, key2, key3, value);
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4592
|
+
}
|
|
4593
|
+
return result;
|
|
4594
|
+
}
|
|
4595
|
+
reduce(fn, init) {
|
|
4596
|
+
let iterator = this.entries();
|
|
4597
|
+
let first = iterator.next();
|
|
4598
|
+
if (first.done) {
|
|
4599
|
+
if (arguments.length < 2) {
|
|
4600
|
+
throw new TypeError("Reduce of empty Map3 with no initial value!");
|
|
4601
|
+
}
|
|
4602
|
+
return init;
|
|
4603
|
+
}
|
|
4604
|
+
let acc;
|
|
4605
|
+
let start;
|
|
4606
|
+
if (arguments.length < 2) {
|
|
4607
|
+
acc = first.value[3];
|
|
4608
|
+
start = iterator.next();
|
|
4609
|
+
} else {
|
|
4610
|
+
acc = init;
|
|
4611
|
+
start = first;
|
|
4612
|
+
}
|
|
4613
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
4614
|
+
const [key1, key2, key3, value] = current.value;
|
|
4615
|
+
acc = fn(acc, value, key1, key2, key3);
|
|
4616
|
+
}
|
|
4617
|
+
return acc;
|
|
4618
|
+
}
|
|
4619
|
+
mapEntries(fn) {
|
|
4620
|
+
let result = [];
|
|
4621
|
+
for (const [key1, map2] of this.map1) {
|
|
4622
|
+
for (const [key2, map3] of map2) {
|
|
4623
|
+
for (const [key3, value] of map3) {
|
|
4624
|
+
result.push(fn(value, key1, key2, key3));
|
|
4625
|
+
}
|
|
4626
|
+
}
|
|
4627
|
+
}
|
|
4628
|
+
return result;
|
|
4629
|
+
}
|
|
4630
|
+
mapValues(fn) {
|
|
4631
|
+
let result = new _Map3();
|
|
4632
|
+
for (const [key1, map2] of this.map1) {
|
|
4633
|
+
for (const [key2, map3] of map2) {
|
|
4634
|
+
for (const [key3, value] of map3) {
|
|
4635
|
+
result.set(key1, key2, key3, fn(value, key1, key2, key3));
|
|
4636
|
+
}
|
|
4637
|
+
}
|
|
4638
|
+
}
|
|
4639
|
+
return result;
|
|
4640
|
+
}
|
|
4641
|
+
toMap() {
|
|
4642
|
+
let result = /* @__PURE__ */ new Map();
|
|
4643
|
+
for (const [key1, map2] of this.map1) {
|
|
4644
|
+
for (const [key2, map3] of map2) {
|
|
4645
|
+
for (const [key3, value] of map3) {
|
|
4646
|
+
result.set([key1, key2, key3], value);
|
|
4647
|
+
}
|
|
4648
|
+
}
|
|
4649
|
+
}
|
|
4650
|
+
return result;
|
|
4651
|
+
}
|
|
4652
|
+
toString() {
|
|
4653
|
+
const entries = [];
|
|
4654
|
+
for (const [key1, map2] of this.map1) {
|
|
4655
|
+
for (const [key2, map3] of map2) {
|
|
4656
|
+
const inner = [...map3].map(([key3, v]) => `${stringify(key3)} => ${stringify(v)}`).join(", ");
|
|
4657
|
+
entries.push(`${stringify(key1)} => ${stringify(key2)} => { ${inner} }`);
|
|
4658
|
+
}
|
|
4659
|
+
}
|
|
4660
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries.join(", ")} }`;
|
|
4661
|
+
}
|
|
4662
|
+
};
|
|
4663
|
+
|
|
4664
|
+
// src/deprecated/set.ts
|
|
4665
|
+
var SetBase = class extends BaseContainer {
|
|
4666
|
+
constructor(entries) {
|
|
4667
|
+
super();
|
|
4668
|
+
__publicField(this, "data");
|
|
4669
|
+
this.data = new Set(entries ?? []);
|
|
4670
|
+
}
|
|
4671
|
+
has(value) {
|
|
4672
|
+
return this.some((v) => this.valueEquals(v, value));
|
|
4673
|
+
}
|
|
4674
|
+
add(value) {
|
|
4675
|
+
if (!this.has(value))
|
|
4676
|
+
this.data.add(value);
|
|
4677
|
+
return value;
|
|
4678
|
+
}
|
|
4679
|
+
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
4680
|
+
set(key, value) {
|
|
4681
|
+
if (!this.valueEquals(key, value))
|
|
4682
|
+
throw new TypeError("SetBase.set() requires key === value.");
|
|
4683
|
+
this.add(value);
|
|
4684
|
+
}
|
|
4685
|
+
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
4686
|
+
get(key) {
|
|
4687
|
+
return this.has(key) ? key : void 0;
|
|
4688
|
+
}
|
|
4689
|
+
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
4690
|
+
getOrDefault(key, defaultValue) {
|
|
4691
|
+
return this.get(key) ?? defaultValue;
|
|
4692
|
+
}
|
|
4693
|
+
getOrCreate(key, creatorOrValue) {
|
|
4694
|
+
if (!this.has(key)) {
|
|
4695
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
4696
|
+
this.set(key, value);
|
|
4697
|
+
return value;
|
|
4698
|
+
}
|
|
4699
|
+
return this.get(key);
|
|
4700
|
+
}
|
|
4701
|
+
delete(value) {
|
|
4702
|
+
if (!this.has(value)) return false;
|
|
4703
|
+
for (const v of this.values()) {
|
|
4704
|
+
if (this.valueEquals(v, value)) {
|
|
4705
|
+
this.data.delete(v);
|
|
4706
|
+
return true;
|
|
4707
|
+
}
|
|
4708
|
+
}
|
|
4709
|
+
return false;
|
|
4710
|
+
}
|
|
4711
|
+
clear() {
|
|
4712
|
+
this.data.clear();
|
|
4713
|
+
}
|
|
4714
|
+
get size() {
|
|
4715
|
+
return this.data.size;
|
|
4716
|
+
}
|
|
4717
|
+
isEmpty() {
|
|
4718
|
+
return this.size === 0;
|
|
4719
|
+
}
|
|
4720
|
+
forEach(callbackfn, thisArg) {
|
|
4721
|
+
this.data.forEach((value) => callbackfn.call(thisArg, value, this));
|
|
4722
|
+
}
|
|
4723
|
+
*keys() {
|
|
4724
|
+
yield* this.data.keys();
|
|
4725
|
+
}
|
|
4726
|
+
*values() {
|
|
4727
|
+
yield* this.data.values();
|
|
4728
|
+
}
|
|
4729
|
+
*entries() {
|
|
4730
|
+
yield* this.data.entries();
|
|
4731
|
+
}
|
|
4732
|
+
*kvKeys() {
|
|
4733
|
+
for (const key of this.keys()) {
|
|
4734
|
+
yield [key];
|
|
4735
|
+
}
|
|
4736
|
+
}
|
|
4737
|
+
*kvValues() {
|
|
4738
|
+
for (const el of this.values()) {
|
|
4739
|
+
yield el;
|
|
4740
|
+
}
|
|
4741
|
+
}
|
|
4742
|
+
*kvEntries() {
|
|
4743
|
+
for (const [key, el] of this.entries()) {
|
|
4744
|
+
yield [[key], el];
|
|
4745
|
+
}
|
|
4746
|
+
}
|
|
4747
|
+
*[Symbol.iterator]() {
|
|
4748
|
+
yield* this.values();
|
|
4749
|
+
}
|
|
4750
|
+
clone() {
|
|
4751
|
+
const result = this.createEmpty();
|
|
4752
|
+
for (const v of this.values()) result.add(v);
|
|
4753
|
+
return result;
|
|
4754
|
+
}
|
|
4755
|
+
merge(other) {
|
|
4756
|
+
for (const value of other.values()) {
|
|
4757
|
+
this.add(value);
|
|
4758
|
+
}
|
|
4759
|
+
return this;
|
|
4760
|
+
}
|
|
4761
|
+
some(fn) {
|
|
4762
|
+
for (const value of this.data) {
|
|
4763
|
+
if (fn(value)) return true;
|
|
4764
|
+
}
|
|
4765
|
+
return false;
|
|
4766
|
+
}
|
|
4767
|
+
every(fn) {
|
|
4768
|
+
for (const value of this.data) {
|
|
4769
|
+
if (!fn(value)) return false;
|
|
4770
|
+
}
|
|
4771
|
+
return true;
|
|
4772
|
+
}
|
|
4773
|
+
filter(predicate) {
|
|
4774
|
+
const result = this.createEmpty();
|
|
4775
|
+
for (const value of this.data)
|
|
4776
|
+
if (predicate(value, this)) result.add(value);
|
|
4777
|
+
return result;
|
|
4778
|
+
}
|
|
4779
|
+
reduce(fn, init) {
|
|
4780
|
+
let iterator = this.values();
|
|
4781
|
+
let first = iterator.next();
|
|
4782
|
+
if (first.done) {
|
|
4783
|
+
if (arguments.length < 2) {
|
|
4784
|
+
throw new TypeError("Reduce of empty SetBase with no initial value!");
|
|
4785
|
+
}
|
|
4786
|
+
return init;
|
|
4787
|
+
}
|
|
4788
|
+
let acc;
|
|
4789
|
+
let start;
|
|
4790
|
+
if (arguments.length < 2) {
|
|
4791
|
+
acc = first.value;
|
|
4792
|
+
start = iterator.next();
|
|
4793
|
+
} else {
|
|
4794
|
+
acc = init;
|
|
4795
|
+
start = first;
|
|
4796
|
+
}
|
|
4797
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
4798
|
+
const value = current.value;
|
|
4799
|
+
acc = fn(acc, value);
|
|
4800
|
+
}
|
|
4801
|
+
return acc;
|
|
4802
|
+
}
|
|
4803
|
+
mapValues(fn) {
|
|
4804
|
+
let result = this.createEmpty();
|
|
4805
|
+
for (const value of this.data) {
|
|
4806
|
+
result.add(fn(value));
|
|
4807
|
+
}
|
|
4808
|
+
return result;
|
|
4809
|
+
}
|
|
4810
|
+
mapToArray(fn) {
|
|
4811
|
+
let result = [];
|
|
4812
|
+
for (const value of this.values()) {
|
|
4813
|
+
result.push(fn(value));
|
|
4814
|
+
}
|
|
4815
|
+
return result;
|
|
4816
|
+
}
|
|
4817
|
+
map(fn) {
|
|
4818
|
+
let result = this.createEmpty();
|
|
4819
|
+
for (const value of this.values()) {
|
|
4820
|
+
result.add(fn(value));
|
|
4821
|
+
}
|
|
4822
|
+
return result;
|
|
4823
|
+
}
|
|
4824
|
+
toSet() {
|
|
4825
|
+
return new Set(this.data);
|
|
4826
|
+
}
|
|
4827
|
+
toArray() {
|
|
4828
|
+
return [...this.values()];
|
|
4829
|
+
}
|
|
4830
|
+
toString() {
|
|
4831
|
+
return stringify(this.data);
|
|
4832
|
+
}
|
|
4833
|
+
};
|
|
4834
|
+
var Set1 = class _Set1 extends SetBase {
|
|
4835
|
+
constructor(entries) {
|
|
4836
|
+
super(entries);
|
|
4837
|
+
}
|
|
4838
|
+
createEmpty() {
|
|
4839
|
+
return new _Set1();
|
|
4840
|
+
}
|
|
4841
|
+
valueEquals(a, b) {
|
|
4842
|
+
return a === b;
|
|
4843
|
+
}
|
|
4844
|
+
};
|
|
4845
|
+
var DeepSet = class _DeepSet extends SetBase {
|
|
4846
|
+
constructor(entries) {
|
|
4847
|
+
super(entries);
|
|
4848
|
+
}
|
|
4849
|
+
createEmpty() {
|
|
4850
|
+
return new _DeepSet();
|
|
4851
|
+
}
|
|
4852
|
+
valueEquals(a, b) {
|
|
4853
|
+
return isDeepEqual2(a, b);
|
|
4854
|
+
}
|
|
4855
|
+
};
|
|
3708
4856
|
export {
|
|
3709
4857
|
assert_exports as Assert,
|
|
4858
|
+
BaseContainer,
|
|
4859
|
+
BiMap,
|
|
3710
4860
|
cookies_exports as Cookies,
|
|
3711
4861
|
DeepSet,
|
|
3712
4862
|
DefaultArray,
|
|
4863
|
+
DefaultEqualityFn,
|
|
3713
4864
|
device_exports as Device,
|
|
3714
4865
|
DivRect,
|
|
3715
4866
|
guard_exports as Guard,
|
|
3716
4867
|
IndexArray,
|
|
3717
4868
|
LRUCache,
|
|
4869
|
+
LinkedList,
|
|
3718
4870
|
Map1,
|
|
3719
4871
|
Map2,
|
|
3720
4872
|
Map3,
|
|
@@ -3724,7 +4876,10 @@ export {
|
|
|
3724
4876
|
SignedIndexArray,
|
|
3725
4877
|
SmallIntCache,
|
|
3726
4878
|
Stack,
|
|
4879
|
+
TriMap,
|
|
4880
|
+
UniMap,
|
|
3727
4881
|
utils_exports as Utils,
|
|
4882
|
+
ValueSet,
|
|
3728
4883
|
Vec,
|
|
3729
4884
|
Vec2,
|
|
3730
4885
|
asMulti
|