@tspro/ts-utils-lib 1.19.1 → 1.21.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 +20 -0
- package/dist/index.d.mts +868 -191
- package/dist/index.d.ts +868 -191
- package/dist/index.js +1999 -294
- package/dist/index.mjs +1990 -294
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* TsUtilsLib v1.
|
|
1
|
+
/* TsUtilsLib v1.21.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -23,25 +23,34 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
23
23
|
// src/index.ts
|
|
24
24
|
var index_exports = {};
|
|
25
25
|
__export(index_exports, {
|
|
26
|
+
AnchoredRect: () => AnchoredRect,
|
|
26
27
|
Assert: () => assert_exports,
|
|
28
|
+
BaseContainer: () => BaseContainer,
|
|
29
|
+
BiMap: () => BiMap,
|
|
27
30
|
Cookies: () => cookies_exports,
|
|
28
31
|
DeepSet: () => DeepSet,
|
|
29
32
|
DefaultArray: () => DefaultArray,
|
|
33
|
+
DefaultEqualityFn: () => DefaultEqualityFn,
|
|
30
34
|
Device: () => device_exports,
|
|
31
35
|
DivRect: () => DivRect,
|
|
32
36
|
Guard: () => guard_exports,
|
|
33
37
|
IndexArray: () => IndexArray,
|
|
34
38
|
LRUCache: () => LRUCache,
|
|
39
|
+
LinkedList: () => LinkedList,
|
|
35
40
|
Map1: () => Map1,
|
|
36
41
|
Map2: () => Map2,
|
|
37
42
|
Map3: () => Map3,
|
|
38
43
|
MultiContainer: () => MultiContainer,
|
|
44
|
+
Rect: () => Rect,
|
|
39
45
|
Set1: () => Set1,
|
|
40
46
|
SetBase: () => SetBase,
|
|
41
47
|
SignedIndexArray: () => SignedIndexArray,
|
|
42
48
|
SmallIntCache: () => SmallIntCache,
|
|
43
49
|
Stack: () => Stack,
|
|
50
|
+
TriMap: () => TriMap,
|
|
51
|
+
UniMap: () => UniMap,
|
|
44
52
|
Utils: () => utils_exports,
|
|
53
|
+
ValueSet: () => ValueSet,
|
|
45
54
|
Vec: () => Vec,
|
|
46
55
|
Vec2: () => Vec2,
|
|
47
56
|
asMulti: () => asMulti
|
|
@@ -105,6 +114,7 @@ __export(assert_exports, {
|
|
|
105
114
|
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined,
|
|
106
115
|
isNonEmptyString: () => isNonEmptyString,
|
|
107
116
|
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined,
|
|
117
|
+
isNotThrowing: () => isNotThrowing,
|
|
108
118
|
isNull: () => isNull,
|
|
109
119
|
isNullish: () => isNullish,
|
|
110
120
|
isNumber: () => isNumber,
|
|
@@ -500,6 +510,11 @@ function isThrowing(throwTestFn, msg) {
|
|
|
500
510
|
_fail(`Expected to throw`, msg);
|
|
501
511
|
return true;
|
|
502
512
|
}
|
|
513
|
+
function isNotThrowing(throwTestFn, msg) {
|
|
514
|
+
if (!guard_exports.isNotThrowing(throwTestFn))
|
|
515
|
+
_fail(`Expected to throw`, msg);
|
|
516
|
+
return true;
|
|
517
|
+
}
|
|
503
518
|
|
|
504
519
|
// src/web/cookies.ts
|
|
505
520
|
var cookies_exports = {};
|
|
@@ -747,6 +762,7 @@ __export(guard_exports, {
|
|
|
747
762
|
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined2,
|
|
748
763
|
isNonEmptyString: () => isNonEmptyString2,
|
|
749
764
|
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined2,
|
|
765
|
+
isNotThrowing: () => isNotThrowing2,
|
|
750
766
|
isNull: () => isNull2,
|
|
751
767
|
isNullish: () => isNullish2,
|
|
752
768
|
isNumber: () => isNumber2,
|
|
@@ -996,6 +1012,14 @@ function isThrowing2(throwTestFn) {
|
|
|
996
1012
|
return true;
|
|
997
1013
|
}
|
|
998
1014
|
}
|
|
1015
|
+
function isNotThrowing2(throwTestFn) {
|
|
1016
|
+
try {
|
|
1017
|
+
throwTestFn();
|
|
1018
|
+
return true;
|
|
1019
|
+
} catch (err) {
|
|
1020
|
+
return false;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
999
1023
|
function tryOr(tryFn, orVal) {
|
|
1000
1024
|
try {
|
|
1001
1025
|
return tryFn();
|
|
@@ -1429,99 +1453,19 @@ __export(str_exports, {
|
|
|
1429
1453
|
removeAt: () => removeAt,
|
|
1430
1454
|
repeatString: () => repeatString,
|
|
1431
1455
|
replaceAt: () => replaceAt,
|
|
1456
|
+
stringify: () => stringify,
|
|
1432
1457
|
toCharArray: () => toCharArray
|
|
1433
1458
|
});
|
|
1434
|
-
function toCharArray(str2) {
|
|
1435
|
-
return str2.split("");
|
|
1436
|
-
}
|
|
1437
|
-
function repeatString(repeatString2, repeatCount) {
|
|
1438
|
-
if (!isInteger2(repeatCount) || repeatCount < 0) {
|
|
1439
|
-
throw new Error("repeatStr: Invalid repeatCount = " + repeatCount);
|
|
1440
|
-
}
|
|
1441
|
-
return new Array(repeatCount + 1).join(repeatString2);
|
|
1442
|
-
}
|
|
1443
|
-
function chunkString(str2, chunkSize) {
|
|
1444
|
-
if (!isInteger2(chunkSize) || chunkSize < 1) {
|
|
1445
|
-
throw new Error("chunckString: Invalid chuckSize = " + chunkSize);
|
|
1446
|
-
}
|
|
1447
|
-
let result = [];
|
|
1448
|
-
for (let i = 0; i < str2.length; i += chunkSize) {
|
|
1449
|
-
result.push(str2.slice(i, i + chunkSize));
|
|
1450
|
-
}
|
|
1451
|
-
return result;
|
|
1452
|
-
}
|
|
1453
|
-
function replaceAt(str2, pos, removeCount, insert) {
|
|
1454
|
-
if (!isInteger2(removeCount) || removeCount < 0) {
|
|
1455
|
-
throw new Error("replaceAt: Invalid removeCount = " + removeCount);
|
|
1456
|
-
} else if (!isInteger2(pos) || pos < 0 || pos + removeCount > str2.length) {
|
|
1457
|
-
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " + str2.length);
|
|
1458
|
-
} else {
|
|
1459
|
-
return str2.substring(0, pos) + insert + str2.substring(pos + removeCount);
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
function insertAt(str2, pos, insertStr) {
|
|
1463
|
-
return replaceAt(str2, pos, 0, insertStr);
|
|
1464
|
-
}
|
|
1465
|
-
function removeAt(str2, pos, removeCount) {
|
|
1466
|
-
return replaceAt(str2, pos, removeCount, "");
|
|
1467
|
-
}
|
|
1468
|
-
function charCount(str2, ch) {
|
|
1469
|
-
if (ch.length !== 1 || str2.length === 0) return 0;
|
|
1470
|
-
let count = 0;
|
|
1471
|
-
for (let i = 0; i < str2.length; i++) {
|
|
1472
|
-
if (str2[i] === ch) count++;
|
|
1473
|
-
}
|
|
1474
|
-
return count;
|
|
1475
|
-
}
|
|
1476
|
-
function makeSentenceFromPascal(PascalString) {
|
|
1477
|
-
if (PascalString === "") {
|
|
1478
|
-
return "";
|
|
1479
|
-
}
|
|
1480
|
-
let word = PascalString.charAt(0);
|
|
1481
|
-
let sentence = "";
|
|
1482
|
-
const addWord = () => {
|
|
1483
|
-
if (word !== "") {
|
|
1484
|
-
if (sentence === "") {
|
|
1485
|
-
sentence += word.charAt(0).toUpperCase() + word.substring(1);
|
|
1486
|
-
} else {
|
|
1487
|
-
sentence += " " + word;
|
|
1488
|
-
}
|
|
1489
|
-
word = "";
|
|
1490
|
-
}
|
|
1491
|
-
};
|
|
1492
|
-
const isLetterAndCapital = (c) => {
|
|
1493
|
-
return c.toUpperCase() !== c.toLowerCase() && c === c.toUpperCase();
|
|
1494
|
-
};
|
|
1495
|
-
for (let i = 1; i < PascalString.length; i++) {
|
|
1496
|
-
let c = PascalString.charAt(i);
|
|
1497
|
-
if (isLetterAndCapital(c)) {
|
|
1498
|
-
addWord();
|
|
1499
|
-
}
|
|
1500
|
-
word += c.toLowerCase();
|
|
1501
|
-
}
|
|
1502
|
-
addWord();
|
|
1503
|
-
return sentence;
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
// src/utils/index.ts
|
|
1507
|
-
var Is = guard_exports;
|
|
1508
1459
|
|
|
1509
|
-
// src/core/
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
} else if (isArray2(value)) {
|
|
1514
|
-
return `[ ${value.map((e) => formatValue(e)).join(", ")} ]`.replaceAll(" ", " ");
|
|
1515
|
-
} else if (isFunction2(value.toString)) {
|
|
1516
|
-
return value.toString();
|
|
1517
|
-
} else {
|
|
1518
|
-
return JSON.stringify(value);
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1460
|
+
// src/core/base.ts
|
|
1461
|
+
var DefaultEqualityFn = (a, b) => a === b;
|
|
1462
|
+
var BaseContainer = class {
|
|
1463
|
+
};
|
|
1521
1464
|
|
|
1522
1465
|
// src/core/stack.ts
|
|
1523
|
-
var Stack = class {
|
|
1466
|
+
var Stack = class extends BaseContainer {
|
|
1524
1467
|
constructor() {
|
|
1468
|
+
super();
|
|
1525
1469
|
__publicField(this, "data", []);
|
|
1526
1470
|
}
|
|
1527
1471
|
assertId(id) {
|
|
@@ -1582,13 +1526,14 @@ var Stack = class {
|
|
|
1582
1526
|
this.data.length = 0;
|
|
1583
1527
|
}
|
|
1584
1528
|
toString() {
|
|
1585
|
-
return `Stack(${this.length})${
|
|
1529
|
+
return `Stack(${this.length})${stringify(this.data)}`;
|
|
1586
1530
|
}
|
|
1587
1531
|
};
|
|
1588
1532
|
|
|
1589
1533
|
// src/core/vec.ts
|
|
1590
|
-
var Vec = class _Vec {
|
|
1534
|
+
var Vec = class _Vec extends BaseContainer {
|
|
1591
1535
|
constructor(...coords) {
|
|
1536
|
+
super();
|
|
1592
1537
|
__publicField(this, "coords");
|
|
1593
1538
|
if (coords.length < 2) {
|
|
1594
1539
|
throw new TypeError("Vec needs minumum two coords!");
|
|
@@ -1716,8 +1661,179 @@ var Vec = class _Vec {
|
|
|
1716
1661
|
}
|
|
1717
1662
|
};
|
|
1718
1663
|
|
|
1719
|
-
// src/core/
|
|
1720
|
-
var
|
|
1664
|
+
// src/core/rect.ts
|
|
1665
|
+
var Rect = class _Rect {
|
|
1666
|
+
constructor(...args) {
|
|
1667
|
+
__publicField(this, "x");
|
|
1668
|
+
__publicField(this, "y");
|
|
1669
|
+
__publicField(this, "width");
|
|
1670
|
+
__publicField(this, "height");
|
|
1671
|
+
if (args.length === 0) {
|
|
1672
|
+
this.x = this.y = this.width = this.height = 0;
|
|
1673
|
+
} else if (args.length === 2) {
|
|
1674
|
+
this.x = this.y = 0;
|
|
1675
|
+
this.width = args[0];
|
|
1676
|
+
this.height = args[1];
|
|
1677
|
+
} else {
|
|
1678
|
+
this.x = args[0];
|
|
1679
|
+
this.y = args[1];
|
|
1680
|
+
this.width = args[2];
|
|
1681
|
+
this.height = args[3];
|
|
1682
|
+
}
|
|
1683
|
+
if (this.width < 0 || this.height < 0)
|
|
1684
|
+
throw new Error("Rect width and height must be non-negative.");
|
|
1685
|
+
}
|
|
1686
|
+
set(...args) {
|
|
1687
|
+
if (args.length === 0) {
|
|
1688
|
+
this.x = this.y = this.width = this.height = 0;
|
|
1689
|
+
} else if (args.length === 2) {
|
|
1690
|
+
this.x = this.y = 0;
|
|
1691
|
+
this.width = args[0];
|
|
1692
|
+
this.height = args[1];
|
|
1693
|
+
} else {
|
|
1694
|
+
this.x = args[0];
|
|
1695
|
+
this.y = args[1];
|
|
1696
|
+
this.width = args[2];
|
|
1697
|
+
this.height = args[3];
|
|
1698
|
+
}
|
|
1699
|
+
if (this.width < 0 || this.height < 0)
|
|
1700
|
+
throw new Error("Rect width and height must be non-negative.");
|
|
1701
|
+
return this;
|
|
1702
|
+
}
|
|
1703
|
+
// --- Static Constructors ---
|
|
1704
|
+
static fromPoints(p1, p2) {
|
|
1705
|
+
const x = Math.min(p1.x, p2.x);
|
|
1706
|
+
const y = Math.min(p1.y, p2.y);
|
|
1707
|
+
const w = Math.abs(p1.x - p2.x);
|
|
1708
|
+
const h = Math.abs(p1.y - p2.y);
|
|
1709
|
+
return new _Rect(x, y, w, h);
|
|
1710
|
+
}
|
|
1711
|
+
static fromCenter(cx, cy, width, height) {
|
|
1712
|
+
return new _Rect(cx - width / 2, cy - height / 2, width, height);
|
|
1713
|
+
}
|
|
1714
|
+
// --- Derived Properties ---
|
|
1715
|
+
get left() {
|
|
1716
|
+
return this.x;
|
|
1717
|
+
}
|
|
1718
|
+
get top() {
|
|
1719
|
+
return this.y;
|
|
1720
|
+
}
|
|
1721
|
+
get right() {
|
|
1722
|
+
return this.x + this.width;
|
|
1723
|
+
}
|
|
1724
|
+
get bottom() {
|
|
1725
|
+
return this.y + this.height;
|
|
1726
|
+
}
|
|
1727
|
+
get centerX() {
|
|
1728
|
+
return this.x + this.width / 2;
|
|
1729
|
+
}
|
|
1730
|
+
get centerY() {
|
|
1731
|
+
return this.y + this.height / 2;
|
|
1732
|
+
}
|
|
1733
|
+
get center() {
|
|
1734
|
+
return { x: this.centerX, y: this.centerY };
|
|
1735
|
+
}
|
|
1736
|
+
get area() {
|
|
1737
|
+
return this.width * this.height;
|
|
1738
|
+
}
|
|
1739
|
+
get isEmpty() {
|
|
1740
|
+
return this.width <= 0 || this.height <= 0;
|
|
1741
|
+
}
|
|
1742
|
+
// --- Geometric Tests ---
|
|
1743
|
+
containsPoint(px, py) {
|
|
1744
|
+
return px >= this.left && px <= this.right && py >= this.top && py <= this.bottom;
|
|
1745
|
+
}
|
|
1746
|
+
containsRect(other) {
|
|
1747
|
+
return other.left >= this.left && other.right <= this.right && other.top >= this.top && other.bottom <= this.bottom;
|
|
1748
|
+
}
|
|
1749
|
+
intersects(other) {
|
|
1750
|
+
return !(other.right < this.left || other.left > this.right || other.bottom < this.top || other.top > this.bottom);
|
|
1751
|
+
}
|
|
1752
|
+
// --- Operations ---
|
|
1753
|
+
intersectionCopy(other) {
|
|
1754
|
+
const x1 = Math.max(this.left, other.left);
|
|
1755
|
+
const y1 = Math.max(this.top, other.top);
|
|
1756
|
+
const x2 = Math.min(this.right, other.right);
|
|
1757
|
+
const y2 = Math.min(this.bottom, other.bottom);
|
|
1758
|
+
if (x2 <= x1 || y2 <= y1) return new _Rect();
|
|
1759
|
+
return new _Rect(x1, y1, x2 - x1, y2 - y1);
|
|
1760
|
+
}
|
|
1761
|
+
unionCopy(other) {
|
|
1762
|
+
const x1 = Math.min(this.left, other.left);
|
|
1763
|
+
const y1 = Math.min(this.top, other.top);
|
|
1764
|
+
const x2 = Math.max(this.right, other.right);
|
|
1765
|
+
const y2 = Math.max(this.bottom, other.bottom);
|
|
1766
|
+
return new _Rect(x1, y1, x2 - x1, y2 - y1);
|
|
1767
|
+
}
|
|
1768
|
+
insetCopy(dx, dy) {
|
|
1769
|
+
return new _Rect(this.x + dx, this.y + dy, this.width - 2 * dx, this.height - 2 * dy);
|
|
1770
|
+
}
|
|
1771
|
+
inflateCopy(dx, dy) {
|
|
1772
|
+
return new _Rect(this.x - dx, this.y - dy, this.width + 2 * dx, this.height + 2 * dy);
|
|
1773
|
+
}
|
|
1774
|
+
offsetInPlace(dx, dy) {
|
|
1775
|
+
this.x += dx;
|
|
1776
|
+
this.y += dy;
|
|
1777
|
+
return this;
|
|
1778
|
+
}
|
|
1779
|
+
offsetCopy(dx, dy) {
|
|
1780
|
+
return new _Rect(this.x + dx, this.y + dy, this.width, this.height);
|
|
1781
|
+
}
|
|
1782
|
+
scaleInPlace(scaleX, scaleY = scaleX) {
|
|
1783
|
+
this.x = this.centerX - this.width * scaleX / 2;
|
|
1784
|
+
this.width *= scaleX;
|
|
1785
|
+
this.y = this.centerY - this.height * scaleY / 2;
|
|
1786
|
+
this.height *= scaleY;
|
|
1787
|
+
return this;
|
|
1788
|
+
}
|
|
1789
|
+
scaleCopy(scaleX, scaleY = scaleX) {
|
|
1790
|
+
return this.clone().scaleInPlace(scaleX, scaleY);
|
|
1791
|
+
}
|
|
1792
|
+
roundCopy() {
|
|
1793
|
+
const left = Math.round(this.left);
|
|
1794
|
+
const top = Math.round(this.top);
|
|
1795
|
+
const right = Math.round(this.right);
|
|
1796
|
+
const bottom = Math.round(this.bottom);
|
|
1797
|
+
return new _Rect(left, top, right - left, bottom - top);
|
|
1798
|
+
}
|
|
1799
|
+
floorCopy() {
|
|
1800
|
+
const left = Math.floor(this.left);
|
|
1801
|
+
const top = Math.floor(this.top);
|
|
1802
|
+
const right = Math.floor(this.right);
|
|
1803
|
+
const bottom = Math.floor(this.bottom);
|
|
1804
|
+
return new _Rect(left, top, right - left, bottom - top);
|
|
1805
|
+
}
|
|
1806
|
+
ceilCopy() {
|
|
1807
|
+
const left = Math.ceil(this.left);
|
|
1808
|
+
const top = Math.ceil(this.top);
|
|
1809
|
+
const right = Math.ceil(this.right);
|
|
1810
|
+
const bottom = Math.ceil(this.bottom);
|
|
1811
|
+
return new _Rect(left, top, right - left, bottom - top);
|
|
1812
|
+
}
|
|
1813
|
+
expandCopy(px, py) {
|
|
1814
|
+
const left = Math.min(this.left, px);
|
|
1815
|
+
const top = Math.min(this.top, py);
|
|
1816
|
+
const right = Math.max(this.right, px);
|
|
1817
|
+
const bottom = Math.max(this.bottom, py);
|
|
1818
|
+
return new _Rect(left, top, right - left, bottom - top);
|
|
1819
|
+
}
|
|
1820
|
+
// --- Utilities ---
|
|
1821
|
+
equals(other) {
|
|
1822
|
+
return this.x === other.x && this.y === other.y && this.width === other.width && this.height === other.height;
|
|
1823
|
+
}
|
|
1824
|
+
clone() {
|
|
1825
|
+
return new _Rect(this.x, this.y, this.width, this.height);
|
|
1826
|
+
}
|
|
1827
|
+
toString() {
|
|
1828
|
+
return `Rect(x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height})`;
|
|
1829
|
+
}
|
|
1830
|
+
toAnchoredRect() {
|
|
1831
|
+
return new AnchoredRect(this.left, this.right, this.top, this.bottom);
|
|
1832
|
+
}
|
|
1833
|
+
};
|
|
1834
|
+
|
|
1835
|
+
// src/core/anchor-rect.ts
|
|
1836
|
+
var AnchoredRect = class _AnchoredRect {
|
|
1721
1837
|
constructor(...args) {
|
|
1722
1838
|
__publicField(this, "left");
|
|
1723
1839
|
__publicField(this, "anchorX");
|
|
@@ -1743,8 +1859,31 @@ var DivRect = class _DivRect {
|
|
|
1743
1859
|
this.left = this.anchorX = this.right = 0;
|
|
1744
1860
|
this.top = this.anchorY = this.bottom = 0;
|
|
1745
1861
|
} else {
|
|
1746
|
-
throw new TypeError(`Invalid
|
|
1862
|
+
throw new TypeError(`Invalid AnchoredRect args: ${args}`);
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
set(...args) {
|
|
1866
|
+
if (args.length === 6) {
|
|
1867
|
+
this.left = args[0];
|
|
1868
|
+
this.anchorX = args[1];
|
|
1869
|
+
this.right = args[2];
|
|
1870
|
+
this.top = args[3];
|
|
1871
|
+
this.anchorY = args[4];
|
|
1872
|
+
this.bottom = args[5];
|
|
1873
|
+
} else if (args.length === 4) {
|
|
1874
|
+
this.left = args[0];
|
|
1875
|
+
this.right = args[1];
|
|
1876
|
+
this.anchorX = (this.left + this.right) / 2;
|
|
1877
|
+
this.top = args[2];
|
|
1878
|
+
this.bottom = args[3];
|
|
1879
|
+
this.anchorY = (this.top + this.bottom) / 2;
|
|
1880
|
+
} else if (args.length === 0) {
|
|
1881
|
+
this.left = this.anchorX = this.right = 0;
|
|
1882
|
+
this.top = this.anchorY = this.bottom = 0;
|
|
1883
|
+
} else {
|
|
1884
|
+
throw new TypeError(`Invalid AnchoredRect args: ${args}`);
|
|
1747
1885
|
}
|
|
1886
|
+
return this;
|
|
1748
1887
|
}
|
|
1749
1888
|
/**
|
|
1750
1889
|
* Create rect from basic left, top, width and height arguments.
|
|
@@ -1753,10 +1892,10 @@ var DivRect = class _DivRect {
|
|
|
1753
1892
|
* @param top - Top coordinate.
|
|
1754
1893
|
* @param width - Width.
|
|
1755
1894
|
* @param height - Height.
|
|
1756
|
-
* @returns -
|
|
1895
|
+
* @returns - AnchoredRect.
|
|
1757
1896
|
*/
|
|
1758
1897
|
static create(left, top, width, height) {
|
|
1759
|
-
return new
|
|
1898
|
+
return new _AnchoredRect(left, left + width, top, top + height);
|
|
1760
1899
|
}
|
|
1761
1900
|
/**
|
|
1762
1901
|
* Create rect from anchorX, anchorY, width, height arguments.
|
|
@@ -1765,10 +1904,10 @@ var DivRect = class _DivRect {
|
|
|
1765
1904
|
* @param centerY - Center y-coordinate.
|
|
1766
1905
|
* @param width - Width.
|
|
1767
1906
|
* @param height - Height.
|
|
1768
|
-
* @returns -
|
|
1907
|
+
* @returns - AnchoredRect.
|
|
1769
1908
|
*/
|
|
1770
1909
|
static createCentered(centerX, centerY, width, height) {
|
|
1771
|
-
return new
|
|
1910
|
+
return new _AnchoredRect(
|
|
1772
1911
|
centerX - width / 2,
|
|
1773
1912
|
centerX,
|
|
1774
1913
|
centerX + width / 2,
|
|
@@ -1784,26 +1923,22 @@ var DivRect = class _DivRect {
|
|
|
1784
1923
|
* @param rightw - Right section width.
|
|
1785
1924
|
* @param toph - Top section height.
|
|
1786
1925
|
* @param bottomh - Bottomsection height.
|
|
1787
|
-
* @returns -
|
|
1926
|
+
* @returns - AnchoredRect.
|
|
1788
1927
|
*/
|
|
1789
1928
|
static createSections(leftw, rightw, toph, bottomh) {
|
|
1790
|
-
return new
|
|
1929
|
+
return new _AnchoredRect(-leftw, 0, rightw, -toph, 0, bottomh);
|
|
1791
1930
|
}
|
|
1792
|
-
/**
|
|
1931
|
+
/**
|
|
1932
|
+
* Get center x-coordinate.
|
|
1933
|
+
*/
|
|
1793
1934
|
get centerX() {
|
|
1794
|
-
return this.
|
|
1795
|
-
}
|
|
1796
|
-
/** @deprecated - Renamed to anchorX. */
|
|
1797
|
-
set centerX(x) {
|
|
1798
|
-
this.anchorX = x;
|
|
1935
|
+
return this.left + this.width / 2;
|
|
1799
1936
|
}
|
|
1800
|
-
/**
|
|
1937
|
+
/**
|
|
1938
|
+
* Get center ycoordinate.
|
|
1939
|
+
*/
|
|
1801
1940
|
get centerY() {
|
|
1802
|
-
return this.
|
|
1803
|
-
}
|
|
1804
|
-
/** @deprecated - Renamed to anchorY. */
|
|
1805
|
-
set centerY(y) {
|
|
1806
|
-
this.anchorY = y;
|
|
1941
|
+
return this.top + this.height / 2;
|
|
1807
1942
|
}
|
|
1808
1943
|
/**
|
|
1809
1944
|
* Width getter.
|
|
@@ -1854,8 +1989,8 @@ var DivRect = class _DivRect {
|
|
|
1854
1989
|
/**
|
|
1855
1990
|
* Do a and b rects overlap?
|
|
1856
1991
|
*
|
|
1857
|
-
* @param a -
|
|
1858
|
-
* @param b -
|
|
1992
|
+
* @param a - AnchoredRect a.
|
|
1993
|
+
* @param b - AnchoredRect b.
|
|
1859
1994
|
* @returns - True/false.
|
|
1860
1995
|
*/
|
|
1861
1996
|
static overlap(a, b) {
|
|
@@ -1864,8 +1999,8 @@ var DivRect = class _DivRect {
|
|
|
1864
1999
|
/**
|
|
1865
2000
|
* Do horizontal measures of a and b rects overlap?
|
|
1866
2001
|
*
|
|
1867
|
-
* @param a -
|
|
1868
|
-
* @param b -
|
|
2002
|
+
* @param a - AnchoredRect a.
|
|
2003
|
+
* @param b - AnchoredRect b.
|
|
1869
2004
|
* @returns - True/false.
|
|
1870
2005
|
*/
|
|
1871
2006
|
static overlapX(a, b) {
|
|
@@ -1873,8 +2008,8 @@ var DivRect = class _DivRect {
|
|
|
1873
2008
|
}
|
|
1874
2009
|
/**
|
|
1875
2010
|
* Check if given rects are equal.
|
|
1876
|
-
* @param a -
|
|
1877
|
-
* @param b -
|
|
2011
|
+
* @param a - AnchoredRect a.
|
|
2012
|
+
* @param b - AnchoredRect b.
|
|
1878
2013
|
* @returns - True/false.
|
|
1879
2014
|
*/
|
|
1880
2015
|
static equals(a, b) {
|
|
@@ -1892,13 +2027,13 @@ var DivRect = class _DivRect {
|
|
|
1892
2027
|
* @returns - True/false.
|
|
1893
2028
|
*/
|
|
1894
2029
|
equals(other) {
|
|
1895
|
-
return
|
|
2030
|
+
return _AnchoredRect.equals(this, other);
|
|
1896
2031
|
}
|
|
1897
2032
|
/**
|
|
1898
2033
|
* Check if edges of given rects are equal, ignoring anchorX and anchorY.
|
|
1899
2034
|
*
|
|
1900
|
-
* @param a -
|
|
1901
|
-
* @param b -
|
|
2035
|
+
* @param a - AnchoredRect a.
|
|
2036
|
+
* @param b - AnchoredRect b.
|
|
1902
2037
|
* @returns - True/false.
|
|
1903
2038
|
*/
|
|
1904
2039
|
static equalsEdges(a, b) {
|
|
@@ -1913,30 +2048,25 @@ var DivRect = class _DivRect {
|
|
|
1913
2048
|
/**
|
|
1914
2049
|
* Check if edges of this Rect equals with given Rect, ignoring anchorX and anchorY.
|
|
1915
2050
|
*
|
|
1916
|
-
* @param other - The other
|
|
2051
|
+
* @param other - The other AnchoredRect.
|
|
1917
2052
|
* @returns - True/false.
|
|
1918
2053
|
*/
|
|
1919
2054
|
equalsEdges(other) {
|
|
1920
|
-
return
|
|
1921
|
-
}
|
|
1922
|
-
/** @deprecated - Use `DivRect.equalsEdges()` instead. */
|
|
1923
|
-
static equalsFrame(a, b) {
|
|
1924
|
-
return _DivRect.equalsEdges(a, b);
|
|
2055
|
+
return _AnchoredRect.equalsEdges(this, other);
|
|
1925
2056
|
}
|
|
1926
2057
|
/**
|
|
1927
2058
|
* Created duplicate of this Rect.
|
|
1928
|
-
*
|
|
1929
2059
|
* @returns - Duplicate.
|
|
1930
2060
|
*/
|
|
1931
|
-
|
|
1932
|
-
return new
|
|
2061
|
+
clone() {
|
|
2062
|
+
return new _AnchoredRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
|
|
1933
2063
|
}
|
|
1934
2064
|
/**
|
|
1935
2065
|
* Move this rect by (dx, dy). Modifies this Rect.
|
|
1936
2066
|
*
|
|
1937
2067
|
* @param dx - Offset amount in x-direction.
|
|
1938
2068
|
* @param dy - Offset amount in y-direction.
|
|
1939
|
-
* @returns - This
|
|
2069
|
+
* @returns - This AnchoredRect instance.
|
|
1940
2070
|
*/
|
|
1941
2071
|
offsetInPlace(dx, dy) {
|
|
1942
2072
|
this.left += dx;
|
|
@@ -1952,16 +2082,16 @@ var DivRect = class _DivRect {
|
|
|
1952
2082
|
*
|
|
1953
2083
|
* @param dx - Offset amount in x-direction.
|
|
1954
2084
|
* @param dy - Offset amount in y-direction.
|
|
1955
|
-
* @returns -
|
|
2085
|
+
* @returns - AnchoredRect copy with applied offset.
|
|
1956
2086
|
*/
|
|
1957
2087
|
offsetCopy(dx, dy) {
|
|
1958
|
-
return this.
|
|
2088
|
+
return this.clone().offsetInPlace(dx, dy);
|
|
1959
2089
|
}
|
|
1960
2090
|
/**
|
|
1961
2091
|
* Expand this Rect by given Rect. Modifies this Rect.
|
|
1962
2092
|
*
|
|
1963
|
-
* @param rect -
|
|
1964
|
-
* @returns - This
|
|
2093
|
+
* @param rect - AnchoredRect to expand this instance with.
|
|
2094
|
+
* @returns - This AnchoredRect instance.
|
|
1965
2095
|
*/
|
|
1966
2096
|
expandInPlace(rect) {
|
|
1967
2097
|
this.left = Math.min(this.left, rect.left);
|
|
@@ -1973,17 +2103,17 @@ var DivRect = class _DivRect {
|
|
|
1973
2103
|
/**
|
|
1974
2104
|
* Expand this Rect by given Rect. Immutable, returns modified copy.
|
|
1975
2105
|
*
|
|
1976
|
-
* @param rect -
|
|
1977
|
-
* @returns - Expanded copy of this
|
|
2106
|
+
* @param rect - AnchoredRect to expand this instance with.
|
|
2107
|
+
* @returns - Expanded copy of this AnchoredRect.
|
|
1978
2108
|
*/
|
|
1979
2109
|
expandCopy(rect) {
|
|
1980
|
-
return this.
|
|
2110
|
+
return this.clone().expandInPlace(rect);
|
|
1981
2111
|
}
|
|
1982
2112
|
/**
|
|
1983
2113
|
* Clip this Rect by given Rect. Mmodifies this Rect.
|
|
1984
2114
|
*
|
|
1985
|
-
* @param clipRect -
|
|
1986
|
-
* @returns - This
|
|
2115
|
+
* @param clipRect - AnchoredRect to clip this instance with.
|
|
2116
|
+
* @returns - This AnchoredRect instance.
|
|
1987
2117
|
*/
|
|
1988
2118
|
clipInPlace(clipRect) {
|
|
1989
2119
|
this.left = Math.max(this.left, clipRect.left);
|
|
@@ -1997,21 +2127,20 @@ var DivRect = class _DivRect {
|
|
|
1997
2127
|
/**
|
|
1998
2128
|
* Clip this Rect by given Rect. Immutable, return modified copy.
|
|
1999
2129
|
*
|
|
2000
|
-
* @param clipRect -
|
|
2001
|
-
* @returns - Clipped
|
|
2130
|
+
* @param clipRect - AnchoredRecto to clip this instance with.
|
|
2131
|
+
* @returns - Clipped AnchoredRect copy.
|
|
2002
2132
|
*/
|
|
2003
2133
|
clipCopy(clipRect) {
|
|
2004
|
-
return this.
|
|
2134
|
+
return this.clone().clipInPlace(clipRect);
|
|
2005
2135
|
}
|
|
2006
2136
|
/**
|
|
2007
2137
|
* Scale Rect. Anchor pos is (anchorX, anchorY). Modifies this Rect.
|
|
2008
2138
|
*
|
|
2009
2139
|
* @param scaleX - Scale x-amount.
|
|
2010
2140
|
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
2011
|
-
* @returns This
|
|
2141
|
+
* @returns This AnchoredRect instance.
|
|
2012
2142
|
*/
|
|
2013
|
-
scaleInPlace(scaleX, scaleY) {
|
|
2014
|
-
scaleY = scaleY ?? scaleX;
|
|
2143
|
+
scaleInPlace(scaleX, scaleY = scaleX) {
|
|
2015
2144
|
this.left = this.anchorX - this.leftw * scaleX;
|
|
2016
2145
|
this.right = this.anchorX + this.rightw * scaleX;
|
|
2017
2146
|
this.top = this.anchorY - this.toph * scaleY;
|
|
@@ -2023,24 +2152,28 @@ var DivRect = class _DivRect {
|
|
|
2023
2152
|
*
|
|
2024
2153
|
* @param scaleX - Scale x-amount.
|
|
2025
2154
|
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
2026
|
-
* @returns Scaled copy of this
|
|
2155
|
+
* @returns Scaled copy of this AnchoredRect.
|
|
2027
2156
|
*/
|
|
2028
|
-
scaleCopy(scaleX, scaleY) {
|
|
2029
|
-
return this.
|
|
2157
|
+
scaleCopy(scaleX, scaleY = scaleX) {
|
|
2158
|
+
return this.clone().scaleInPlace(scaleX, scaleY);
|
|
2030
2159
|
}
|
|
2031
2160
|
/**
|
|
2032
|
-
* Get this
|
|
2033
|
-
* @returns - This
|
|
2161
|
+
* Get this AnchoredRect instance.
|
|
2162
|
+
* @returns - This AnchoredRect instance.
|
|
2034
2163
|
*/
|
|
2035
2164
|
getRect() {
|
|
2036
2165
|
return this;
|
|
2037
2166
|
}
|
|
2167
|
+
toRect() {
|
|
2168
|
+
return new Rect(this.left, this.right, this.width, this.height);
|
|
2169
|
+
}
|
|
2038
2170
|
};
|
|
2039
2171
|
|
|
2040
2172
|
// src/core/LRU-cache.ts
|
|
2041
|
-
var LRUCache = class {
|
|
2173
|
+
var LRUCache = class extends BaseContainer {
|
|
2042
2174
|
// Maximum key length.
|
|
2043
2175
|
constructor(maxSize, maxKeyLength = Infinity) {
|
|
2176
|
+
super();
|
|
2044
2177
|
__publicField(this, "cache");
|
|
2045
2178
|
// Stores the actual key-value pairs
|
|
2046
2179
|
__publicField(this, "next");
|
|
@@ -2132,11 +2265,31 @@ var LRUCache = class {
|
|
|
2132
2265
|
}
|
|
2133
2266
|
this.tail = key;
|
|
2134
2267
|
}
|
|
2268
|
+
*keys() {
|
|
2269
|
+
for (let key = this.head; key != null; key = this.next[key])
|
|
2270
|
+
yield key;
|
|
2271
|
+
}
|
|
2272
|
+
*values() {
|
|
2273
|
+
for (let key = this.head; key != null; key = this.next[key])
|
|
2274
|
+
yield this.cache[key];
|
|
2275
|
+
}
|
|
2276
|
+
*entries() {
|
|
2277
|
+
for (let key = this.head; key != null; key = this.next[key])
|
|
2278
|
+
yield [key, this.cache[key]];
|
|
2279
|
+
}
|
|
2280
|
+
*[Symbol.iterator]() {
|
|
2281
|
+
yield* this.entries();
|
|
2282
|
+
}
|
|
2283
|
+
toString() {
|
|
2284
|
+
const entries = [...this.entries()];
|
|
2285
|
+
return entries.length === 0 ? `LRUCache(0){ }` : `LRUCache(${entries.length}){ ${entries.map((e) => `${stringify(e[0])}: ${stringify(e[1])}`).join(", ")} }`;
|
|
2286
|
+
}
|
|
2135
2287
|
};
|
|
2136
2288
|
|
|
2137
2289
|
// src/core/index-array.ts
|
|
2138
|
-
var IndexArray = class _IndexArray {
|
|
2290
|
+
var IndexArray = class _IndexArray extends BaseContainer {
|
|
2139
2291
|
constructor(entries) {
|
|
2292
|
+
super();
|
|
2140
2293
|
__publicField(this, "posVal");
|
|
2141
2294
|
__publicField(this, "hasPos");
|
|
2142
2295
|
// Number of values
|
|
@@ -2349,14 +2502,20 @@ var IndexArray = class _IndexArray {
|
|
|
2349
2502
|
return this.valuesArray();
|
|
2350
2503
|
}
|
|
2351
2504
|
toString() {
|
|
2352
|
-
|
|
2353
|
-
|
|
2505
|
+
let isRegularArray = true;
|
|
2506
|
+
for (let i = 0; i < this.hasPos.length && isRegularArray; i++)
|
|
2507
|
+
if (!this.hasPos[i]) isRegularArray = false;
|
|
2508
|
+
if (isRegularArray)
|
|
2509
|
+
return stringify(this.posVal.slice(0, this.hasPos.length));
|
|
2510
|
+
const entries = this.entriesArray().map(([id, v]) => `${stringify(id)}: ${stringify(v)}`).join(", ");
|
|
2511
|
+
return entries.length === 0 ? `[ ]` : `[ ${entries} ]`;
|
|
2354
2512
|
}
|
|
2355
2513
|
};
|
|
2356
2514
|
|
|
2357
2515
|
// src/core/signed-index-array.ts
|
|
2358
|
-
var SignedIndexArray = class _SignedIndexArray {
|
|
2516
|
+
var SignedIndexArray = class _SignedIndexArray extends BaseContainer {
|
|
2359
2517
|
constructor(entries) {
|
|
2518
|
+
super();
|
|
2360
2519
|
// For indexes >= 0
|
|
2361
2520
|
__publicField(this, "posVal");
|
|
2362
2521
|
__publicField(this, "hasPos");
|
|
@@ -2612,21 +2771,28 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
2612
2771
|
return this.valuesArray();
|
|
2613
2772
|
}
|
|
2614
2773
|
toString() {
|
|
2615
|
-
|
|
2616
|
-
|
|
2774
|
+
let isRegularArray = this.hasNeg.length === 0;
|
|
2775
|
+
for (let i = 0; i < this.hasPos.length && isRegularArray; i++)
|
|
2776
|
+
if (!this.hasPos[i]) isRegularArray = false;
|
|
2777
|
+
if (isRegularArray)
|
|
2778
|
+
return stringify(this.posVal.slice(0, this.hasPos.length));
|
|
2779
|
+
const entries = this.entriesArray().map(([id, v]) => `${stringify(id)}: ${stringify(v)}`).join(", ");
|
|
2780
|
+
return entries.length === 0 ? `[ ]` : `[ ${entries} ]`;
|
|
2617
2781
|
}
|
|
2618
2782
|
};
|
|
2619
2783
|
|
|
2620
2784
|
// src/core/default-array.ts
|
|
2621
|
-
var DefaultArray = class _DefaultArray {
|
|
2622
|
-
constructor(
|
|
2623
|
-
|
|
2785
|
+
var DefaultArray = class _DefaultArray extends BaseContainer {
|
|
2786
|
+
constructor(...args) {
|
|
2787
|
+
super();
|
|
2788
|
+
__publicField(this, "defaultValue");
|
|
2624
2789
|
__publicField(this, "data");
|
|
2625
|
-
|
|
2626
|
-
|
|
2790
|
+
this.defaultValue = args.pop();
|
|
2791
|
+
if (typeof args[0] === "number") {
|
|
2792
|
+
this.data = Array(args[0]).fill(this.defaultValue);
|
|
2627
2793
|
} else {
|
|
2628
|
-
this.data = Array.from(
|
|
2629
|
-
(v) => v === void 0 ? defaultValue : v
|
|
2794
|
+
this.data = Array.from(args[0]).map(
|
|
2795
|
+
(v) => v === void 0 ? this.defaultValue : v
|
|
2630
2796
|
);
|
|
2631
2797
|
}
|
|
2632
2798
|
}
|
|
@@ -2727,9 +2893,7 @@ var DefaultArray = class _DefaultArray {
|
|
|
2727
2893
|
}
|
|
2728
2894
|
clone() {
|
|
2729
2895
|
const ctor = this.constructor;
|
|
2730
|
-
|
|
2731
|
-
clone.data = this.data.slice();
|
|
2732
|
-
return clone;
|
|
2896
|
+
return new ctor(this.values(), this.defaultValue);
|
|
2733
2897
|
}
|
|
2734
2898
|
merge(other, conflictResolver) {
|
|
2735
2899
|
if (this.constructor !== other.constructor)
|
|
@@ -2815,62 +2979,92 @@ var DefaultArray = class _DefaultArray {
|
|
|
2815
2979
|
return this.valuesArray();
|
|
2816
2980
|
}
|
|
2817
2981
|
toString() {
|
|
2818
|
-
|
|
2819
|
-
return `DefaultArray[ ${entries} ]`.replaceAll(" ", " ");
|
|
2982
|
+
return stringify(this.data);
|
|
2820
2983
|
}
|
|
2821
2984
|
};
|
|
2822
2985
|
|
|
2823
|
-
// src/core/
|
|
2824
|
-
var
|
|
2825
|
-
constructor(
|
|
2826
|
-
|
|
2827
|
-
this
|
|
2986
|
+
// src/core/uni-map.ts
|
|
2987
|
+
var UniMap = class _UniMap extends BaseContainer {
|
|
2988
|
+
constructor(...args) {
|
|
2989
|
+
super();
|
|
2990
|
+
__publicField(this, "map");
|
|
2991
|
+
__publicField(this, "keyEquals");
|
|
2992
|
+
const maybeEquals = args.at(-1);
|
|
2993
|
+
this.keyEquals = isFunction2(maybeEquals) ? args.pop() : DefaultEqualityFn;
|
|
2994
|
+
const entries = args[0];
|
|
2995
|
+
this.map = new Map(entries);
|
|
2828
2996
|
}
|
|
2829
|
-
|
|
2830
|
-
return
|
|
2997
|
+
static createDeep(arg) {
|
|
2998
|
+
return arg ? new _UniMap(arg, isDeepEqual2) : new _UniMap(isDeepEqual2);
|
|
2831
2999
|
}
|
|
2832
|
-
|
|
2833
|
-
this.
|
|
3000
|
+
has(key) {
|
|
3001
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
|
|
3002
|
+
return this.map.has(key);
|
|
3003
|
+
for (const [k, v] of this.map)
|
|
3004
|
+
if (this.keyEquals(k, key))
|
|
3005
|
+
return true;
|
|
3006
|
+
return false;
|
|
3007
|
+
}
|
|
3008
|
+
set(key, value) {
|
|
3009
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key)) {
|
|
3010
|
+
this.map.set(key, value);
|
|
3011
|
+
return value;
|
|
3012
|
+
}
|
|
3013
|
+
for (const key2 of this.map.keys())
|
|
3014
|
+
if (this.keyEquals(key2, key)) {
|
|
3015
|
+
this.map.set(key2, value);
|
|
3016
|
+
return value;
|
|
3017
|
+
}
|
|
3018
|
+
this.map.set(key, value);
|
|
2834
3019
|
return value;
|
|
2835
3020
|
}
|
|
2836
|
-
get(
|
|
2837
|
-
|
|
3021
|
+
get(key) {
|
|
3022
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
|
|
3023
|
+
return this.map.get(key);
|
|
3024
|
+
for (const [k, v] of this.map)
|
|
3025
|
+
if (this.keyEquals(k, key))
|
|
3026
|
+
return v;
|
|
3027
|
+
return void 0;
|
|
2838
3028
|
}
|
|
2839
|
-
|
|
2840
|
-
|
|
3029
|
+
delete(key) {
|
|
3030
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
|
|
3031
|
+
return this.map.delete(key);
|
|
3032
|
+
for (const k of this.map.keys())
|
|
3033
|
+
if (this.keyEquals(k, key))
|
|
3034
|
+
return this.map.delete(k);
|
|
3035
|
+
return this.map.delete(key);
|
|
2841
3036
|
}
|
|
2842
|
-
|
|
2843
|
-
|
|
3037
|
+
getOrDefault(key, defaultValue) {
|
|
3038
|
+
return this.get(key) ?? defaultValue;
|
|
3039
|
+
}
|
|
3040
|
+
getOrCreate(key, creatorOrValue) {
|
|
3041
|
+
if (!this.has(key)) {
|
|
2844
3042
|
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2845
|
-
this.set(
|
|
2846
|
-
return value;
|
|
3043
|
+
return this.set(key, value);
|
|
2847
3044
|
}
|
|
2848
|
-
return this.get(
|
|
2849
|
-
}
|
|
2850
|
-
delete(key1) {
|
|
2851
|
-
return this.map1.delete(key1);
|
|
3045
|
+
return this.get(key);
|
|
2852
3046
|
}
|
|
2853
3047
|
clear() {
|
|
2854
|
-
this.
|
|
3048
|
+
this.map.clear();
|
|
2855
3049
|
}
|
|
2856
3050
|
get size() {
|
|
2857
|
-
return this.
|
|
3051
|
+
return this.map.size;
|
|
2858
3052
|
}
|
|
2859
3053
|
isEmpty() {
|
|
2860
3054
|
return this.size === 0;
|
|
2861
3055
|
}
|
|
2862
3056
|
forEach(callbackfn, thisArg) {
|
|
2863
|
-
this.
|
|
3057
|
+
this.map.forEach((value, key) => callbackfn.call(thisArg, value, key, this));
|
|
2864
3058
|
}
|
|
2865
3059
|
*keys() {
|
|
2866
|
-
yield* this.
|
|
3060
|
+
yield* this.map.keys();
|
|
2867
3061
|
}
|
|
2868
3062
|
*values() {
|
|
2869
|
-
yield* this.
|
|
3063
|
+
yield* this.map.values();
|
|
2870
3064
|
}
|
|
2871
3065
|
*entries() {
|
|
2872
|
-
for (const [
|
|
2873
|
-
yield [
|
|
3066
|
+
for (const [key, value] of this.map)
|
|
3067
|
+
yield [key, value];
|
|
2874
3068
|
}
|
|
2875
3069
|
keysArray() {
|
|
2876
3070
|
return [...this.keys()];
|
|
@@ -2900,34 +3094,34 @@ var Map1 = class _Map1 {
|
|
|
2900
3094
|
yield* this.entries();
|
|
2901
3095
|
}
|
|
2902
3096
|
clone() {
|
|
2903
|
-
return new
|
|
3097
|
+
return new _UniMap(this, this.keyEquals);
|
|
2904
3098
|
}
|
|
2905
3099
|
merge(other, conflictResolver) {
|
|
2906
|
-
for (const [
|
|
2907
|
-
if (this.has(
|
|
2908
|
-
this.set(
|
|
3100
|
+
for (const [key, value] of other.entries()) {
|
|
3101
|
+
if (this.has(key) && conflictResolver) {
|
|
3102
|
+
this.set(key, conflictResolver(this.get(key), value, key));
|
|
2909
3103
|
} else {
|
|
2910
|
-
this.set(
|
|
3104
|
+
this.set(key, value);
|
|
2911
3105
|
}
|
|
2912
3106
|
}
|
|
2913
3107
|
return this;
|
|
2914
3108
|
}
|
|
2915
3109
|
some(fn) {
|
|
2916
|
-
for (const [
|
|
2917
|
-
if (fn(value,
|
|
3110
|
+
for (const [key, value] of this.map) {
|
|
3111
|
+
if (fn(value, key)) return true;
|
|
2918
3112
|
}
|
|
2919
3113
|
return false;
|
|
2920
3114
|
}
|
|
2921
3115
|
every(fn) {
|
|
2922
|
-
for (const [
|
|
2923
|
-
if (!fn(value,
|
|
3116
|
+
for (const [key, value] of this.map) {
|
|
3117
|
+
if (!fn(value, key)) return false;
|
|
2924
3118
|
}
|
|
2925
3119
|
return true;
|
|
2926
3120
|
}
|
|
2927
3121
|
filter(predicate) {
|
|
2928
3122
|
const result = new this.constructor();
|
|
2929
|
-
for (const [
|
|
2930
|
-
if (predicate(value,
|
|
3123
|
+
for (const [key, value] of this.map) {
|
|
3124
|
+
if (predicate(value, key, this)) result.set(key, value);
|
|
2931
3125
|
}
|
|
2932
3126
|
return result;
|
|
2933
3127
|
}
|
|
@@ -2950,41 +3144,48 @@ var Map1 = class _Map1 {
|
|
|
2950
3144
|
start = first;
|
|
2951
3145
|
}
|
|
2952
3146
|
for (let current = start; !current.done; current = iterator.next()) {
|
|
2953
|
-
const [
|
|
2954
|
-
acc = fn(acc, value,
|
|
3147
|
+
const [key, value] = current.value;
|
|
3148
|
+
acc = fn(acc, value, key);
|
|
2955
3149
|
}
|
|
2956
3150
|
return acc;
|
|
2957
3151
|
}
|
|
2958
3152
|
mapEntries(fn) {
|
|
2959
3153
|
let result = [];
|
|
2960
|
-
for (const [
|
|
2961
|
-
result.push(fn(value,
|
|
3154
|
+
for (const [key, value] of this.map) {
|
|
3155
|
+
result.push(fn(value, key));
|
|
2962
3156
|
}
|
|
2963
3157
|
return result;
|
|
2964
3158
|
}
|
|
2965
3159
|
mapValues(fn) {
|
|
2966
|
-
let result = new
|
|
2967
|
-
for (const [
|
|
2968
|
-
result.set(
|
|
3160
|
+
let result = new _UniMap();
|
|
3161
|
+
for (const [key, value] of this.map) {
|
|
3162
|
+
result.set(key, fn(value, key));
|
|
2969
3163
|
}
|
|
2970
3164
|
return result;
|
|
2971
3165
|
}
|
|
2972
3166
|
toMap() {
|
|
2973
|
-
return new Map(this.
|
|
3167
|
+
return new Map(this.map);
|
|
2974
3168
|
}
|
|
2975
3169
|
toString() {
|
|
2976
|
-
const entries = [...this.
|
|
2977
|
-
return `
|
|
3170
|
+
const entries = [...this.map].map(([k, v]) => `${stringify(k)} => ${stringify(v)}`).join(", ");
|
|
3171
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
|
|
2978
3172
|
}
|
|
2979
3173
|
};
|
|
2980
3174
|
|
|
2981
|
-
// src/core/
|
|
2982
|
-
var
|
|
3175
|
+
// src/core/bi-map.ts
|
|
3176
|
+
var BiMap = class _BiMap extends BaseContainer {
|
|
2983
3177
|
constructor(entries) {
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
3178
|
+
super();
|
|
3179
|
+
__publicField(this, "map1");
|
|
3180
|
+
__publicField(this, "key1Equals", DefaultEqualityFn);
|
|
3181
|
+
__publicField(this, "key2Equals", DefaultEqualityFn);
|
|
3182
|
+
this.map1 = new UniMap(this.key1Equals);
|
|
3183
|
+
if (entries instanceof _BiMap) {
|
|
3184
|
+
for (const [key1, map2] of entries.map1) {
|
|
3185
|
+
const newMap2 = this.map1.set(key1, new UniMap(this.key2Equals));
|
|
3186
|
+
for (const [key2, value] of map2) {
|
|
3187
|
+
newMap2.set(key2, value);
|
|
3188
|
+
}
|
|
2988
3189
|
}
|
|
2989
3190
|
} else if (entries) {
|
|
2990
3191
|
for (const [key1, key2, value] of entries) {
|
|
@@ -2996,9 +3197,7 @@ var Map2 = class _Map2 {
|
|
|
2996
3197
|
return this.map1.get(key1)?.has(key2) ?? false;
|
|
2997
3198
|
}
|
|
2998
3199
|
set(key1, key2, value) {
|
|
2999
|
-
|
|
3000
|
-
map2.set(key2, value);
|
|
3001
|
-
return value;
|
|
3200
|
+
return this.map1.getOrCreate(key1, () => new UniMap(this.key2Equals)).set(key2, value);
|
|
3002
3201
|
}
|
|
3003
3202
|
get(key1, key2) {
|
|
3004
3203
|
return this.map1.get(key1)?.get(key2);
|
|
@@ -3076,7 +3275,7 @@ var Map2 = class _Map2 {
|
|
|
3076
3275
|
yield* this.entries();
|
|
3077
3276
|
}
|
|
3078
3277
|
clone() {
|
|
3079
|
-
return new
|
|
3278
|
+
return new _BiMap(this);
|
|
3080
3279
|
}
|
|
3081
3280
|
merge(other, conflictResolver) {
|
|
3082
3281
|
for (const [key1, key2, value] of other.entries()) {
|
|
@@ -3147,7 +3346,7 @@ var Map2 = class _Map2 {
|
|
|
3147
3346
|
return result;
|
|
3148
3347
|
}
|
|
3149
3348
|
mapValues(fn) {
|
|
3150
|
-
let result = new
|
|
3349
|
+
let result = new _BiMap();
|
|
3151
3350
|
for (const [key1, map2] of this.map1) {
|
|
3152
3351
|
for (const [key2, value] of map2) {
|
|
3153
3352
|
result.set(key1, key2, fn(value, key1, key2));
|
|
@@ -3167,24 +3366,28 @@ var Map2 = class _Map2 {
|
|
|
3167
3366
|
toString() {
|
|
3168
3367
|
const entries = [];
|
|
3169
3368
|
for (const [key1, map2] of this.map1) {
|
|
3170
|
-
const inner = [...map2].map(([key2, v]) => `${
|
|
3171
|
-
entries.push(`${
|
|
3369
|
+
const inner = [...map2].map(([key2, v]) => `${stringify(key2)} => ${stringify(v)}`).join(", ");
|
|
3370
|
+
entries.push(`${stringify(key1)} => { ${inner} }`);
|
|
3172
3371
|
}
|
|
3173
|
-
return `
|
|
3372
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
|
|
3174
3373
|
}
|
|
3175
3374
|
};
|
|
3176
3375
|
|
|
3177
|
-
// src/core/
|
|
3178
|
-
var
|
|
3376
|
+
// src/core/tri-map.ts
|
|
3377
|
+
var TriMap = class _TriMap extends BaseContainer {
|
|
3179
3378
|
constructor(entries) {
|
|
3180
|
-
|
|
3181
|
-
|
|
3379
|
+
super();
|
|
3380
|
+
__publicField(this, "map1");
|
|
3381
|
+
__publicField(this, "key1Equals", DefaultEqualityFn);
|
|
3382
|
+
__publicField(this, "key2Equals", DefaultEqualityFn);
|
|
3383
|
+
__publicField(this, "key3Equals", DefaultEqualityFn);
|
|
3384
|
+
this.map1 = new UniMap(this.key1Equals);
|
|
3385
|
+
if (entries instanceof _TriMap) {
|
|
3182
3386
|
for (const [key1, map2] of entries.map1) {
|
|
3183
|
-
const newMap2 =
|
|
3387
|
+
const newMap2 = this.map1.set(key1, new UniMap(this.key2Equals));
|
|
3184
3388
|
for (const [key2, map3] of map2) {
|
|
3185
|
-
newMap2.set(key2, new
|
|
3389
|
+
newMap2.set(key2, new UniMap(map3, this.key3Equals));
|
|
3186
3390
|
}
|
|
3187
|
-
this.map1.set(key1, newMap2);
|
|
3188
3391
|
}
|
|
3189
3392
|
} else if (entries) {
|
|
3190
3393
|
for (const [key1, key2, key3, value] of entries) {
|
|
@@ -3196,10 +3399,8 @@ var Map3 = class _Map3 {
|
|
|
3196
3399
|
return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
|
|
3197
3400
|
}
|
|
3198
3401
|
set(key1, key2, key3, value) {
|
|
3199
|
-
let map2 = this.map1.
|
|
3200
|
-
|
|
3201
|
-
let map3 = map2.get(key2);
|
|
3202
|
-
if (!map3) map2.set(key2, map3 = /* @__PURE__ */ new Map());
|
|
3402
|
+
let map2 = this.map1.getOrCreate(key1, () => new UniMap(this.key2Equals));
|
|
3403
|
+
let map3 = map2.getOrCreate(key2, () => new UniMap(this.key3Equals));
|
|
3203
3404
|
map3.set(key3, value);
|
|
3204
3405
|
return value;
|
|
3205
3406
|
}
|
|
@@ -3291,7 +3492,7 @@ var Map3 = class _Map3 {
|
|
|
3291
3492
|
yield* this.entries();
|
|
3292
3493
|
}
|
|
3293
3494
|
clone() {
|
|
3294
|
-
return new
|
|
3495
|
+
return new _TriMap(this);
|
|
3295
3496
|
}
|
|
3296
3497
|
merge(other, conflictResolver) {
|
|
3297
3498
|
for (const [key1, key2, key3, value] of other.entries()) {
|
|
@@ -3370,7 +3571,7 @@ var Map3 = class _Map3 {
|
|
|
3370
3571
|
return result;
|
|
3371
3572
|
}
|
|
3372
3573
|
mapValues(fn) {
|
|
3373
|
-
let result = new
|
|
3574
|
+
let result = new _TriMap();
|
|
3374
3575
|
for (const [key1, map2] of this.map1) {
|
|
3375
3576
|
for (const [key2, map3] of map2) {
|
|
3376
3577
|
for (const [key3, value] of map3) {
|
|
@@ -3395,22 +3596,32 @@ var Map3 = class _Map3 {
|
|
|
3395
3596
|
const entries = [];
|
|
3396
3597
|
for (const [key1, map2] of this.map1) {
|
|
3397
3598
|
for (const [key2, map3] of map2) {
|
|
3398
|
-
const inner = [...map3].map(([key3, v]) => `${
|
|
3399
|
-
entries.push(`${
|
|
3599
|
+
const inner = [...map3].map(([key3, v]) => `${stringify(key3)} => ${stringify(v)}`).join(", ");
|
|
3600
|
+
entries.push(`${stringify(key1)} => ${stringify(key2)} => { ${inner} }`);
|
|
3400
3601
|
}
|
|
3401
3602
|
}
|
|
3402
|
-
return `
|
|
3603
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries.join(", ")} }`;
|
|
3403
3604
|
}
|
|
3404
3605
|
};
|
|
3405
3606
|
|
|
3406
3607
|
// src/core/set.ts
|
|
3407
|
-
var
|
|
3408
|
-
constructor(
|
|
3608
|
+
var ValueSet = class _ValueSet extends BaseContainer {
|
|
3609
|
+
constructor(...args) {
|
|
3610
|
+
super();
|
|
3409
3611
|
__publicField(this, "data");
|
|
3410
|
-
this
|
|
3612
|
+
__publicField(this, "equals");
|
|
3613
|
+
const maybeEquals = args.at(-1);
|
|
3614
|
+
this.equals = isFunction2(maybeEquals) ? args.pop() : DefaultEqualityFn;
|
|
3615
|
+
const entries = args[0];
|
|
3616
|
+
this.data = new Set(entries);
|
|
3617
|
+
}
|
|
3618
|
+
static createDeep(arg) {
|
|
3619
|
+
return arg ? new _ValueSet(arg, isDeepEqual2) : new _ValueSet(isDeepEqual2);
|
|
3411
3620
|
}
|
|
3412
3621
|
has(value) {
|
|
3413
|
-
|
|
3622
|
+
if (this.equals === DefaultEqualityFn)
|
|
3623
|
+
return this.data.has(value);
|
|
3624
|
+
return this.some((v) => this.equals(v, value));
|
|
3414
3625
|
}
|
|
3415
3626
|
add(value) {
|
|
3416
3627
|
if (!this.has(value))
|
|
@@ -3419,8 +3630,8 @@ var SetBase = class {
|
|
|
3419
3630
|
}
|
|
3420
3631
|
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
3421
3632
|
set(key, value) {
|
|
3422
|
-
if (!this.
|
|
3423
|
-
throw new TypeError("
|
|
3633
|
+
if (!this.equals(key, value))
|
|
3634
|
+
throw new TypeError("ValueSet.set() requires key === value.");
|
|
3424
3635
|
this.add(value);
|
|
3425
3636
|
}
|
|
3426
3637
|
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
@@ -3440,9 +3651,10 @@ var SetBase = class {
|
|
|
3440
3651
|
return this.get(key);
|
|
3441
3652
|
}
|
|
3442
3653
|
delete(value) {
|
|
3443
|
-
if (
|
|
3654
|
+
if (this.equals === DefaultEqualityFn || this.data.has(value))
|
|
3655
|
+
return this.data.delete(value);
|
|
3444
3656
|
for (const v of this.values()) {
|
|
3445
|
-
if (this.
|
|
3657
|
+
if (this.equals(v, value)) {
|
|
3446
3658
|
this.data.delete(v);
|
|
3447
3659
|
return true;
|
|
3448
3660
|
}
|
|
@@ -3489,7 +3701,7 @@ var SetBase = class {
|
|
|
3489
3701
|
yield* this.values();
|
|
3490
3702
|
}
|
|
3491
3703
|
clone() {
|
|
3492
|
-
const result =
|
|
3704
|
+
const result = new _ValueSet();
|
|
3493
3705
|
for (const v of this.values()) result.add(v);
|
|
3494
3706
|
return result;
|
|
3495
3707
|
}
|
|
@@ -3512,7 +3724,7 @@ var SetBase = class {
|
|
|
3512
3724
|
return true;
|
|
3513
3725
|
}
|
|
3514
3726
|
filter(predicate) {
|
|
3515
|
-
const result =
|
|
3727
|
+
const result = new _ValueSet();
|
|
3516
3728
|
for (const value of this.data)
|
|
3517
3729
|
if (predicate(value, this)) result.add(value);
|
|
3518
3730
|
return result;
|
|
@@ -3522,7 +3734,7 @@ var SetBase = class {
|
|
|
3522
3734
|
let first = iterator.next();
|
|
3523
3735
|
if (first.done) {
|
|
3524
3736
|
if (arguments.length < 2) {
|
|
3525
|
-
throw new TypeError("Reduce of empty
|
|
3737
|
+
throw new TypeError("Reduce of empty ValueSet with no initial value!");
|
|
3526
3738
|
}
|
|
3527
3739
|
return init;
|
|
3528
3740
|
}
|
|
@@ -3542,7 +3754,7 @@ var SetBase = class {
|
|
|
3542
3754
|
return acc;
|
|
3543
3755
|
}
|
|
3544
3756
|
mapValues(fn) {
|
|
3545
|
-
let result =
|
|
3757
|
+
let result = new _ValueSet();
|
|
3546
3758
|
for (const value of this.data) {
|
|
3547
3759
|
result.add(fn(value));
|
|
3548
3760
|
}
|
|
@@ -3556,7 +3768,7 @@ var SetBase = class {
|
|
|
3556
3768
|
return result;
|
|
3557
3769
|
}
|
|
3558
3770
|
map(fn) {
|
|
3559
|
-
let result =
|
|
3771
|
+
let result = new _ValueSet();
|
|
3560
3772
|
for (const value of this.values()) {
|
|
3561
3773
|
result.add(fn(value));
|
|
3562
3774
|
}
|
|
@@ -3569,41 +3781,14 @@ var SetBase = class {
|
|
|
3569
3781
|
return [...this.values()];
|
|
3570
3782
|
}
|
|
3571
3783
|
toString() {
|
|
3572
|
-
return
|
|
3573
|
-
}
|
|
3574
|
-
};
|
|
3575
|
-
var Set1 = class _Set1 extends SetBase {
|
|
3576
|
-
constructor(entries) {
|
|
3577
|
-
super(entries);
|
|
3578
|
-
}
|
|
3579
|
-
createEmpty() {
|
|
3580
|
-
return new _Set1();
|
|
3581
|
-
}
|
|
3582
|
-
valueEquals(a, b) {
|
|
3583
|
-
return a === b;
|
|
3584
|
-
}
|
|
3585
|
-
getName() {
|
|
3586
|
-
return "Set1";
|
|
3587
|
-
}
|
|
3588
|
-
};
|
|
3589
|
-
var DeepSet = class _DeepSet extends SetBase {
|
|
3590
|
-
constructor(entries) {
|
|
3591
|
-
super(entries);
|
|
3592
|
-
}
|
|
3593
|
-
createEmpty() {
|
|
3594
|
-
return new _DeepSet();
|
|
3595
|
-
}
|
|
3596
|
-
valueEquals(a, b) {
|
|
3597
|
-
return isDeepEqual2(a, b);
|
|
3598
|
-
}
|
|
3599
|
-
getName() {
|
|
3600
|
-
return "DeepSet";
|
|
3784
|
+
return stringify(this.data);
|
|
3601
3785
|
}
|
|
3602
3786
|
};
|
|
3603
3787
|
|
|
3604
3788
|
// src/core/multi-container.ts
|
|
3605
|
-
var MultiContainer = class {
|
|
3789
|
+
var MultiContainer = class extends BaseContainer {
|
|
3606
3790
|
constructor(base) {
|
|
3791
|
+
super();
|
|
3607
3792
|
this.base = base;
|
|
3608
3793
|
}
|
|
3609
3794
|
isEmpty() {
|
|
@@ -3659,17 +3844,382 @@ var MultiContainer = class {
|
|
|
3659
3844
|
const entries = [];
|
|
3660
3845
|
for (const keys of this.keys()) {
|
|
3661
3846
|
const arr = this.getAll(...keys);
|
|
3662
|
-
const keyStr = Array.isArray(keys) ?
|
|
3663
|
-
const valuesStr = Array.isArray(arr) ?
|
|
3847
|
+
const keyStr = Array.isArray(keys) ? stringify(keys) : "[ ]";
|
|
3848
|
+
const valuesStr = Array.isArray(arr) ? stringify(arr) : "[ ]";
|
|
3664
3849
|
entries.push(`${keyStr} => ${valuesStr}`);
|
|
3665
3850
|
}
|
|
3666
|
-
return `MultiContainer{ ${entries.join(", ")} }
|
|
3851
|
+
return entries.length === 0 ? `MultiContainer{ }` : `MultiContainer{ ${entries.join(", ")} }`;
|
|
3667
3852
|
}
|
|
3668
3853
|
};
|
|
3669
3854
|
function asMulti(base) {
|
|
3670
3855
|
return new MultiContainer(base);
|
|
3671
3856
|
}
|
|
3672
3857
|
|
|
3858
|
+
// src/core/linked-list.ts
|
|
3859
|
+
var LinkedListNode = class {
|
|
3860
|
+
constructor(value) {
|
|
3861
|
+
this.value = value;
|
|
3862
|
+
__publicField(this, "next", null);
|
|
3863
|
+
__publicField(this, "prev", null);
|
|
3864
|
+
}
|
|
3865
|
+
};
|
|
3866
|
+
var LinkedList = class _LinkedList extends BaseContainer {
|
|
3867
|
+
constructor(...args) {
|
|
3868
|
+
super();
|
|
3869
|
+
__publicField(this, "_head", null);
|
|
3870
|
+
__publicField(this, "_tail", null);
|
|
3871
|
+
__publicField(this, "_size", 0);
|
|
3872
|
+
__publicField(this, "equals");
|
|
3873
|
+
const maybeEquals = args.at(-1);
|
|
3874
|
+
this.equals = isFunction2(maybeEquals) ? args.pop() : DefaultEqualityFn;
|
|
3875
|
+
const entries = args[0];
|
|
3876
|
+
if (entries) {
|
|
3877
|
+
for (const v of entries) {
|
|
3878
|
+
this.push(v);
|
|
3879
|
+
}
|
|
3880
|
+
}
|
|
3881
|
+
}
|
|
3882
|
+
static createDeep(entries) {
|
|
3883
|
+
if (entries) {
|
|
3884
|
+
return new _LinkedList(entries, isDeepEqual2);
|
|
3885
|
+
} else {
|
|
3886
|
+
return new _LinkedList(isDeepEqual2);
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
get length() {
|
|
3890
|
+
return this._size;
|
|
3891
|
+
}
|
|
3892
|
+
get first() {
|
|
3893
|
+
return this._head?.value;
|
|
3894
|
+
}
|
|
3895
|
+
get last() {
|
|
3896
|
+
return this._tail?.value;
|
|
3897
|
+
}
|
|
3898
|
+
/** Add item to the end of the list */
|
|
3899
|
+
push(value) {
|
|
3900
|
+
const node = new LinkedListNode(value);
|
|
3901
|
+
if (!this._tail) {
|
|
3902
|
+
this._head = this._tail = node;
|
|
3903
|
+
} else {
|
|
3904
|
+
node.prev = this._tail;
|
|
3905
|
+
this._tail.next = node;
|
|
3906
|
+
this._tail = node;
|
|
3907
|
+
}
|
|
3908
|
+
this._size++;
|
|
3909
|
+
}
|
|
3910
|
+
/** Remove item from the end of the list */
|
|
3911
|
+
pop() {
|
|
3912
|
+
if (!this._tail) return void 0;
|
|
3913
|
+
const value = this._tail.value;
|
|
3914
|
+
this._tail = this._tail.prev;
|
|
3915
|
+
if (this._tail) this._tail.next = null;
|
|
3916
|
+
else this._head = null;
|
|
3917
|
+
this._size--;
|
|
3918
|
+
return value;
|
|
3919
|
+
}
|
|
3920
|
+
/** Add item to the beginning of the list */
|
|
3921
|
+
unshift(value) {
|
|
3922
|
+
const node = new LinkedListNode(value);
|
|
3923
|
+
if (!this._head) {
|
|
3924
|
+
this._head = this._tail = node;
|
|
3925
|
+
} else {
|
|
3926
|
+
node.next = this._head;
|
|
3927
|
+
this._head.prev = node;
|
|
3928
|
+
this._head = node;
|
|
3929
|
+
}
|
|
3930
|
+
this._size++;
|
|
3931
|
+
}
|
|
3932
|
+
/** Remove item from the beginning of the list */
|
|
3933
|
+
shift() {
|
|
3934
|
+
if (!this._head) return void 0;
|
|
3935
|
+
const value = this._head.value;
|
|
3936
|
+
this._head = this._head.next;
|
|
3937
|
+
if (this._head) this._head.prev = null;
|
|
3938
|
+
else this._tail = null;
|
|
3939
|
+
this._size--;
|
|
3940
|
+
return value;
|
|
3941
|
+
}
|
|
3942
|
+
/** Check if value exists in the list */
|
|
3943
|
+
has(value) {
|
|
3944
|
+
for (let node = this._head; node; node = node.next) {
|
|
3945
|
+
if (this.equals(node.value, value)) return true;
|
|
3946
|
+
}
|
|
3947
|
+
return false;
|
|
3948
|
+
}
|
|
3949
|
+
/** Get value at index (O(n/2)) */
|
|
3950
|
+
get(index) {
|
|
3951
|
+
return this.nodeAt(index)?.value;
|
|
3952
|
+
}
|
|
3953
|
+
/** Set value at index (O(n/2)) */
|
|
3954
|
+
set(index, value) {
|
|
3955
|
+
const node = this.nodeAt(index);
|
|
3956
|
+
if (!node) return false;
|
|
3957
|
+
node.value = value;
|
|
3958
|
+
return true;
|
|
3959
|
+
}
|
|
3960
|
+
/** Insert value at index (O(n/2)) */
|
|
3961
|
+
insertAt(index, value) {
|
|
3962
|
+
if (index < 0 || index > this._size) return false;
|
|
3963
|
+
if (index === 0) {
|
|
3964
|
+
this.unshift(value);
|
|
3965
|
+
return true;
|
|
3966
|
+
}
|
|
3967
|
+
if (index === this._size) {
|
|
3968
|
+
this.push(value);
|
|
3969
|
+
return true;
|
|
3970
|
+
}
|
|
3971
|
+
const nextNode = this.nodeAt(index);
|
|
3972
|
+
if (!nextNode) return false;
|
|
3973
|
+
const prevNode = nextNode.prev;
|
|
3974
|
+
const newNode = new LinkedListNode(value);
|
|
3975
|
+
newNode.next = nextNode;
|
|
3976
|
+
newNode.prev = prevNode;
|
|
3977
|
+
if (prevNode) prevNode.next = newNode;
|
|
3978
|
+
nextNode.prev = newNode;
|
|
3979
|
+
this._size++;
|
|
3980
|
+
return true;
|
|
3981
|
+
}
|
|
3982
|
+
/** Remove value at index (O(n/2)) */
|
|
3983
|
+
removeAt(index) {
|
|
3984
|
+
const node = this.nodeAt(index);
|
|
3985
|
+
if (!node) return void 0;
|
|
3986
|
+
if (node.prev) node.prev.next = node.next;
|
|
3987
|
+
else this._head = node.next;
|
|
3988
|
+
if (node.next) node.next.prev = node.prev;
|
|
3989
|
+
else this._tail = node.prev;
|
|
3990
|
+
this._size--;
|
|
3991
|
+
return node.value;
|
|
3992
|
+
}
|
|
3993
|
+
/** Remove first matching value (O(n)) */
|
|
3994
|
+
remove(value) {
|
|
3995
|
+
for (let node = this._head; node; node = node.next) {
|
|
3996
|
+
if (this.equals(node.value, value)) {
|
|
3997
|
+
if (node.prev) node.prev.next = node.next;
|
|
3998
|
+
else this._head = node.next;
|
|
3999
|
+
if (node.next) node.next.prev = node.prev;
|
|
4000
|
+
else this._tail = node.prev;
|
|
4001
|
+
this._size--;
|
|
4002
|
+
return true;
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
4005
|
+
return false;
|
|
4006
|
+
}
|
|
4007
|
+
/** Convert to array */
|
|
4008
|
+
toArray() {
|
|
4009
|
+
const result = [];
|
|
4010
|
+
for (const v of this) result.push(v);
|
|
4011
|
+
return result;
|
|
4012
|
+
}
|
|
4013
|
+
/** Replace contents from array */
|
|
4014
|
+
fromArray(values) {
|
|
4015
|
+
this.clear();
|
|
4016
|
+
for (const v of values) this.push(v);
|
|
4017
|
+
}
|
|
4018
|
+
/** Clear all nodes */
|
|
4019
|
+
clear() {
|
|
4020
|
+
this._head = this._tail = null;
|
|
4021
|
+
this._size = 0;
|
|
4022
|
+
}
|
|
4023
|
+
/** Iterator support */
|
|
4024
|
+
*[Symbol.iterator]() {
|
|
4025
|
+
yield* this.values();
|
|
4026
|
+
}
|
|
4027
|
+
*keys() {
|
|
4028
|
+
for (let id = 0; id < this._size; id++)
|
|
4029
|
+
yield id;
|
|
4030
|
+
}
|
|
4031
|
+
*values() {
|
|
4032
|
+
let node = this._head;
|
|
4033
|
+
while (node) {
|
|
4034
|
+
yield node.value;
|
|
4035
|
+
node = node.next;
|
|
4036
|
+
}
|
|
4037
|
+
}
|
|
4038
|
+
*entries() {
|
|
4039
|
+
let node = this._head;
|
|
4040
|
+
let id = 0;
|
|
4041
|
+
while (node) {
|
|
4042
|
+
yield [id++, node.value];
|
|
4043
|
+
node = node.next;
|
|
4044
|
+
}
|
|
4045
|
+
}
|
|
4046
|
+
toString() {
|
|
4047
|
+
return this._size === 0 ? `LinkedList(0)[ ]` : `LinkedList(${this._size})[ ${this.toArray().join(", ")} ]`;
|
|
4048
|
+
}
|
|
4049
|
+
// ---- Private helpers ----
|
|
4050
|
+
nodeAt(index) {
|
|
4051
|
+
if (index < 0 || index >= this._size) return null;
|
|
4052
|
+
let node;
|
|
4053
|
+
if (index < this._size / 2) {
|
|
4054
|
+
node = this._head;
|
|
4055
|
+
for (let i = 0; i < index; i++) node = node.next;
|
|
4056
|
+
} else {
|
|
4057
|
+
node = this._tail;
|
|
4058
|
+
for (let i = this._size - 1; i > index; i--) node = node.prev;
|
|
4059
|
+
}
|
|
4060
|
+
return node;
|
|
4061
|
+
}
|
|
4062
|
+
clone() {
|
|
4063
|
+
return new _LinkedList(this);
|
|
4064
|
+
}
|
|
4065
|
+
};
|
|
4066
|
+
|
|
4067
|
+
// src/utils/str/index.ts
|
|
4068
|
+
function toCharArray(str2) {
|
|
4069
|
+
return str2.split("");
|
|
4070
|
+
}
|
|
4071
|
+
function repeatString(repeatString2, repeatCount) {
|
|
4072
|
+
if (!isInteger2(repeatCount) || repeatCount < 0) {
|
|
4073
|
+
throw new Error("repeatStr: Invalid repeatCount = " + repeatCount);
|
|
4074
|
+
}
|
|
4075
|
+
return new Array(repeatCount + 1).join(repeatString2);
|
|
4076
|
+
}
|
|
4077
|
+
function chunkString(str2, chunkSize) {
|
|
4078
|
+
if (!isInteger2(chunkSize) || chunkSize < 1) {
|
|
4079
|
+
throw new Error("chunckString: Invalid chuckSize = " + chunkSize);
|
|
4080
|
+
}
|
|
4081
|
+
let result = [];
|
|
4082
|
+
for (let i = 0; i < str2.length; i += chunkSize) {
|
|
4083
|
+
result.push(str2.slice(i, i + chunkSize));
|
|
4084
|
+
}
|
|
4085
|
+
return result;
|
|
4086
|
+
}
|
|
4087
|
+
function replaceAt(str2, pos, removeCount, insert) {
|
|
4088
|
+
if (!isInteger2(removeCount) || removeCount < 0) {
|
|
4089
|
+
throw new Error("replaceAt: Invalid removeCount = " + removeCount);
|
|
4090
|
+
} else if (!isInteger2(pos) || pos < 0 || pos + removeCount > str2.length) {
|
|
4091
|
+
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " + str2.length);
|
|
4092
|
+
} else {
|
|
4093
|
+
return str2.substring(0, pos) + insert + str2.substring(pos + removeCount);
|
|
4094
|
+
}
|
|
4095
|
+
}
|
|
4096
|
+
function insertAt(str2, pos, insertStr) {
|
|
4097
|
+
return replaceAt(str2, pos, 0, insertStr);
|
|
4098
|
+
}
|
|
4099
|
+
function removeAt(str2, pos, removeCount) {
|
|
4100
|
+
return replaceAt(str2, pos, removeCount, "");
|
|
4101
|
+
}
|
|
4102
|
+
function charCount(str2, ch) {
|
|
4103
|
+
if (ch.length !== 1 || str2.length === 0) return 0;
|
|
4104
|
+
let count = 0;
|
|
4105
|
+
for (let i = 0; i < str2.length; i++) {
|
|
4106
|
+
if (str2[i] === ch) count++;
|
|
4107
|
+
}
|
|
4108
|
+
return count;
|
|
4109
|
+
}
|
|
4110
|
+
function makeSentenceFromPascal(PascalString) {
|
|
4111
|
+
if (PascalString === "") {
|
|
4112
|
+
return "";
|
|
4113
|
+
}
|
|
4114
|
+
let word = PascalString.charAt(0);
|
|
4115
|
+
let sentence = "";
|
|
4116
|
+
const addWord = () => {
|
|
4117
|
+
if (word !== "") {
|
|
4118
|
+
if (sentence === "") {
|
|
4119
|
+
sentence += word.charAt(0).toUpperCase() + word.substring(1);
|
|
4120
|
+
} else {
|
|
4121
|
+
sentence += " " + word;
|
|
4122
|
+
}
|
|
4123
|
+
word = "";
|
|
4124
|
+
}
|
|
4125
|
+
};
|
|
4126
|
+
const isLetterAndCapital = (c) => {
|
|
4127
|
+
return c.toUpperCase() !== c.toLowerCase() && c === c.toUpperCase();
|
|
4128
|
+
};
|
|
4129
|
+
for (let i = 1; i < PascalString.length; i++) {
|
|
4130
|
+
let c = PascalString.charAt(i);
|
|
4131
|
+
if (isLetterAndCapital(c)) {
|
|
4132
|
+
addWord();
|
|
4133
|
+
}
|
|
4134
|
+
word += c.toLowerCase();
|
|
4135
|
+
}
|
|
4136
|
+
addWord();
|
|
4137
|
+
return sentence;
|
|
4138
|
+
}
|
|
4139
|
+
function stringify(value, maxDepth = 5, seen = /* @__PURE__ */ new WeakSet()) {
|
|
4140
|
+
if (value === null) return "null";
|
|
4141
|
+
if (value === void 0) return "undefined";
|
|
4142
|
+
const t = typeof value;
|
|
4143
|
+
switch (t) {
|
|
4144
|
+
case "boolean":
|
|
4145
|
+
return value ? "true" : "false";
|
|
4146
|
+
case "number":
|
|
4147
|
+
if (isNaNValue2(value)) return "NaN";
|
|
4148
|
+
if (!isFinite3(value))
|
|
4149
|
+
return value < 0 ? "-Infinity" : "Infinity";
|
|
4150
|
+
return value.toString();
|
|
4151
|
+
case "bigint":
|
|
4152
|
+
return `${value}n`;
|
|
4153
|
+
case "string":
|
|
4154
|
+
return `"${value}"`;
|
|
4155
|
+
case "symbol":
|
|
4156
|
+
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
4157
|
+
case "function":
|
|
4158
|
+
return `[Function${value.name ? ` ${value.name}` : ""}]`;
|
|
4159
|
+
}
|
|
4160
|
+
if (seen.has(value))
|
|
4161
|
+
return "[Circular]";
|
|
4162
|
+
if (maxDepth <= 0)
|
|
4163
|
+
return "[Depth limit]";
|
|
4164
|
+
maxDepth--;
|
|
4165
|
+
seen.add(value);
|
|
4166
|
+
const strfy = (v) => stringify(v, maxDepth, seen);
|
|
4167
|
+
if (isArray2(value)) {
|
|
4168
|
+
const inner = value.map((v) => strfy(v)).join(", ");
|
|
4169
|
+
return inner.length === 0 ? "[ ]" : `[ ${inner} ]`;
|
|
4170
|
+
}
|
|
4171
|
+
if (ArrayBuffer.isView(value)) {
|
|
4172
|
+
if (value instanceof DataView)
|
|
4173
|
+
return `DataView(${value.byteLength})`;
|
|
4174
|
+
const inner = Array.from(value).map((v) => strfy(v)).join(", ");
|
|
4175
|
+
return `${value.constructor.name}[ ${inner} ]`;
|
|
4176
|
+
}
|
|
4177
|
+
if (value instanceof ArrayBuffer)
|
|
4178
|
+
return `ArrayBuffer(${value.byteLength})`;
|
|
4179
|
+
if (value instanceof Map) {
|
|
4180
|
+
const entries = Array.from(value.entries()).map(([k, v]) => `${strfy(k)} => ${strfy(v)}`).join(", ");
|
|
4181
|
+
return entries.length === 0 ? `Map(${value.size}){ }` : `Map(${value.size}){ ${entries} }`;
|
|
4182
|
+
}
|
|
4183
|
+
if (value instanceof Set) {
|
|
4184
|
+
const entries = Array.from(value.values()).map((v) => strfy(v)).join(", ");
|
|
4185
|
+
return entries.length === 0 ? `Set(${value.size}){ }` : `Set(${value.size}){ ${entries} }`;
|
|
4186
|
+
}
|
|
4187
|
+
if (value instanceof WeakMap)
|
|
4188
|
+
return "WeakMap{ ? }";
|
|
4189
|
+
if (value instanceof WeakSet)
|
|
4190
|
+
return "WeakSet{ ? }";
|
|
4191
|
+
if (typeof BaseContainer !== "undefined" && value instanceof BaseContainer)
|
|
4192
|
+
return value.toString();
|
|
4193
|
+
if (value instanceof Date)
|
|
4194
|
+
return `Date("${value.toISOString()}")`;
|
|
4195
|
+
if (value instanceof RegExp)
|
|
4196
|
+
return value.toString();
|
|
4197
|
+
if (value instanceof Error)
|
|
4198
|
+
return `${value.name}("${value.message}")`;
|
|
4199
|
+
if (value instanceof Promise)
|
|
4200
|
+
return "Promise{ ? }";
|
|
4201
|
+
if (value instanceof URL)
|
|
4202
|
+
return `URL("${value.href}")`;
|
|
4203
|
+
if (value instanceof URLSearchParams)
|
|
4204
|
+
return `URLSearchParams("${value.toString()}")`;
|
|
4205
|
+
if (value === Math) return "Math";
|
|
4206
|
+
if (value === JSON) return "JSON";
|
|
4207
|
+
if (value === Reflect) return "Reflect";
|
|
4208
|
+
if (value === Intl) return "Intl";
|
|
4209
|
+
if (t === "object") {
|
|
4210
|
+
const ctorName = value.constructor?.name ?? "Object";
|
|
4211
|
+
const entries = Object.entries(value).map(
|
|
4212
|
+
([key, val]) => `${strfy(key)}: ${strfy(val)}`
|
|
4213
|
+
);
|
|
4214
|
+
if (entries.length === 0) return `${ctorName}{ }`;
|
|
4215
|
+
return `${ctorName}{ ${entries.join(", ")} }`;
|
|
4216
|
+
}
|
|
4217
|
+
return String(value);
|
|
4218
|
+
}
|
|
4219
|
+
|
|
4220
|
+
// src/utils/index.ts
|
|
4221
|
+
var Is = guard_exports;
|
|
4222
|
+
|
|
3673
4223
|
// src/deprecated/vec2.ts
|
|
3674
4224
|
var Vec2 = class _Vec2 {
|
|
3675
4225
|
constructor(x, y) {
|
|
@@ -3746,27 +4296,1182 @@ var SmallIntCache = class {
|
|
|
3746
4296
|
this.neg = [];
|
|
3747
4297
|
}
|
|
3748
4298
|
};
|
|
4299
|
+
|
|
4300
|
+
// src/deprecated/map1.ts
|
|
4301
|
+
var Map1 = class _Map1 extends BaseContainer {
|
|
4302
|
+
constructor(entries) {
|
|
4303
|
+
super();
|
|
4304
|
+
__publicField(this, "map1");
|
|
4305
|
+
this.map1 = entries instanceof _Map1 ? new Map(entries.map1) : new Map(entries);
|
|
4306
|
+
}
|
|
4307
|
+
has(key1) {
|
|
4308
|
+
return this.map1.has(key1);
|
|
4309
|
+
}
|
|
4310
|
+
set(key1, value) {
|
|
4311
|
+
this.map1.set(key1, value);
|
|
4312
|
+
return value;
|
|
4313
|
+
}
|
|
4314
|
+
get(key1) {
|
|
4315
|
+
return this.map1.get(key1);
|
|
4316
|
+
}
|
|
4317
|
+
getOrDefault(key1, defaultValue) {
|
|
4318
|
+
return this.get(key1) ?? defaultValue;
|
|
4319
|
+
}
|
|
4320
|
+
getOrCreate(key1, creatorOrValue) {
|
|
4321
|
+
if (!this.has(key1)) {
|
|
4322
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
4323
|
+
this.set(key1, value);
|
|
4324
|
+
return value;
|
|
4325
|
+
}
|
|
4326
|
+
return this.get(key1);
|
|
4327
|
+
}
|
|
4328
|
+
delete(key1) {
|
|
4329
|
+
return this.map1.delete(key1);
|
|
4330
|
+
}
|
|
4331
|
+
clear() {
|
|
4332
|
+
this.map1.clear();
|
|
4333
|
+
}
|
|
4334
|
+
get size() {
|
|
4335
|
+
return this.map1.size;
|
|
4336
|
+
}
|
|
4337
|
+
isEmpty() {
|
|
4338
|
+
return this.size === 0;
|
|
4339
|
+
}
|
|
4340
|
+
forEach(callbackfn, thisArg) {
|
|
4341
|
+
this.map1.forEach((value, key1) => callbackfn.call(thisArg, value, key1, this));
|
|
4342
|
+
}
|
|
4343
|
+
*keys() {
|
|
4344
|
+
yield* this.map1.keys();
|
|
4345
|
+
}
|
|
4346
|
+
*values() {
|
|
4347
|
+
yield* this.map1.values();
|
|
4348
|
+
}
|
|
4349
|
+
*entries() {
|
|
4350
|
+
for (const [key1, value] of this.map1)
|
|
4351
|
+
yield [key1, value];
|
|
4352
|
+
}
|
|
4353
|
+
keysArray() {
|
|
4354
|
+
return [...this.keys()];
|
|
4355
|
+
}
|
|
4356
|
+
valuesArray() {
|
|
4357
|
+
return [...this.values()];
|
|
4358
|
+
}
|
|
4359
|
+
entriesArray() {
|
|
4360
|
+
return [...this.entries()];
|
|
4361
|
+
}
|
|
4362
|
+
*kvKeys() {
|
|
4363
|
+
for (const key of this.keys()) {
|
|
4364
|
+
yield [key];
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
*kvValues() {
|
|
4368
|
+
for (const el of this.values()) {
|
|
4369
|
+
yield el;
|
|
4370
|
+
}
|
|
4371
|
+
}
|
|
4372
|
+
*kvEntries() {
|
|
4373
|
+
for (const [key, el] of this.entries()) {
|
|
4374
|
+
yield [[key], el];
|
|
4375
|
+
}
|
|
4376
|
+
}
|
|
4377
|
+
*[Symbol.iterator]() {
|
|
4378
|
+
yield* this.entries();
|
|
4379
|
+
}
|
|
4380
|
+
clone() {
|
|
4381
|
+
return new _Map1(this);
|
|
4382
|
+
}
|
|
4383
|
+
merge(other, conflictResolver) {
|
|
4384
|
+
for (const [key1, value] of other.entries()) {
|
|
4385
|
+
if (this.has(key1) && conflictResolver) {
|
|
4386
|
+
this.set(key1, conflictResolver(this.get(key1), value, key1));
|
|
4387
|
+
} else {
|
|
4388
|
+
this.set(key1, value);
|
|
4389
|
+
}
|
|
4390
|
+
}
|
|
4391
|
+
return this;
|
|
4392
|
+
}
|
|
4393
|
+
some(fn) {
|
|
4394
|
+
for (const [key1, value] of this.map1) {
|
|
4395
|
+
if (fn(value, key1)) return true;
|
|
4396
|
+
}
|
|
4397
|
+
return false;
|
|
4398
|
+
}
|
|
4399
|
+
every(fn) {
|
|
4400
|
+
for (const [key1, value] of this.map1) {
|
|
4401
|
+
if (!fn(value, key1)) return false;
|
|
4402
|
+
}
|
|
4403
|
+
return true;
|
|
4404
|
+
}
|
|
4405
|
+
filter(predicate) {
|
|
4406
|
+
const result = new this.constructor();
|
|
4407
|
+
for (const [key1, value] of this.map1) {
|
|
4408
|
+
if (predicate(value, key1, this)) result.set(key1, value);
|
|
4409
|
+
}
|
|
4410
|
+
return result;
|
|
4411
|
+
}
|
|
4412
|
+
reduce(fn, init) {
|
|
4413
|
+
let iterator = this.entries();
|
|
4414
|
+
let first = iterator.next();
|
|
4415
|
+
if (first.done) {
|
|
4416
|
+
if (arguments.length < 2) {
|
|
4417
|
+
throw new TypeError("Reduce of empty Map1 with no initial value!");
|
|
4418
|
+
}
|
|
4419
|
+
return init;
|
|
4420
|
+
}
|
|
4421
|
+
let acc;
|
|
4422
|
+
let start;
|
|
4423
|
+
if (arguments.length < 2) {
|
|
4424
|
+
acc = first.value[1];
|
|
4425
|
+
start = iterator.next();
|
|
4426
|
+
} else {
|
|
4427
|
+
acc = init;
|
|
4428
|
+
start = first;
|
|
4429
|
+
}
|
|
4430
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
4431
|
+
const [key1, value] = current.value;
|
|
4432
|
+
acc = fn(acc, value, key1);
|
|
4433
|
+
}
|
|
4434
|
+
return acc;
|
|
4435
|
+
}
|
|
4436
|
+
mapEntries(fn) {
|
|
4437
|
+
let result = [];
|
|
4438
|
+
for (const [key1, value] of this.map1) {
|
|
4439
|
+
result.push(fn(value, key1));
|
|
4440
|
+
}
|
|
4441
|
+
return result;
|
|
4442
|
+
}
|
|
4443
|
+
mapValues(fn) {
|
|
4444
|
+
let result = new _Map1();
|
|
4445
|
+
for (const [key1, value] of this.map1) {
|
|
4446
|
+
result.set(key1, fn(value, key1));
|
|
4447
|
+
}
|
|
4448
|
+
return result;
|
|
4449
|
+
}
|
|
4450
|
+
toMap() {
|
|
4451
|
+
return new Map(this.map1);
|
|
4452
|
+
}
|
|
4453
|
+
toString() {
|
|
4454
|
+
const entries = [...this.map1].map(([k, v]) => `${stringify(k)} => ${stringify(v)}`).join(", ");
|
|
4455
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
|
|
4456
|
+
}
|
|
4457
|
+
};
|
|
4458
|
+
|
|
4459
|
+
// src/deprecated/map2.ts
|
|
4460
|
+
var Map2 = class _Map2 extends BaseContainer {
|
|
4461
|
+
constructor(entries) {
|
|
4462
|
+
super();
|
|
4463
|
+
__publicField(this, "map1", /* @__PURE__ */ new Map());
|
|
4464
|
+
if (entries instanceof _Map2) {
|
|
4465
|
+
for (const [key1, inner] of entries.map1) {
|
|
4466
|
+
this.map1.set(key1, new Map(inner));
|
|
4467
|
+
}
|
|
4468
|
+
} else if (entries) {
|
|
4469
|
+
for (const [key1, key2, value] of entries) {
|
|
4470
|
+
this.set(key1, key2, value);
|
|
4471
|
+
}
|
|
4472
|
+
}
|
|
4473
|
+
}
|
|
4474
|
+
has(key1, key2) {
|
|
4475
|
+
return this.map1.get(key1)?.has(key2) ?? false;
|
|
4476
|
+
}
|
|
4477
|
+
set(key1, key2, value) {
|
|
4478
|
+
let map2 = this.map1.get(key1) ?? this.map1.set(key1, /* @__PURE__ */ new Map()).get(key1);
|
|
4479
|
+
map2.set(key2, value);
|
|
4480
|
+
return value;
|
|
4481
|
+
}
|
|
4482
|
+
get(key1, key2) {
|
|
4483
|
+
return this.map1.get(key1)?.get(key2);
|
|
4484
|
+
}
|
|
4485
|
+
getOrDefault(key1, key2, defaultValue) {
|
|
4486
|
+
return this.get(key1, key2) ?? defaultValue;
|
|
4487
|
+
}
|
|
4488
|
+
getOrCreate(key1, key2, creatorOrValue) {
|
|
4489
|
+
if (!this.has(key1, key2)) {
|
|
4490
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
4491
|
+
this.set(key1, key2, value);
|
|
4492
|
+
return value;
|
|
4493
|
+
}
|
|
4494
|
+
return this.get(key1, key2);
|
|
4495
|
+
}
|
|
4496
|
+
delete(key1, key2) {
|
|
4497
|
+
if (key2 === void 0) return this.map1.delete(key1);
|
|
4498
|
+
const map2 = this.map1.get(key1);
|
|
4499
|
+
if (!map2) return false;
|
|
4500
|
+
return map2.delete(key2);
|
|
4501
|
+
}
|
|
4502
|
+
clear() {
|
|
4503
|
+
this.map1.clear();
|
|
4504
|
+
}
|
|
4505
|
+
get size() {
|
|
4506
|
+
let count = 0;
|
|
4507
|
+
for (const map2 of this.map1.values()) {
|
|
4508
|
+
count += map2.size;
|
|
4509
|
+
}
|
|
4510
|
+
return count;
|
|
4511
|
+
}
|
|
4512
|
+
isEmpty() {
|
|
4513
|
+
return this.size === 0;
|
|
4514
|
+
}
|
|
4515
|
+
forEach(callbackfn, thisArg) {
|
|
4516
|
+
this.map1.forEach((map2, key1) => map2.forEach((value, key2) => callbackfn.call(thisArg, value, key1, key2, this)));
|
|
4517
|
+
}
|
|
4518
|
+
*keys() {
|
|
4519
|
+
for (const [key1, map2] of this.map1)
|
|
4520
|
+
for (const key2 of map2.keys())
|
|
4521
|
+
yield [key1, key2];
|
|
4522
|
+
}
|
|
4523
|
+
*values() {
|
|
4524
|
+
for (const map2 of this.map1.values())
|
|
4525
|
+
for (const value of map2.values())
|
|
4526
|
+
yield value;
|
|
4527
|
+
}
|
|
4528
|
+
*entries() {
|
|
4529
|
+
for (const [key1, map2] of this.map1)
|
|
4530
|
+
for (const [key2, value] of map2)
|
|
4531
|
+
yield [key1, key2, value];
|
|
4532
|
+
}
|
|
4533
|
+
keysArray() {
|
|
4534
|
+
return [...this.keys()];
|
|
4535
|
+
}
|
|
4536
|
+
valuesArray() {
|
|
4537
|
+
return [...this.values()];
|
|
4538
|
+
}
|
|
4539
|
+
entriesArray() {
|
|
4540
|
+
return [...this.entries()];
|
|
4541
|
+
}
|
|
4542
|
+
*kvKeys() {
|
|
4543
|
+
for (const [key1, key2] of this.keys())
|
|
4544
|
+
yield [key1, key2];
|
|
4545
|
+
}
|
|
4546
|
+
*kvValues() {
|
|
4547
|
+
for (const el of this.values())
|
|
4548
|
+
yield el;
|
|
4549
|
+
}
|
|
4550
|
+
*kvEntries() {
|
|
4551
|
+
for (const [key1, key2, el] of this.entries())
|
|
4552
|
+
yield [[key1, key2], el];
|
|
4553
|
+
}
|
|
4554
|
+
*[Symbol.iterator]() {
|
|
4555
|
+
yield* this.entries();
|
|
4556
|
+
}
|
|
4557
|
+
clone() {
|
|
4558
|
+
return new _Map2(this);
|
|
4559
|
+
}
|
|
4560
|
+
merge(other, conflictResolver) {
|
|
4561
|
+
for (const [key1, key2, value] of other.entries()) {
|
|
4562
|
+
if (this.has(key1, key2) && conflictResolver) {
|
|
4563
|
+
this.set(key1, key2, conflictResolver(this.get(key1, key2), value, key1, key2));
|
|
4564
|
+
} else {
|
|
4565
|
+
this.set(key1, key2, value);
|
|
4566
|
+
}
|
|
4567
|
+
}
|
|
4568
|
+
return this;
|
|
4569
|
+
}
|
|
4570
|
+
some(fn) {
|
|
4571
|
+
for (const [key1, map2] of this.map1) {
|
|
4572
|
+
for (const [key2, value] of map2) {
|
|
4573
|
+
if (fn(value, key1, key2)) return true;
|
|
4574
|
+
}
|
|
4575
|
+
}
|
|
4576
|
+
return false;
|
|
4577
|
+
}
|
|
4578
|
+
every(fn) {
|
|
4579
|
+
for (const [key1, map2] of this.map1) {
|
|
4580
|
+
for (const [key2, value] of map2) {
|
|
4581
|
+
if (!fn(value, key1, key2)) return false;
|
|
4582
|
+
}
|
|
4583
|
+
}
|
|
4584
|
+
return true;
|
|
4585
|
+
}
|
|
4586
|
+
filter(predicate) {
|
|
4587
|
+
const result = new this.constructor();
|
|
4588
|
+
for (const [key1, map2] of this.map1) {
|
|
4589
|
+
for (const [key2, value] of map2) {
|
|
4590
|
+
if (predicate(value, key1, key2, this)) result.set(key1, key2, value);
|
|
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 Map2 with no initial value!");
|
|
4601
|
+
}
|
|
4602
|
+
return init;
|
|
4603
|
+
}
|
|
4604
|
+
let acc;
|
|
4605
|
+
let start;
|
|
4606
|
+
if (arguments.length < 2) {
|
|
4607
|
+
acc = first.value[2];
|
|
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, value] = current.value;
|
|
4615
|
+
acc = fn(acc, value, key1, key2);
|
|
4616
|
+
}
|
|
4617
|
+
return acc;
|
|
4618
|
+
}
|
|
4619
|
+
mapEntries(fn) {
|
|
4620
|
+
let result = [];
|
|
4621
|
+
for (const [key1, map2] of this.map1) {
|
|
4622
|
+
for (const [key2, value] of map2) {
|
|
4623
|
+
result.push(fn(value, key1, key2));
|
|
4624
|
+
}
|
|
4625
|
+
}
|
|
4626
|
+
return result;
|
|
4627
|
+
}
|
|
4628
|
+
mapValues(fn) {
|
|
4629
|
+
let result = new _Map2();
|
|
4630
|
+
for (const [key1, map2] of this.map1) {
|
|
4631
|
+
for (const [key2, value] of map2) {
|
|
4632
|
+
result.set(key1, key2, fn(value, key1, key2));
|
|
4633
|
+
}
|
|
4634
|
+
}
|
|
4635
|
+
return result;
|
|
4636
|
+
}
|
|
4637
|
+
toMap() {
|
|
4638
|
+
let result = /* @__PURE__ */ new Map();
|
|
4639
|
+
for (const [key1, map2] of this.map1) {
|
|
4640
|
+
for (const [key2, value] of map2) {
|
|
4641
|
+
result.set([key1, key2], value);
|
|
4642
|
+
}
|
|
4643
|
+
}
|
|
4644
|
+
return result;
|
|
4645
|
+
}
|
|
4646
|
+
toString() {
|
|
4647
|
+
const entries = [];
|
|
4648
|
+
for (const [key1, map2] of this.map1) {
|
|
4649
|
+
const inner = [...map2].map(([key2, v]) => `${stringify(key2)} => ${stringify(v)}`).join(", ");
|
|
4650
|
+
entries.push(`${stringify(key1)} => { ${inner} }`);
|
|
4651
|
+
}
|
|
4652
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
|
|
4653
|
+
}
|
|
4654
|
+
};
|
|
4655
|
+
|
|
4656
|
+
// src/deprecated/map3.ts
|
|
4657
|
+
var Map3 = class _Map3 extends BaseContainer {
|
|
4658
|
+
constructor(entries) {
|
|
4659
|
+
super();
|
|
4660
|
+
__publicField(this, "map1", /* @__PURE__ */ new Map());
|
|
4661
|
+
if (entries instanceof _Map3) {
|
|
4662
|
+
for (const [key1, map2] of entries.map1) {
|
|
4663
|
+
const newMap2 = /* @__PURE__ */ new Map();
|
|
4664
|
+
for (const [key2, map3] of map2) {
|
|
4665
|
+
newMap2.set(key2, new Map(map3));
|
|
4666
|
+
}
|
|
4667
|
+
this.map1.set(key1, newMap2);
|
|
4668
|
+
}
|
|
4669
|
+
} else if (entries) {
|
|
4670
|
+
for (const [key1, key2, key3, value] of entries) {
|
|
4671
|
+
this.set(key1, key2, key3, value);
|
|
4672
|
+
}
|
|
4673
|
+
}
|
|
4674
|
+
}
|
|
4675
|
+
has(key1, key2, key3) {
|
|
4676
|
+
return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
|
|
4677
|
+
}
|
|
4678
|
+
set(key1, key2, key3, value) {
|
|
4679
|
+
let map2 = this.map1.get(key1);
|
|
4680
|
+
if (!map2) this.map1.set(key1, map2 = /* @__PURE__ */ new Map());
|
|
4681
|
+
let map3 = map2.get(key2);
|
|
4682
|
+
if (!map3) map2.set(key2, map3 = /* @__PURE__ */ new Map());
|
|
4683
|
+
map3.set(key3, value);
|
|
4684
|
+
return value;
|
|
4685
|
+
}
|
|
4686
|
+
get(key1, key2, key3) {
|
|
4687
|
+
return this.map1.get(key1)?.get(key2)?.get(key3);
|
|
4688
|
+
}
|
|
4689
|
+
getOrDefault(key1, key2, key3, defaultValue) {
|
|
4690
|
+
return this.get(key1, key2, key3) ?? defaultValue;
|
|
4691
|
+
}
|
|
4692
|
+
getOrCreate(key1, key2, key3, creatorOrValue) {
|
|
4693
|
+
if (!this.has(key1, key2, key3)) {
|
|
4694
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
4695
|
+
this.set(key1, key2, key3, value);
|
|
4696
|
+
return value;
|
|
4697
|
+
}
|
|
4698
|
+
return this.get(key1, key2, key3);
|
|
4699
|
+
}
|
|
4700
|
+
delete(key1, key2, key3) {
|
|
4701
|
+
if (key3 === void 0) {
|
|
4702
|
+
if (key2 === void 0) return this.map1.delete(key1);
|
|
4703
|
+
const map2 = this.map1.get(key1);
|
|
4704
|
+
if (!map2) return false;
|
|
4705
|
+
return map2.delete(key2);
|
|
4706
|
+
} else {
|
|
4707
|
+
if (key2 === void 0) return this.map1.delete(key1);
|
|
4708
|
+
const map3 = this.map1.get(key1)?.get(key2);
|
|
4709
|
+
if (!map3) return false;
|
|
4710
|
+
return map3.delete(key3);
|
|
4711
|
+
}
|
|
4712
|
+
}
|
|
4713
|
+
clear() {
|
|
4714
|
+
this.map1.clear();
|
|
4715
|
+
}
|
|
4716
|
+
get size() {
|
|
4717
|
+
let count = 0;
|
|
4718
|
+
for (const map2 of this.map1.values()) {
|
|
4719
|
+
for (const map3 of map2.values()) {
|
|
4720
|
+
count += map3.size;
|
|
4721
|
+
}
|
|
4722
|
+
}
|
|
4723
|
+
return count;
|
|
4724
|
+
}
|
|
4725
|
+
isEmpty() {
|
|
4726
|
+
return this.size === 0;
|
|
4727
|
+
}
|
|
4728
|
+
forEach(callbackfn, thisArg) {
|
|
4729
|
+
this.map1.forEach((map2, key1) => map2.forEach((map3, key2) => map3.forEach((value, key3) => callbackfn.call(thisArg, value, key1, key2, key3, this))));
|
|
4730
|
+
}
|
|
4731
|
+
*keys() {
|
|
4732
|
+
for (const [key1, map2] of this.map1)
|
|
4733
|
+
for (const [key2, map3] of map2)
|
|
4734
|
+
for (const key3 of map3.keys())
|
|
4735
|
+
yield [key1, key2, key3];
|
|
4736
|
+
}
|
|
4737
|
+
*values() {
|
|
4738
|
+
for (const map2 of this.map1.values())
|
|
4739
|
+
for (const map3 of map2.values())
|
|
4740
|
+
for (const value of map3.values())
|
|
4741
|
+
yield value;
|
|
4742
|
+
}
|
|
4743
|
+
*entries() {
|
|
4744
|
+
for (const [key1, map2] of this.map1)
|
|
4745
|
+
for (const [key2, map3] of map2)
|
|
4746
|
+
for (const [key3, value] of map3)
|
|
4747
|
+
yield [key1, key2, key3, value];
|
|
4748
|
+
}
|
|
4749
|
+
keysArray() {
|
|
4750
|
+
return [...this.keys()];
|
|
4751
|
+
}
|
|
4752
|
+
valuesArray() {
|
|
4753
|
+
return [...this.values()];
|
|
4754
|
+
}
|
|
4755
|
+
entriesArray() {
|
|
4756
|
+
return [...this.entries()];
|
|
4757
|
+
}
|
|
4758
|
+
*kvKeys() {
|
|
4759
|
+
for (const [key1, key2, key3] of this.keys())
|
|
4760
|
+
yield [key1, key2, key3];
|
|
4761
|
+
}
|
|
4762
|
+
*kvValues() {
|
|
4763
|
+
for (const el of this.values())
|
|
4764
|
+
yield el;
|
|
4765
|
+
}
|
|
4766
|
+
*kvEntries() {
|
|
4767
|
+
for (const [key1, key2, key3, el] of this.entries())
|
|
4768
|
+
yield [[key1, key2, key3], el];
|
|
4769
|
+
}
|
|
4770
|
+
*[Symbol.iterator]() {
|
|
4771
|
+
yield* this.entries();
|
|
4772
|
+
}
|
|
4773
|
+
clone() {
|
|
4774
|
+
return new _Map3(this);
|
|
4775
|
+
}
|
|
4776
|
+
merge(other, conflictResolver) {
|
|
4777
|
+
for (const [key1, key2, key3, value] of other.entries()) {
|
|
4778
|
+
if (this.has(key1, key2, key3) && conflictResolver) {
|
|
4779
|
+
this.set(key1, key2, key3, conflictResolver(this.get(key1, key2, key3), value, key1, key2, key3));
|
|
4780
|
+
} else {
|
|
4781
|
+
this.set(key1, key2, key3, value);
|
|
4782
|
+
}
|
|
4783
|
+
}
|
|
4784
|
+
return this;
|
|
4785
|
+
}
|
|
4786
|
+
some(fn) {
|
|
4787
|
+
for (const [key1, map2] of this.map1) {
|
|
4788
|
+
for (const [key2, map3] of map2) {
|
|
4789
|
+
for (const [key3, value] of map3) {
|
|
4790
|
+
if (fn(value, key1, key2, key3)) return true;
|
|
4791
|
+
}
|
|
4792
|
+
}
|
|
4793
|
+
}
|
|
4794
|
+
return false;
|
|
4795
|
+
}
|
|
4796
|
+
every(fn) {
|
|
4797
|
+
for (const [key1, map2] of this.map1) {
|
|
4798
|
+
for (const [key2, map3] of map2) {
|
|
4799
|
+
for (const [key3, value] of map3) {
|
|
4800
|
+
if (!fn(value, key1, key2, key3)) return false;
|
|
4801
|
+
}
|
|
4802
|
+
}
|
|
4803
|
+
}
|
|
4804
|
+
return true;
|
|
4805
|
+
}
|
|
4806
|
+
filter(predicate) {
|
|
4807
|
+
const result = new this.constructor();
|
|
4808
|
+
for (const [key1, map2] of this.map1) {
|
|
4809
|
+
for (const [key2, map3] of map2) {
|
|
4810
|
+
for (const [key3, value] of map3) {
|
|
4811
|
+
if (predicate(value, key1, key2, key3, this)) result.set(key1, key2, key3, value);
|
|
4812
|
+
}
|
|
4813
|
+
}
|
|
4814
|
+
}
|
|
4815
|
+
return result;
|
|
4816
|
+
}
|
|
4817
|
+
reduce(fn, init) {
|
|
4818
|
+
let iterator = this.entries();
|
|
4819
|
+
let first = iterator.next();
|
|
4820
|
+
if (first.done) {
|
|
4821
|
+
if (arguments.length < 2) {
|
|
4822
|
+
throw new TypeError("Reduce of empty Map3 with no initial value!");
|
|
4823
|
+
}
|
|
4824
|
+
return init;
|
|
4825
|
+
}
|
|
4826
|
+
let acc;
|
|
4827
|
+
let start;
|
|
4828
|
+
if (arguments.length < 2) {
|
|
4829
|
+
acc = first.value[3];
|
|
4830
|
+
start = iterator.next();
|
|
4831
|
+
} else {
|
|
4832
|
+
acc = init;
|
|
4833
|
+
start = first;
|
|
4834
|
+
}
|
|
4835
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
4836
|
+
const [key1, key2, key3, value] = current.value;
|
|
4837
|
+
acc = fn(acc, value, key1, key2, key3);
|
|
4838
|
+
}
|
|
4839
|
+
return acc;
|
|
4840
|
+
}
|
|
4841
|
+
mapEntries(fn) {
|
|
4842
|
+
let result = [];
|
|
4843
|
+
for (const [key1, map2] of this.map1) {
|
|
4844
|
+
for (const [key2, map3] of map2) {
|
|
4845
|
+
for (const [key3, value] of map3) {
|
|
4846
|
+
result.push(fn(value, key1, key2, key3));
|
|
4847
|
+
}
|
|
4848
|
+
}
|
|
4849
|
+
}
|
|
4850
|
+
return result;
|
|
4851
|
+
}
|
|
4852
|
+
mapValues(fn) {
|
|
4853
|
+
let result = new _Map3();
|
|
4854
|
+
for (const [key1, map2] of this.map1) {
|
|
4855
|
+
for (const [key2, map3] of map2) {
|
|
4856
|
+
for (const [key3, value] of map3) {
|
|
4857
|
+
result.set(key1, key2, key3, fn(value, key1, key2, key3));
|
|
4858
|
+
}
|
|
4859
|
+
}
|
|
4860
|
+
}
|
|
4861
|
+
return result;
|
|
4862
|
+
}
|
|
4863
|
+
toMap() {
|
|
4864
|
+
let result = /* @__PURE__ */ new Map();
|
|
4865
|
+
for (const [key1, map2] of this.map1) {
|
|
4866
|
+
for (const [key2, map3] of map2) {
|
|
4867
|
+
for (const [key3, value] of map3) {
|
|
4868
|
+
result.set([key1, key2, key3], value);
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4871
|
+
}
|
|
4872
|
+
return result;
|
|
4873
|
+
}
|
|
4874
|
+
toString() {
|
|
4875
|
+
const entries = [];
|
|
4876
|
+
for (const [key1, map2] of this.map1) {
|
|
4877
|
+
for (const [key2, map3] of map2) {
|
|
4878
|
+
const inner = [...map3].map(([key3, v]) => `${stringify(key3)} => ${stringify(v)}`).join(", ");
|
|
4879
|
+
entries.push(`${stringify(key1)} => ${stringify(key2)} => { ${inner} }`);
|
|
4880
|
+
}
|
|
4881
|
+
}
|
|
4882
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries.join(", ")} }`;
|
|
4883
|
+
}
|
|
4884
|
+
};
|
|
4885
|
+
|
|
4886
|
+
// src/deprecated/set.ts
|
|
4887
|
+
var SetBase = class extends BaseContainer {
|
|
4888
|
+
constructor(entries) {
|
|
4889
|
+
super();
|
|
4890
|
+
__publicField(this, "data");
|
|
4891
|
+
this.data = new Set(entries ?? []);
|
|
4892
|
+
}
|
|
4893
|
+
has(value) {
|
|
4894
|
+
return this.some((v) => this.valueEquals(v, value));
|
|
4895
|
+
}
|
|
4896
|
+
add(value) {
|
|
4897
|
+
if (!this.has(value))
|
|
4898
|
+
this.data.add(value);
|
|
4899
|
+
return value;
|
|
4900
|
+
}
|
|
4901
|
+
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
4902
|
+
set(key, value) {
|
|
4903
|
+
if (!this.valueEquals(key, value))
|
|
4904
|
+
throw new TypeError("SetBase.set() requires key === value.");
|
|
4905
|
+
this.add(value);
|
|
4906
|
+
}
|
|
4907
|
+
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
4908
|
+
get(key) {
|
|
4909
|
+
return this.has(key) ? key : void 0;
|
|
4910
|
+
}
|
|
4911
|
+
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
4912
|
+
getOrDefault(key, defaultValue) {
|
|
4913
|
+
return this.get(key) ?? defaultValue;
|
|
4914
|
+
}
|
|
4915
|
+
getOrCreate(key, creatorOrValue) {
|
|
4916
|
+
if (!this.has(key)) {
|
|
4917
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
4918
|
+
this.set(key, value);
|
|
4919
|
+
return value;
|
|
4920
|
+
}
|
|
4921
|
+
return this.get(key);
|
|
4922
|
+
}
|
|
4923
|
+
delete(value) {
|
|
4924
|
+
if (!this.has(value)) return false;
|
|
4925
|
+
for (const v of this.values()) {
|
|
4926
|
+
if (this.valueEquals(v, value)) {
|
|
4927
|
+
this.data.delete(v);
|
|
4928
|
+
return true;
|
|
4929
|
+
}
|
|
4930
|
+
}
|
|
4931
|
+
return false;
|
|
4932
|
+
}
|
|
4933
|
+
clear() {
|
|
4934
|
+
this.data.clear();
|
|
4935
|
+
}
|
|
4936
|
+
get size() {
|
|
4937
|
+
return this.data.size;
|
|
4938
|
+
}
|
|
4939
|
+
isEmpty() {
|
|
4940
|
+
return this.size === 0;
|
|
4941
|
+
}
|
|
4942
|
+
forEach(callbackfn, thisArg) {
|
|
4943
|
+
this.data.forEach((value) => callbackfn.call(thisArg, value, this));
|
|
4944
|
+
}
|
|
4945
|
+
*keys() {
|
|
4946
|
+
yield* this.data.keys();
|
|
4947
|
+
}
|
|
4948
|
+
*values() {
|
|
4949
|
+
yield* this.data.values();
|
|
4950
|
+
}
|
|
4951
|
+
*entries() {
|
|
4952
|
+
yield* this.data.entries();
|
|
4953
|
+
}
|
|
4954
|
+
*kvKeys() {
|
|
4955
|
+
for (const key of this.keys()) {
|
|
4956
|
+
yield [key];
|
|
4957
|
+
}
|
|
4958
|
+
}
|
|
4959
|
+
*kvValues() {
|
|
4960
|
+
for (const el of this.values()) {
|
|
4961
|
+
yield el;
|
|
4962
|
+
}
|
|
4963
|
+
}
|
|
4964
|
+
*kvEntries() {
|
|
4965
|
+
for (const [key, el] of this.entries()) {
|
|
4966
|
+
yield [[key], el];
|
|
4967
|
+
}
|
|
4968
|
+
}
|
|
4969
|
+
*[Symbol.iterator]() {
|
|
4970
|
+
yield* this.values();
|
|
4971
|
+
}
|
|
4972
|
+
clone() {
|
|
4973
|
+
const result = this.createEmpty();
|
|
4974
|
+
for (const v of this.values()) result.add(v);
|
|
4975
|
+
return result;
|
|
4976
|
+
}
|
|
4977
|
+
merge(other) {
|
|
4978
|
+
for (const value of other.values()) {
|
|
4979
|
+
this.add(value);
|
|
4980
|
+
}
|
|
4981
|
+
return this;
|
|
4982
|
+
}
|
|
4983
|
+
some(fn) {
|
|
4984
|
+
for (const value of this.data) {
|
|
4985
|
+
if (fn(value)) return true;
|
|
4986
|
+
}
|
|
4987
|
+
return false;
|
|
4988
|
+
}
|
|
4989
|
+
every(fn) {
|
|
4990
|
+
for (const value of this.data) {
|
|
4991
|
+
if (!fn(value)) return false;
|
|
4992
|
+
}
|
|
4993
|
+
return true;
|
|
4994
|
+
}
|
|
4995
|
+
filter(predicate) {
|
|
4996
|
+
const result = this.createEmpty();
|
|
4997
|
+
for (const value of this.data)
|
|
4998
|
+
if (predicate(value, this)) result.add(value);
|
|
4999
|
+
return result;
|
|
5000
|
+
}
|
|
5001
|
+
reduce(fn, init) {
|
|
5002
|
+
let iterator = this.values();
|
|
5003
|
+
let first = iterator.next();
|
|
5004
|
+
if (first.done) {
|
|
5005
|
+
if (arguments.length < 2) {
|
|
5006
|
+
throw new TypeError("Reduce of empty SetBase with no initial value!");
|
|
5007
|
+
}
|
|
5008
|
+
return init;
|
|
5009
|
+
}
|
|
5010
|
+
let acc;
|
|
5011
|
+
let start;
|
|
5012
|
+
if (arguments.length < 2) {
|
|
5013
|
+
acc = first.value;
|
|
5014
|
+
start = iterator.next();
|
|
5015
|
+
} else {
|
|
5016
|
+
acc = init;
|
|
5017
|
+
start = first;
|
|
5018
|
+
}
|
|
5019
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
5020
|
+
const value = current.value;
|
|
5021
|
+
acc = fn(acc, value);
|
|
5022
|
+
}
|
|
5023
|
+
return acc;
|
|
5024
|
+
}
|
|
5025
|
+
mapValues(fn) {
|
|
5026
|
+
let result = this.createEmpty();
|
|
5027
|
+
for (const value of this.data) {
|
|
5028
|
+
result.add(fn(value));
|
|
5029
|
+
}
|
|
5030
|
+
return result;
|
|
5031
|
+
}
|
|
5032
|
+
mapToArray(fn) {
|
|
5033
|
+
let result = [];
|
|
5034
|
+
for (const value of this.values()) {
|
|
5035
|
+
result.push(fn(value));
|
|
5036
|
+
}
|
|
5037
|
+
return result;
|
|
5038
|
+
}
|
|
5039
|
+
map(fn) {
|
|
5040
|
+
let result = this.createEmpty();
|
|
5041
|
+
for (const value of this.values()) {
|
|
5042
|
+
result.add(fn(value));
|
|
5043
|
+
}
|
|
5044
|
+
return result;
|
|
5045
|
+
}
|
|
5046
|
+
toSet() {
|
|
5047
|
+
return new Set(this.data);
|
|
5048
|
+
}
|
|
5049
|
+
toArray() {
|
|
5050
|
+
return [...this.values()];
|
|
5051
|
+
}
|
|
5052
|
+
toString() {
|
|
5053
|
+
return stringify(this.data);
|
|
5054
|
+
}
|
|
5055
|
+
};
|
|
5056
|
+
var Set1 = class _Set1 extends SetBase {
|
|
5057
|
+
constructor(entries) {
|
|
5058
|
+
super(entries);
|
|
5059
|
+
}
|
|
5060
|
+
createEmpty() {
|
|
5061
|
+
return new _Set1();
|
|
5062
|
+
}
|
|
5063
|
+
valueEquals(a, b) {
|
|
5064
|
+
return a === b;
|
|
5065
|
+
}
|
|
5066
|
+
};
|
|
5067
|
+
var DeepSet = class _DeepSet extends SetBase {
|
|
5068
|
+
constructor(entries) {
|
|
5069
|
+
super(entries);
|
|
5070
|
+
}
|
|
5071
|
+
createEmpty() {
|
|
5072
|
+
return new _DeepSet();
|
|
5073
|
+
}
|
|
5074
|
+
valueEquals(a, b) {
|
|
5075
|
+
return isDeepEqual2(a, b);
|
|
5076
|
+
}
|
|
5077
|
+
};
|
|
5078
|
+
|
|
5079
|
+
// src/deprecated/div-rect.ts
|
|
5080
|
+
var DivRect = class _DivRect {
|
|
5081
|
+
constructor(...args) {
|
|
5082
|
+
__publicField(this, "left");
|
|
5083
|
+
__publicField(this, "anchorX");
|
|
5084
|
+
__publicField(this, "right");
|
|
5085
|
+
__publicField(this, "top");
|
|
5086
|
+
__publicField(this, "anchorY");
|
|
5087
|
+
__publicField(this, "bottom");
|
|
5088
|
+
if (args.length === 6) {
|
|
5089
|
+
this.left = args[0];
|
|
5090
|
+
this.anchorX = args[1];
|
|
5091
|
+
this.right = args[2];
|
|
5092
|
+
this.top = args[3];
|
|
5093
|
+
this.anchorY = args[4];
|
|
5094
|
+
this.bottom = args[5];
|
|
5095
|
+
} else if (args.length === 4) {
|
|
5096
|
+
this.left = args[0];
|
|
5097
|
+
this.right = args[1];
|
|
5098
|
+
this.anchorX = (this.left + this.right) / 2;
|
|
5099
|
+
this.top = args[2];
|
|
5100
|
+
this.bottom = args[3];
|
|
5101
|
+
this.anchorY = (this.top + this.bottom) / 2;
|
|
5102
|
+
} else if (args.length === 0) {
|
|
5103
|
+
this.left = this.anchorX = this.right = 0;
|
|
5104
|
+
this.top = this.anchorY = this.bottom = 0;
|
|
5105
|
+
} else {
|
|
5106
|
+
throw new TypeError(`Invalid DivRect args: ${args}`);
|
|
5107
|
+
}
|
|
5108
|
+
}
|
|
5109
|
+
set(...args) {
|
|
5110
|
+
if (args.length === 6) {
|
|
5111
|
+
this.left = args[0];
|
|
5112
|
+
this.anchorX = args[1];
|
|
5113
|
+
this.right = args[2];
|
|
5114
|
+
this.top = args[3];
|
|
5115
|
+
this.anchorY = args[4];
|
|
5116
|
+
this.bottom = args[5];
|
|
5117
|
+
} else if (args.length === 4) {
|
|
5118
|
+
this.left = args[0];
|
|
5119
|
+
this.right = args[1];
|
|
5120
|
+
this.anchorX = (this.left + this.right) / 2;
|
|
5121
|
+
this.top = args[2];
|
|
5122
|
+
this.bottom = args[3];
|
|
5123
|
+
this.anchorY = (this.top + this.bottom) / 2;
|
|
5124
|
+
} else if (args.length === 0) {
|
|
5125
|
+
this.left = this.anchorX = this.right = 0;
|
|
5126
|
+
this.top = this.anchorY = this.bottom = 0;
|
|
5127
|
+
} else {
|
|
5128
|
+
throw new TypeError(`Invalid DivRect args: ${args}`);
|
|
5129
|
+
}
|
|
5130
|
+
return this;
|
|
5131
|
+
}
|
|
5132
|
+
/**
|
|
5133
|
+
* Create rect from basic left, top, width and height arguments.
|
|
5134
|
+
*
|
|
5135
|
+
* @param left - Left coordinate.
|
|
5136
|
+
* @param top - Top coordinate.
|
|
5137
|
+
* @param width - Width.
|
|
5138
|
+
* @param height - Height.
|
|
5139
|
+
* @returns - DivRect.
|
|
5140
|
+
*/
|
|
5141
|
+
static create(left, top, width, height) {
|
|
5142
|
+
return new _DivRect(left, left + width, top, top + height);
|
|
5143
|
+
}
|
|
5144
|
+
/**
|
|
5145
|
+
* Create rect from anchorX, anchorY, width, height arguments.
|
|
5146
|
+
*
|
|
5147
|
+
* @param centerX - Center x-coordinate.
|
|
5148
|
+
* @param centerY - Center y-coordinate.
|
|
5149
|
+
* @param width - Width.
|
|
5150
|
+
* @param height - Height.
|
|
5151
|
+
* @returns - DivRect.
|
|
5152
|
+
*/
|
|
5153
|
+
static createCentered(centerX, centerY, width, height) {
|
|
5154
|
+
return new _DivRect(
|
|
5155
|
+
centerX - width / 2,
|
|
5156
|
+
centerX,
|
|
5157
|
+
centerX + width / 2,
|
|
5158
|
+
centerY - height / 2,
|
|
5159
|
+
centerY,
|
|
5160
|
+
centerY + height / 2
|
|
5161
|
+
);
|
|
5162
|
+
}
|
|
5163
|
+
/**
|
|
5164
|
+
* Create rect from sections.
|
|
5165
|
+
*
|
|
5166
|
+
* @param leftw - Left section width.
|
|
5167
|
+
* @param rightw - Right section width.
|
|
5168
|
+
* @param toph - Top section height.
|
|
5169
|
+
* @param bottomh - Bottomsection height.
|
|
5170
|
+
* @returns - DivRect.
|
|
5171
|
+
*/
|
|
5172
|
+
static createSections(leftw, rightw, toph, bottomh) {
|
|
5173
|
+
return new _DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
|
|
5174
|
+
}
|
|
5175
|
+
/**
|
|
5176
|
+
* @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
|
|
5177
|
+
* @private
|
|
5178
|
+
* */
|
|
5179
|
+
get centerX() {
|
|
5180
|
+
return this.anchorX;
|
|
5181
|
+
}
|
|
5182
|
+
/**
|
|
5183
|
+
* @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
|
|
5184
|
+
* @private
|
|
5185
|
+
* */
|
|
5186
|
+
set centerX(x) {
|
|
5187
|
+
this.anchorX = x;
|
|
5188
|
+
}
|
|
5189
|
+
/**
|
|
5190
|
+
* @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
|
|
5191
|
+
* @private
|
|
5192
|
+
* */
|
|
5193
|
+
get centerY() {
|
|
5194
|
+
return this.anchorY;
|
|
5195
|
+
}
|
|
5196
|
+
/**
|
|
5197
|
+
* @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
|
|
5198
|
+
* @private
|
|
5199
|
+
* */
|
|
5200
|
+
set centerY(y) {
|
|
5201
|
+
this.anchorY = y;
|
|
5202
|
+
}
|
|
5203
|
+
/**
|
|
5204
|
+
* Width getter.
|
|
5205
|
+
*/
|
|
5206
|
+
get width() {
|
|
5207
|
+
return this.right - this.left;
|
|
5208
|
+
}
|
|
5209
|
+
/**
|
|
5210
|
+
* Height getter.
|
|
5211
|
+
*/
|
|
5212
|
+
get height() {
|
|
5213
|
+
return this.bottom - this.top;
|
|
5214
|
+
}
|
|
5215
|
+
/**
|
|
5216
|
+
* Left section width getter.
|
|
5217
|
+
*/
|
|
5218
|
+
get leftw() {
|
|
5219
|
+
return this.anchorX - this.left;
|
|
5220
|
+
}
|
|
5221
|
+
/**
|
|
5222
|
+
* Right section width getter.
|
|
5223
|
+
*/
|
|
5224
|
+
get rightw() {
|
|
5225
|
+
return this.right - this.anchorX;
|
|
5226
|
+
}
|
|
5227
|
+
/**
|
|
5228
|
+
* Top section height getter.
|
|
5229
|
+
*/
|
|
5230
|
+
get toph() {
|
|
5231
|
+
return this.anchorY - this.top;
|
|
5232
|
+
}
|
|
5233
|
+
/**
|
|
5234
|
+
* Bottom section height getter.
|
|
5235
|
+
*/
|
|
5236
|
+
get bottomh() {
|
|
5237
|
+
return this.bottom - this.anchorY;
|
|
5238
|
+
}
|
|
5239
|
+
/**
|
|
5240
|
+
* Does this Rect contain given (x, y)-point?
|
|
5241
|
+
*
|
|
5242
|
+
* @param x - X-coordinate.
|
|
5243
|
+
* @param y - Y-coordinate.
|
|
5244
|
+
* @returns - True/false.
|
|
5245
|
+
*/
|
|
5246
|
+
contains(x, y) {
|
|
5247
|
+
return x >= this.left && x <= this.right && y >= this.top && y <= this.bottom;
|
|
5248
|
+
}
|
|
5249
|
+
/**
|
|
5250
|
+
* Do a and b rects overlap?
|
|
5251
|
+
*
|
|
5252
|
+
* @param a - DivRect a.
|
|
5253
|
+
* @param b - DivRect b.
|
|
5254
|
+
* @returns - True/false.
|
|
5255
|
+
*/
|
|
5256
|
+
static overlap(a, b) {
|
|
5257
|
+
return a.right > b.left && a.left < b.right && a.bottom > b.top && a.top < b.bottom;
|
|
5258
|
+
}
|
|
5259
|
+
/**
|
|
5260
|
+
* Do horizontal measures of a and b rects overlap?
|
|
5261
|
+
*
|
|
5262
|
+
* @param a - DivRect a.
|
|
5263
|
+
* @param b - DivRect b.
|
|
5264
|
+
* @returns - True/false.
|
|
5265
|
+
*/
|
|
5266
|
+
static overlapX(a, b) {
|
|
5267
|
+
return a.right > b.left && a.left < b.right;
|
|
5268
|
+
}
|
|
5269
|
+
/**
|
|
5270
|
+
* Check if given rects are equal.
|
|
5271
|
+
* @param a - DivRect a.
|
|
5272
|
+
* @param b - DivRect b.
|
|
5273
|
+
* @returns - True/false.
|
|
5274
|
+
*/
|
|
5275
|
+
static equals(a, b) {
|
|
5276
|
+
if (a == null && b == null) {
|
|
5277
|
+
return true;
|
|
5278
|
+
} else if (a == null || b == null) {
|
|
5279
|
+
return false;
|
|
5280
|
+
} else {
|
|
5281
|
+
return a === b || a.left === b.left && a.anchorX === b.anchorX && a.right === b.right && a.top === b.top && a.anchorY === b.anchorY && a.bottom === b.bottom;
|
|
5282
|
+
}
|
|
5283
|
+
}
|
|
5284
|
+
/**
|
|
5285
|
+
* Check if this rect equals with another rect.
|
|
5286
|
+
* @param other - The other rect.
|
|
5287
|
+
* @returns - True/false.
|
|
5288
|
+
*/
|
|
5289
|
+
equals(other) {
|
|
5290
|
+
return _DivRect.equals(this, other);
|
|
5291
|
+
}
|
|
5292
|
+
/**
|
|
5293
|
+
* Check if edges of given rects are equal, ignoring anchorX and anchorY.
|
|
5294
|
+
*
|
|
5295
|
+
* @param a - DivRect a.
|
|
5296
|
+
* @param b - DivRect b.
|
|
5297
|
+
* @returns - True/false.
|
|
5298
|
+
*/
|
|
5299
|
+
static equalsEdges(a, b) {
|
|
5300
|
+
if (a == null && b == null) {
|
|
5301
|
+
return true;
|
|
5302
|
+
} else if (a == null || b == null) {
|
|
5303
|
+
return false;
|
|
5304
|
+
} else {
|
|
5305
|
+
return a === b || a.left === b.left && a.right === b.right && a.top === b.top && a.bottom === b.bottom;
|
|
5306
|
+
}
|
|
5307
|
+
}
|
|
5308
|
+
/**
|
|
5309
|
+
* Check if edges of this Rect equals with given Rect, ignoring anchorX and anchorY.
|
|
5310
|
+
*
|
|
5311
|
+
* @param other - The other DivRect.
|
|
5312
|
+
* @returns - True/false.
|
|
5313
|
+
*/
|
|
5314
|
+
equalsEdges(other) {
|
|
5315
|
+
return _DivRect.equalsEdges(this, other);
|
|
5316
|
+
}
|
|
5317
|
+
/**
|
|
5318
|
+
* @deprecated - Use {@link equalsEdges()} instead. Will be removed in v2.0.0.
|
|
5319
|
+
* @private
|
|
5320
|
+
*/
|
|
5321
|
+
static equalsFrame(a, b) {
|
|
5322
|
+
return _DivRect.equalsEdges(a, b);
|
|
5323
|
+
}
|
|
5324
|
+
/**
|
|
5325
|
+
* @deprecated - Use {@link clone()} instead. Will be removed in v2.0.0.
|
|
5326
|
+
* @private
|
|
5327
|
+
*/
|
|
5328
|
+
copy() {
|
|
5329
|
+
return new _DivRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
|
|
5330
|
+
}
|
|
5331
|
+
/**
|
|
5332
|
+
* Created duplicate of this Rect.
|
|
5333
|
+
* @returns - Duplicate.
|
|
5334
|
+
*/
|
|
5335
|
+
clone() {
|
|
5336
|
+
return new _DivRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
|
|
5337
|
+
}
|
|
5338
|
+
/**
|
|
5339
|
+
* Move this rect by (dx, dy). Modifies this Rect.
|
|
5340
|
+
*
|
|
5341
|
+
* @param dx - Offset amount in x-direction.
|
|
5342
|
+
* @param dy - Offset amount in y-direction.
|
|
5343
|
+
* @returns - This DivRect instance.
|
|
5344
|
+
*/
|
|
5345
|
+
offsetInPlace(dx, dy) {
|
|
5346
|
+
this.left += dx;
|
|
5347
|
+
this.anchorX += dx;
|
|
5348
|
+
this.right += dx;
|
|
5349
|
+
this.top += dy;
|
|
5350
|
+
this.anchorY += dy;
|
|
5351
|
+
this.bottom += dy;
|
|
5352
|
+
return this;
|
|
5353
|
+
}
|
|
5354
|
+
/**
|
|
5355
|
+
* Move this rect by (dx, dy). Immutable, returns modified copy.
|
|
5356
|
+
*
|
|
5357
|
+
* @param dx - Offset amount in x-direction.
|
|
5358
|
+
* @param dy - Offset amount in y-direction.
|
|
5359
|
+
* @returns - DivRect copy with applied offset.
|
|
5360
|
+
*/
|
|
5361
|
+
offsetCopy(dx, dy) {
|
|
5362
|
+
return this.clone().offsetInPlace(dx, dy);
|
|
5363
|
+
}
|
|
5364
|
+
/**
|
|
5365
|
+
* Expand this Rect by given Rect. Modifies this Rect.
|
|
5366
|
+
*
|
|
5367
|
+
* @param rect - DivRect to expand this instance with.
|
|
5368
|
+
* @returns - This DivRect instance.
|
|
5369
|
+
*/
|
|
5370
|
+
expandInPlace(rect) {
|
|
5371
|
+
this.left = Math.min(this.left, rect.left);
|
|
5372
|
+
this.right = Math.max(this.right, rect.right);
|
|
5373
|
+
this.top = Math.min(this.top, rect.top);
|
|
5374
|
+
this.bottom = Math.max(this.bottom, rect.bottom);
|
|
5375
|
+
return this;
|
|
5376
|
+
}
|
|
5377
|
+
/**
|
|
5378
|
+
* Expand this Rect by given Rect. Immutable, returns modified copy.
|
|
5379
|
+
*
|
|
5380
|
+
* @param rect - DivRect to expand this instance with.
|
|
5381
|
+
* @returns - Expanded copy of this DivRect.
|
|
5382
|
+
*/
|
|
5383
|
+
expandCopy(rect) {
|
|
5384
|
+
return this.clone().expandInPlace(rect);
|
|
5385
|
+
}
|
|
5386
|
+
/**
|
|
5387
|
+
* Clip this Rect by given Rect. Mmodifies this Rect.
|
|
5388
|
+
*
|
|
5389
|
+
* @param clipRect - DivRect to clip this instance with.
|
|
5390
|
+
* @returns - This DivRect instance.
|
|
5391
|
+
*/
|
|
5392
|
+
clipInPlace(clipRect) {
|
|
5393
|
+
this.left = Math.max(this.left, clipRect.left);
|
|
5394
|
+
this.right = Math.min(this.right, clipRect.right);
|
|
5395
|
+
this.anchorX = clamp(this.anchorX, this.left, this.right);
|
|
5396
|
+
this.top = Math.max(this.top, clipRect.top);
|
|
5397
|
+
this.bottom = Math.min(this.bottom, clipRect.bottom);
|
|
5398
|
+
this.anchorY = clamp(this.anchorY, this.top, this.bottom);
|
|
5399
|
+
return this;
|
|
5400
|
+
}
|
|
5401
|
+
/**
|
|
5402
|
+
* Clip this Rect by given Rect. Immutable, return modified copy.
|
|
5403
|
+
*
|
|
5404
|
+
* @param clipRect - DivRecto to clip this instance with.
|
|
5405
|
+
* @returns - Clipped DivRect copy.
|
|
5406
|
+
*/
|
|
5407
|
+
clipCopy(clipRect) {
|
|
5408
|
+
return this.clone().clipInPlace(clipRect);
|
|
5409
|
+
}
|
|
5410
|
+
/**
|
|
5411
|
+
* Scale Rect. Anchor pos is (anchorX, anchorY). Modifies this Rect.
|
|
5412
|
+
*
|
|
5413
|
+
* @param scaleX - Scale x-amount.
|
|
5414
|
+
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
5415
|
+
* @returns This DivRect instance.
|
|
5416
|
+
*/
|
|
5417
|
+
scaleInPlace(scaleX, scaleY = scaleX) {
|
|
5418
|
+
this.left = this.anchorX - this.leftw * scaleX;
|
|
5419
|
+
this.right = this.anchorX + this.rightw * scaleX;
|
|
5420
|
+
this.top = this.anchorY - this.toph * scaleY;
|
|
5421
|
+
this.bottom = this.anchorY + this.bottomh * scaleY;
|
|
5422
|
+
return this;
|
|
5423
|
+
}
|
|
5424
|
+
/**
|
|
5425
|
+
* Scale Rect. Anchor pos is (anchorX, anchorY). Immutable, returns modified copy.
|
|
5426
|
+
*
|
|
5427
|
+
* @param scaleX - Scale x-amount.
|
|
5428
|
+
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
5429
|
+
* @returns Scaled copy of this DivRect.
|
|
5430
|
+
*/
|
|
5431
|
+
scaleCopy(scaleX, scaleY = scaleX) {
|
|
5432
|
+
return this.clone().scaleInPlace(scaleX, scaleY);
|
|
5433
|
+
}
|
|
5434
|
+
/**
|
|
5435
|
+
* Get this DivRect instance.
|
|
5436
|
+
* @returns - This DivRect instance.
|
|
5437
|
+
*/
|
|
5438
|
+
getRect() {
|
|
5439
|
+
return this;
|
|
5440
|
+
}
|
|
5441
|
+
toRect() {
|
|
5442
|
+
return new Rect(this.left, this.right, this.width, this.height);
|
|
5443
|
+
}
|
|
5444
|
+
};
|
|
3749
5445
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3750
5446
|
0 && (module.exports = {
|
|
5447
|
+
AnchoredRect,
|
|
3751
5448
|
Assert,
|
|
5449
|
+
BaseContainer,
|
|
5450
|
+
BiMap,
|
|
3752
5451
|
Cookies,
|
|
3753
5452
|
DeepSet,
|
|
3754
5453
|
DefaultArray,
|
|
5454
|
+
DefaultEqualityFn,
|
|
3755
5455
|
Device,
|
|
3756
5456
|
DivRect,
|
|
3757
5457
|
Guard,
|
|
3758
5458
|
IndexArray,
|
|
3759
5459
|
LRUCache,
|
|
5460
|
+
LinkedList,
|
|
3760
5461
|
Map1,
|
|
3761
5462
|
Map2,
|
|
3762
5463
|
Map3,
|
|
3763
5464
|
MultiContainer,
|
|
5465
|
+
Rect,
|
|
3764
5466
|
Set1,
|
|
3765
5467
|
SetBase,
|
|
3766
5468
|
SignedIndexArray,
|
|
3767
5469
|
SmallIntCache,
|
|
3768
5470
|
Stack,
|
|
5471
|
+
TriMap,
|
|
5472
|
+
UniMap,
|
|
3769
5473
|
Utils,
|
|
5474
|
+
ValueSet,
|
|
3770
5475
|
Vec,
|
|
3771
5476
|
Vec2,
|
|
3772
5477
|
asMulti
|