@tspro/ts-utils-lib 1.12.0 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /* TsUtilsLib v1.12.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
1
+ /* TsUtilsLib v1.14.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __export = (target, all) => {
@@ -1262,10 +1262,234 @@ var SmallIntCache = class {
1262
1262
  }
1263
1263
  };
1264
1264
 
1265
+ // src/core/signed-index-array.ts
1266
+ var SignedIndexArray = class _SignedIndexArray {
1267
+ constructor(entries) {
1268
+ // for indexes >= 0
1269
+ __publicField(this, "posEl");
1270
+ __publicField(this, "hasPos");
1271
+ // for indexes < 0
1272
+ __publicField(this, "negEl");
1273
+ __publicField(this, "hasNeg");
1274
+ // number of elems
1275
+ __publicField(this, "elCount");
1276
+ if (entries instanceof _SignedIndexArray) {
1277
+ this.negEl = entries.negEl.slice();
1278
+ this.hasNeg = entries.hasNeg.slice();
1279
+ this.posEl = entries.posEl.slice();
1280
+ this.hasPos = entries.hasPos.slice();
1281
+ this.elCount = entries.elCount;
1282
+ } else {
1283
+ this.negEl = [];
1284
+ this.hasNeg = [];
1285
+ this.posEl = [];
1286
+ this.hasPos = [];
1287
+ this.elCount = 0;
1288
+ if (entries) {
1289
+ for (const [id, el] of entries) {
1290
+ this.set(id, el);
1291
+ }
1292
+ }
1293
+ }
1294
+ }
1295
+ static toNegIndex(id) {
1296
+ return -id - 1;
1297
+ }
1298
+ get size() {
1299
+ return this.elCount;
1300
+ }
1301
+ has(id) {
1302
+ if (!isInteger(id)) {
1303
+ return false;
1304
+ } else if (id >= 0) {
1305
+ return this.hasPos[id] === true;
1306
+ } else {
1307
+ return this.hasNeg[_SignedIndexArray.toNegIndex(id)] === true;
1308
+ }
1309
+ }
1310
+ set(id, el) {
1311
+ if (!isInteger(id)) {
1312
+ throw new Error("Index must be an integer");
1313
+ } else if (id >= 0) {
1314
+ if (this.hasPos[id] !== true) this.elCount++;
1315
+ this.posEl[id] = el;
1316
+ this.hasPos[id] = true;
1317
+ } else {
1318
+ if (this.hasNeg[_SignedIndexArray.toNegIndex(id)] !== true) this.elCount++;
1319
+ this.negEl[_SignedIndexArray.toNegIndex(id)] = el;
1320
+ this.hasNeg[_SignedIndexArray.toNegIndex(id)] = true;
1321
+ }
1322
+ }
1323
+ get(id) {
1324
+ if (!isInteger(id)) {
1325
+ throw new Error("Index must be an integer");
1326
+ } else if (id >= 0) {
1327
+ return this.hasPos[id] ? this.posEl[id] : void 0;
1328
+ } else {
1329
+ return this.hasNeg[_SignedIndexArray.toNegIndex(id)] ? this.negEl[_SignedIndexArray.toNegIndex(id)] : void 0;
1330
+ }
1331
+ }
1332
+ getOrDefault(id, defaultValue) {
1333
+ return this.get(id) ?? defaultValue;
1334
+ }
1335
+ getOrCreate(id, creatorOrValue) {
1336
+ if (!this.has(id)) {
1337
+ const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
1338
+ this.set(id, value);
1339
+ return value;
1340
+ }
1341
+ return this.get(id);
1342
+ }
1343
+ delete(id) {
1344
+ if (!isInteger(id)) return false;
1345
+ const isPos = id >= 0;
1346
+ const arr = isPos ? this.posEl : this.negEl;
1347
+ const has = isPos ? this.hasPos : this.hasNeg;
1348
+ const idx = isPos ? id : _SignedIndexArray.toNegIndex(id);
1349
+ if (!has[idx]) return false;
1350
+ arr[idx] = void 0;
1351
+ has[idx] = false;
1352
+ this.elCount--;
1353
+ return true;
1354
+ }
1355
+ clear() {
1356
+ this.negEl = [];
1357
+ this.hasNeg = [];
1358
+ this.posEl = [];
1359
+ this.hasPos = [];
1360
+ this.elCount = 0;
1361
+ }
1362
+ forEach(callbackfn, thisArg) {
1363
+ for (const [id, el] of this.entries()) {
1364
+ callbackfn.call(thisArg, el, id, this);
1365
+ }
1366
+ }
1367
+ indices() {
1368
+ function* gen(self) {
1369
+ for (let id = self.negEl.length - 1; id >= 0; id--) {
1370
+ if (self.hasNeg[id]) yield _SignedIndexArray.toNegIndex(id);
1371
+ }
1372
+ for (let id = 0; id < self.posEl.length; id++) {
1373
+ if (self.hasPos[id]) yield id;
1374
+ }
1375
+ }
1376
+ return gen(this);
1377
+ }
1378
+ indicesArray() {
1379
+ return [...this.indices()];
1380
+ }
1381
+ values() {
1382
+ function* gen(self) {
1383
+ for (let id = self.negEl.length - 1; id >= 0; id--) {
1384
+ if (self.hasNeg[id]) yield self.negEl[id];
1385
+ }
1386
+ for (let id = 0; id < self.posEl.length; id++) {
1387
+ if (self.hasPos[id]) yield self.posEl[id];
1388
+ }
1389
+ }
1390
+ return gen(this);
1391
+ }
1392
+ valuesArray() {
1393
+ return [...this.values()];
1394
+ }
1395
+ *entries() {
1396
+ for (let id = this.negEl.length - 1; id >= 0; id--) {
1397
+ if (this.hasNeg[id]) yield [_SignedIndexArray.toNegIndex(id), this.negEl[id]];
1398
+ }
1399
+ for (let id = 0; id < this.posEl.length; id++) {
1400
+ if (this.hasPos[id]) yield [id, this.posEl[id]];
1401
+ }
1402
+ }
1403
+ entriesArray() {
1404
+ return [...this.entries()];
1405
+ }
1406
+ *[Symbol.iterator]() {
1407
+ yield* this.entries();
1408
+ }
1409
+ clone() {
1410
+ return new _SignedIndexArray(this);
1411
+ }
1412
+ merge(other, conflictResolver) {
1413
+ for (const [id, value] of other.entries()) {
1414
+ if (this.has(id) && conflictResolver) {
1415
+ this.set(id, conflictResolver(this.get(id), value, id));
1416
+ } else {
1417
+ this.set(id, value);
1418
+ }
1419
+ }
1420
+ return this;
1421
+ }
1422
+ some(fn) {
1423
+ for (const [id, el] of this.entries()) {
1424
+ if (fn(el, id)) return true;
1425
+ }
1426
+ return false;
1427
+ }
1428
+ every(fn) {
1429
+ for (const [id, el] of this.entries()) {
1430
+ if (!fn(el, id)) return false;
1431
+ }
1432
+ return true;
1433
+ }
1434
+ filter(fn) {
1435
+ let result = new _SignedIndexArray();
1436
+ for (const [id, el] of this.entries()) {
1437
+ if (fn(el, id)) result.set(id, el);
1438
+ }
1439
+ return result;
1440
+ }
1441
+ reduce(fn, init) {
1442
+ let iterator = this.entries();
1443
+ let first = iterator.next();
1444
+ if (first.done) {
1445
+ if (arguments.length < 2) {
1446
+ throw new TypeError("Reduce of empty SignedIndexArray with no initial value!");
1447
+ }
1448
+ return init;
1449
+ }
1450
+ let acc;
1451
+ let start;
1452
+ if (arguments.length < 2) {
1453
+ acc = first.value[1];
1454
+ start = iterator.next();
1455
+ } else {
1456
+ acc = init;
1457
+ start = first;
1458
+ }
1459
+ for (let current = start; !current.done; current = iterator.next()) {
1460
+ const [id, el] = current.value;
1461
+ acc = fn(acc, el, id);
1462
+ }
1463
+ return acc;
1464
+ }
1465
+ mapToArray(fn) {
1466
+ let result = [];
1467
+ for (const [id, el] of this.entries()) {
1468
+ result.push(fn(el, id));
1469
+ }
1470
+ return result;
1471
+ }
1472
+ map(fn) {
1473
+ let result = new _SignedIndexArray();
1474
+ for (const [id, el] of this.entries()) {
1475
+ result.set(id, fn(el, id));
1476
+ }
1477
+ return result;
1478
+ }
1479
+ toString() {
1480
+ const entries = this.entriesArray().map(([id, el]) => `${id}: ${el}`).join(", ");
1481
+ return `SignedIndexArray[ ${entries} ]`;
1482
+ }
1483
+ };
1484
+
1265
1485
  // src/core/map.ts
1266
- var Map1 = class {
1267
- constructor() {
1268
- __publicField(this, "map1", /* @__PURE__ */ new Map());
1486
+ var Map1 = class _Map1 {
1487
+ constructor(entries) {
1488
+ __publicField(this, "map1");
1489
+ this.map1 = entries instanceof _Map1 ? new Map(entries.map1) : new Map(entries);
1490
+ }
1491
+ has(key1) {
1492
+ return this.map1.has(key1);
1269
1493
  }
1270
1494
  set(key1, value) {
1271
1495
  this.map1.set(key1, value);
@@ -1274,8 +1498,16 @@ var Map1 = class {
1274
1498
  get(key1) {
1275
1499
  return this.map1.get(key1);
1276
1500
  }
1277
- has(key1) {
1278
- return this.map1.has(key1);
1501
+ getOrDefault(key1, defaultValue) {
1502
+ return this.get(key1) ?? defaultValue;
1503
+ }
1504
+ getOrCreate(key1, creatorOrValue) {
1505
+ if (!this.has(key1)) {
1506
+ const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
1507
+ this.set(key1, value);
1508
+ return value;
1509
+ }
1510
+ return this.get(key1);
1279
1511
  }
1280
1512
  delete(key1) {
1281
1513
  return this.map1.delete(key1);
@@ -1292,20 +1524,101 @@ var Map1 = class {
1292
1524
  keys() {
1293
1525
  return this.map1.keys();
1294
1526
  }
1527
+ keysArray() {
1528
+ return [...this.keys()];
1529
+ }
1295
1530
  values() {
1296
1531
  return this.map1.values();
1297
1532
  }
1533
+ valuesArray() {
1534
+ return [...this.values()];
1535
+ }
1298
1536
  *entries() {
1299
1537
  for (const [key1, value] of this.map1)
1300
1538
  yield [key1, value];
1301
1539
  }
1540
+ entriesArray() {
1541
+ return [...this.entries()];
1542
+ }
1302
1543
  *[Symbol.iterator]() {
1303
1544
  yield* this.entries();
1304
1545
  }
1546
+ clone() {
1547
+ return new _Map1(this);
1548
+ }
1549
+ merge(other, conflictResolver) {
1550
+ for (const [key1, value] of other.entries()) {
1551
+ if (this.has(key1) && conflictResolver) {
1552
+ this.set(key1, conflictResolver(this.get(key1), value, key1));
1553
+ } else {
1554
+ this.set(key1, value);
1555
+ }
1556
+ }
1557
+ return this;
1558
+ }
1559
+ some(fn) {
1560
+ for (const [key1, value] of this.map1) {
1561
+ if (fn(value, key1)) return true;
1562
+ }
1563
+ return false;
1564
+ }
1565
+ every(fn) {
1566
+ for (const [key1, value] of this.map1) {
1567
+ if (!fn(value, key1)) return false;
1568
+ }
1569
+ return true;
1570
+ }
1571
+ filter(fn) {
1572
+ let result = new _Map1();
1573
+ for (const [key1, value] of this.map1) {
1574
+ if (fn(value, key1)) result.set(key1, value);
1575
+ }
1576
+ return result;
1577
+ }
1578
+ reduce(fn, init) {
1579
+ let acc = init;
1580
+ for (const [key1, value] of this.map1) {
1581
+ acc = fn(acc, value, key1);
1582
+ }
1583
+ return acc;
1584
+ }
1585
+ mapEntries(fn) {
1586
+ let result = [];
1587
+ for (const [key1, value] of this.map1) {
1588
+ result.push(fn(value, key1));
1589
+ }
1590
+ return result;
1591
+ }
1592
+ mapValues(fn) {
1593
+ let result = new _Map1();
1594
+ for (const [key1, value] of this.map1) {
1595
+ result.set(key1, fn(value, key1));
1596
+ }
1597
+ return result;
1598
+ }
1599
+ toMap() {
1600
+ return new Map(this.map1);
1601
+ }
1602
+ toString() {
1603
+ const entries = [...this.map1].map(([k, v]) => `${k} => ${v}`).join(", ");
1604
+ return `Map1(${this.map1.size}) { ${entries} }`;
1605
+ }
1305
1606
  };
1306
- var Map2 = class {
1307
- constructor() {
1607
+ var Map2 = class _Map2 {
1608
+ constructor(entries) {
1308
1609
  __publicField(this, "map1", /* @__PURE__ */ new Map());
1610
+ if (entries instanceof _Map2) {
1611
+ for (const [key1, inner] of entries.map1) {
1612
+ this.map1.set(key1, new Map(inner));
1613
+ }
1614
+ } else if (entries) {
1615
+ for (const [key1, key2, value] of entries) {
1616
+ this.set(key1, key2, value);
1617
+ }
1618
+ }
1619
+ }
1620
+ has(key1, key2) {
1621
+ return this.map1.get(key1)?.has(key2) ?? false;
1309
1622
  }
1310
1623
  set(key1, key2, value) {
1311
1624
  let map2 = this.map1.get(key1) ?? this.map1.set(key1, /* @__PURE__ */ new Map()).get(key1);
@@ -1315,8 +1628,16 @@ var Map2 = class {
1315
1628
  get(key1, key2) {
1316
1629
  return this.map1.get(key1)?.get(key2);
1317
1630
  }
1318
- has(key1, key2) {
1319
- return this.map1.get(key1)?.has(key2) ?? false;
1631
+ getOrDefault(key1, key2, defaultValue) {
1632
+ return this.get(key1, key2) ?? defaultValue;
1633
+ }
1634
+ getOrCreate(key1, key2, creatorOrValue) {
1635
+ if (!this.has(key1, key2)) {
1636
+ const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
1637
+ this.set(key1, key2, value);
1638
+ return value;
1639
+ }
1640
+ return this.get(key1, key2);
1320
1641
  }
1321
1642
  delete(key1, key2) {
1322
1643
  if (key2 === void 0) return this.map1.delete(key1);
@@ -1339,12 +1660,15 @@ var Map2 = class {
1339
1660
  }
1340
1661
  keys() {
1341
1662
  function* gen(map1) {
1342
- for (const [k1, map2] of map1)
1343
- for (const k2 of map2.keys())
1344
- yield [k1, k2];
1663
+ for (const [key1, map2] of map1)
1664
+ for (const key2 of map2.keys())
1665
+ yield [key1, key2];
1345
1666
  }
1346
1667
  return gen(this.map1);
1347
1668
  }
1669
+ keysArray() {
1670
+ return [...this.keys()];
1671
+ }
1348
1672
  values() {
1349
1673
  function* gen(map1) {
1350
1674
  for (const map2 of map1.values())
@@ -1353,18 +1677,122 @@ var Map2 = class {
1353
1677
  }
1354
1678
  return gen(this.map1);
1355
1679
  }
1680
+ valuesArray() {
1681
+ return [...this.values()];
1682
+ }
1356
1683
  *entries() {
1357
1684
  for (const [key1, map2] of this.map1)
1358
1685
  for (const [key2, value] of map2)
1359
1686
  yield [key1, key2, value];
1360
1687
  }
1688
+ entriesArray() {
1689
+ return [...this.entries()];
1690
+ }
1361
1691
  *[Symbol.iterator]() {
1362
1692
  yield* this.entries();
1363
1693
  }
1694
+ clone() {
1695
+ return new _Map2(this);
1696
+ }
1697
+ merge(other, conflictResolver) {
1698
+ for (const [key1, key2, value] of other.entries()) {
1699
+ if (this.has(key1, key2) && conflictResolver) {
1700
+ this.set(key1, key2, conflictResolver(this.get(key1, key2), value, key1, key2));
1701
+ } else {
1702
+ this.set(key1, key2, value);
1703
+ }
1704
+ }
1705
+ return this;
1706
+ }
1707
+ some(fn) {
1708
+ for (const [key1, map2] of this.map1) {
1709
+ for (const [key2, value] of map2) {
1710
+ if (fn(value, key1, key2)) return true;
1711
+ }
1712
+ }
1713
+ return false;
1714
+ }
1715
+ every(fn) {
1716
+ for (const [key1, map2] of this.map1) {
1717
+ for (const [key2, value] of map2) {
1718
+ if (!fn(value, key1, key2)) return false;
1719
+ }
1720
+ }
1721
+ return true;
1722
+ }
1723
+ filter(fn) {
1724
+ let result = new _Map2();
1725
+ for (const [key1, map2] of this.map1) {
1726
+ for (const [key2, value] of map2) {
1727
+ if (fn(value, key1, key2)) result.set(key1, key2, value);
1728
+ }
1729
+ }
1730
+ return result;
1731
+ }
1732
+ reduce(fn, init) {
1733
+ let acc = init;
1734
+ for (const [key1, map2] of this.map1) {
1735
+ for (const [key2, value] of map2) {
1736
+ acc = fn(acc, value, key1, key2);
1737
+ }
1738
+ }
1739
+ return acc;
1740
+ }
1741
+ mapEntries(fn) {
1742
+ let result = [];
1743
+ for (const [key1, map2] of this.map1) {
1744
+ for (const [key2, value] of map2) {
1745
+ result.push(fn(value, key1, key2));
1746
+ }
1747
+ }
1748
+ return result;
1749
+ }
1750
+ mapValues(fn) {
1751
+ let result = new _Map2();
1752
+ for (const [key1, map2] of this.map1) {
1753
+ for (const [key2, value] of map2) {
1754
+ result.set(key1, key2, fn(value, key1, key2));
1755
+ }
1756
+ }
1757
+ return result;
1758
+ }
1759
+ toMap() {
1760
+ let result = /* @__PURE__ */ new Map();
1761
+ for (const [key1, map2] of this.map1) {
1762
+ for (const [key2, value] of map2) {
1763
+ result.set([key1, key2], value);
1764
+ }
1765
+ }
1766
+ return result;
1767
+ }
1768
+ toString() {
1769
+ const entries = [];
1770
+ for (const [key1, map2] of this.map1) {
1771
+ const inner = [...map2].map(([key2, v]) => `${key2} => ${v}`).join(", ");
1772
+ entries.push(`${key1} => { ${inner} }`);
1773
+ }
1774
+ return `Map2(${this.size}) { ${entries.join(", ")} }`;
1775
+ }
1364
1776
  };
1365
- var Map3 = class {
1366
- constructor() {
1777
+ var Map3 = class _Map3 {
1778
+ constructor(entries) {
1367
1779
  __publicField(this, "map1", /* @__PURE__ */ new Map());
1780
+ if (entries instanceof _Map3) {
1781
+ for (const [key1, map2] of entries.map1) {
1782
+ const newMap2 = /* @__PURE__ */ new Map();
1783
+ for (const [key2, map3] of map2) {
1784
+ newMap2.set(key2, new Map(map3));
1785
+ }
1786
+ this.map1.set(key1, newMap2);
1787
+ }
1788
+ } else if (entries) {
1789
+ for (const [key1, key2, key3, value] of entries) {
1790
+ this.set(key1, key2, key3, value);
1791
+ }
1792
+ }
1793
+ }
1794
+ has(key1, key2, key3) {
1795
+ return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
1368
1796
  }
1369
1797
  set(key1, key2, key3, value) {
1370
1798
  let map2 = this.map1.get(key1);
@@ -1377,8 +1805,16 @@ var Map3 = class {
1377
1805
  get(key1, key2, key3) {
1378
1806
  return this.map1.get(key1)?.get(key2)?.get(key3);
1379
1807
  }
1380
- has(key1, key2, key3) {
1381
- return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
1808
+ getOrDefault(key1, key2, key3, defaultValue) {
1809
+ return this.get(key1, key2, key3) ?? defaultValue;
1810
+ }
1811
+ getOrCreate(key1, key2, key3, creatorOrValue) {
1812
+ if (!this.has(key1, key2, key3)) {
1813
+ const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
1814
+ this.set(key1, key2, key3, value);
1815
+ return value;
1816
+ }
1817
+ return this.get(key1, key2, key3);
1382
1818
  }
1383
1819
  delete(key1, key2, key3) {
1384
1820
  if (key3 === void 0) {
@@ -1410,13 +1846,16 @@ var Map3 = class {
1410
1846
  }
1411
1847
  keys() {
1412
1848
  function* gen(map1) {
1413
- for (const [k1, map2] of map1)
1414
- for (const [k2, map3] of map2)
1415
- for (const k3 of map3.keys())
1416
- yield [k1, k2, k3];
1849
+ for (const [key1, map2] of map1)
1850
+ for (const [key2, map3] of map2)
1851
+ for (const key3 of map3.keys())
1852
+ yield [key1, key2, key3];
1417
1853
  }
1418
1854
  return gen(this.map1);
1419
1855
  }
1856
+ keysArray() {
1857
+ return [...this.keys()];
1858
+ }
1420
1859
  values() {
1421
1860
  function* gen(map1) {
1422
1861
  for (const map2 of map1.values())
@@ -1426,15 +1865,119 @@ var Map3 = class {
1426
1865
  }
1427
1866
  return gen(this.map1);
1428
1867
  }
1868
+ valuesArray() {
1869
+ return [...this.values()];
1870
+ }
1429
1871
  *entries() {
1430
1872
  for (const [key1, map2] of this.map1)
1431
1873
  for (const [key2, map3] of map2)
1432
1874
  for (const [key3, value] of map3)
1433
1875
  yield [key1, key2, key3, value];
1434
1876
  }
1877
+ entriesArray() {
1878
+ return [...this.entries()];
1879
+ }
1435
1880
  *[Symbol.iterator]() {
1436
1881
  yield* this.entries();
1437
1882
  }
1883
+ clone() {
1884
+ return new _Map3(this);
1885
+ }
1886
+ merge(other, conflictResolver) {
1887
+ for (const [key1, key2, key3, value] of other.entries()) {
1888
+ if (this.has(key1, key2, key3) && conflictResolver) {
1889
+ this.set(key1, key2, key3, conflictResolver(this.get(key1, key2, key3), value, key1, key2, key3));
1890
+ } else {
1891
+ this.set(key1, key2, key3, value);
1892
+ }
1893
+ }
1894
+ return this;
1895
+ }
1896
+ some(fn) {
1897
+ for (const [key1, map2] of this.map1) {
1898
+ for (const [key2, map3] of map2) {
1899
+ for (const [key3, value] of map3) {
1900
+ if (fn(value, key1, key2, key3)) return true;
1901
+ }
1902
+ }
1903
+ }
1904
+ return false;
1905
+ }
1906
+ every(fn) {
1907
+ for (const [key1, map2] of this.map1) {
1908
+ for (const [key2, map3] of map2) {
1909
+ for (const [key3, value] of map3) {
1910
+ if (!fn(value, key1, key2, key3)) return false;
1911
+ }
1912
+ }
1913
+ }
1914
+ return true;
1915
+ }
1916
+ filter(fn) {
1917
+ let result = new _Map3();
1918
+ for (const [key1, map2] of this.map1) {
1919
+ for (const [key2, map3] of map2) {
1920
+ for (const [key3, value] of map3) {
1921
+ if (fn(value, key1, key2, key3)) result.set(key1, key2, key3, value);
1922
+ }
1923
+ }
1924
+ }
1925
+ return result;
1926
+ }
1927
+ reduce(fn, init) {
1928
+ let acc = init;
1929
+ for (const [key1, map2] of this.map1) {
1930
+ for (const [key2, map3] of map2) {
1931
+ for (const [key3, value] of map3) {
1932
+ acc = fn(acc, value, key1, key2, key3);
1933
+ }
1934
+ }
1935
+ }
1936
+ return acc;
1937
+ }
1938
+ mapEntries(fn) {
1939
+ let result = [];
1940
+ for (const [key1, map2] of this.map1) {
1941
+ for (const [key2, map3] of map2) {
1942
+ for (const [key3, value] of map3) {
1943
+ result.push(fn(value, key1, key2, key3));
1944
+ }
1945
+ }
1946
+ }
1947
+ return result;
1948
+ }
1949
+ mapValues(fn) {
1950
+ let result = new _Map3();
1951
+ for (const [key1, map2] of this.map1) {
1952
+ for (const [key2, map3] of map2) {
1953
+ for (const [key3, value] of map3) {
1954
+ result.set(key1, key2, key3, fn(value, key1, key2, key3));
1955
+ }
1956
+ }
1957
+ }
1958
+ return result;
1959
+ }
1960
+ toMap() {
1961
+ let result = /* @__PURE__ */ new Map();
1962
+ for (const [key1, map2] of this.map1) {
1963
+ for (const [key2, map3] of map2) {
1964
+ for (const [key3, value] of map3) {
1965
+ result.set([key1, key2, key3], value);
1966
+ }
1967
+ }
1968
+ }
1969
+ return result;
1970
+ }
1971
+ toString() {
1972
+ const entries = [];
1973
+ for (const [key1, map2] of this.map1) {
1974
+ for (const [key2, map3] of map2) {
1975
+ const inner = [...map3].map(([key3, v]) => `${key3} => ${v}`).join(", ");
1976
+ entries.push(`${key1} => ${key2} => { ${inner} }`);
1977
+ }
1978
+ }
1979
+ return `Map3(${this.size}) { ${entries.join(", ")} }`;
1980
+ }
1438
1981
  };
1439
1982
  export {
1440
1983
  Assert,
@@ -1444,6 +1987,7 @@ export {
1444
1987
  Map1,
1445
1988
  Map2,
1446
1989
  Map3,
1990
+ SignedIndexArray,
1447
1991
  SmallIntCache,
1448
1992
  Stack,
1449
1993
  utils_exports as Utils,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tspro/ts-utils-lib",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "author": "PahkaSoft",
5
5
  "license": "MIT",
6
6
  "private": false,