@tspro/ts-utils-lib 1.12.0 → 1.13.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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.13.0] - 2025-10-18
4
+ ### Added
5
+ - Added even more functionality to Map1, Map2 and Map3.
6
+
3
7
  ## [1.12.0] - 2025-10-15
4
8
  ### Added
5
9
  - Added more functionality to Map1, Map2 and Map3.
package/dist/index.d.mts CHANGED
@@ -449,40 +449,78 @@ declare class SmallIntCache<V> {
449
449
  declare class Map1<KEY1, VALUE> {
450
450
  private map1;
451
451
  constructor();
452
+ constructor(map1: Map1<KEY1, VALUE>);
453
+ constructor(entries: Iterable<[KEY1, VALUE]>);
454
+ has(key1: KEY1): boolean;
452
455
  set(key1: KEY1, value: VALUE): VALUE;
453
456
  get(key1: KEY1): VALUE | undefined;
454
- has(key1: KEY1): boolean;
457
+ getOrDefault(key1: KEY1, defaultValue: VALUE): VALUE;
458
+ getOrCreate(key1: KEY1, creator: () => VALUE): VALUE;
455
459
  delete(key1: KEY1): boolean;
456
460
  clear(): void;
457
461
  get size(): number;
458
462
  forEach(callbackfn: (value: VALUE, key1: KEY1, map1: Map1<KEY1, VALUE>) => void, thisArg?: any): void;
459
463
  keys(): IterableIterator<KEY1>;
464
+ keysArray(): KEY1[];
460
465
  values(): IterableIterator<VALUE>;
466
+ valuesArray(): VALUE[];
461
467
  entries(): IterableIterator<[KEY1, VALUE]>;
468
+ entriesArray(): [KEY1, VALUE][];
462
469
  [Symbol.iterator](): Generator<[KEY1, VALUE], void, any>;
470
+ clone(): Map1<KEY1, VALUE>;
471
+ merge(other: Map1<KEY1, VALUE>, conflictResolver?: (oldValue: VALUE, newValue: VALUE, key1: KEY1) => VALUE): this;
472
+ some(fn: (value: VALUE, key1: KEY1) => boolean): boolean;
473
+ every(fn: (value: VALUE, key1: KEY1) => boolean): boolean;
474
+ filter(fn: (value: VALUE, key1: KEY1) => boolean): Map1<KEY1, VALUE>;
475
+ reduce<R>(fn: (acc: R, value: VALUE, key1: KEY1) => R, init: R): R;
476
+ mapEntries<R>(fn: (value: VALUE, key1: KEY1) => R): R[];
477
+ mapValues<R = VALUE>(fn: (value: VALUE, key1: KEY1) => R): Map1<KEY1, R>;
478
+ toMap(): Map<KEY1, VALUE>;
479
+ toString(): string;
463
480
  }
464
481
  declare class Map2<KEY1, KEY2, VALUE> {
465
482
  private map1;
466
483
  constructor();
484
+ constructor(map2: Map2<KEY1, KEY2, VALUE>);
485
+ constructor(entries: Iterable<[KEY1, KEY2, VALUE]>);
486
+ has(key1: KEY1, key2: KEY2): boolean;
467
487
  set(key1: KEY1, key2: KEY2, value: VALUE): VALUE;
468
488
  get(key1: KEY1, key2: KEY2): VALUE | undefined;
469
- has(key1: KEY1, key2: KEY2): boolean;
489
+ getOrDefault(key1: KEY1, key2: KEY2, defaultValue: VALUE): VALUE;
490
+ getOrCreate(key1: KEY1, key2: KEY2, creator: () => VALUE): VALUE;
470
491
  delete(key1: KEY1): boolean;
471
492
  delete(key1: KEY1, key2: KEY2): boolean;
472
493
  clear(): void;
473
494
  get size(): number;
474
495
  forEach(callbackfn: (value: VALUE, key1: KEY1, key2: KEY2, map2: Map2<KEY1, KEY2, VALUE>) => void, thisArg?: any): void;
475
496
  keys(): IterableIterator<[KEY1, KEY2]>;
497
+ keysArray(): [KEY1, KEY2][];
476
498
  values(): IterableIterator<VALUE>;
499
+ valuesArray(): VALUE[];
477
500
  entries(): IterableIterator<[KEY1, KEY2, VALUE]>;
501
+ entriesArray(): [KEY1, KEY2, VALUE][];
478
502
  [Symbol.iterator](): Generator<[KEY1, KEY2, VALUE], void, any>;
503
+ clone(): Map2<KEY1, KEY2, VALUE>;
504
+ merge(other: Map2<KEY1, KEY2, VALUE>, conflictResolver?: (oldValue: VALUE, newValue: VALUE, key1: KEY1, key2: KEY2) => VALUE): this;
505
+ some(fn: (value: VALUE, key1: KEY1, key2: KEY2) => boolean): boolean;
506
+ every(fn: (value: VALUE, key1: KEY1, key2: KEY2) => boolean): boolean;
507
+ filter(fn: (value: VALUE, key1: KEY1, key2: KEY2) => boolean): Map2<KEY1, KEY2, VALUE>;
508
+ reduce<R>(fn: (acc: R, value: VALUE, key1: KEY1, key2: KEY2) => R, init: R): R;
509
+ mapEntries<R>(fn: (value: VALUE, key1: KEY1, key2: KEY2) => R): R[];
510
+ mapValues<R = VALUE>(fn: (value: VALUE, key1: KEY1, key2: KEY2) => R): Map2<KEY1, KEY2, R>;
511
+ toMap(): Map<[KEY1, KEY2], VALUE>;
512
+ toString(): string;
479
513
  }
480
514
  declare class Map3<KEY1, KEY2, KEY3, VALUE> {
481
515
  private map1;
482
516
  constructor();
517
+ constructor(entries: Iterable<[KEY1, KEY2, KEY3, VALUE]>);
518
+ constructor(map3: Map3<KEY1, KEY2, KEY3, VALUE>);
519
+ has(key1: KEY1, key2: KEY2, key3: KEY3): boolean;
483
520
  set(key1: KEY1, key2: KEY2, key3: KEY3, value: VALUE): VALUE;
484
521
  get(key1: KEY1, key2: KEY2, key3: KEY3): VALUE | undefined;
485
- has(key1: KEY1, key2: KEY2, key3: KEY3): boolean;
522
+ getOrDefault(key1: KEY1, key2: KEY2, key3: KEY3, defaultValue: VALUE): VALUE;
523
+ getOrCreate(key1: KEY1, key2: KEY2, key3: KEY3, creator: () => VALUE): VALUE;
486
524
  delete(key1: KEY1): boolean;
487
525
  delete(key1: KEY1, key2: KEY2): boolean;
488
526
  delete(key1: KEY1, key2: KEY2, key3: KEY3): boolean;
@@ -490,9 +528,22 @@ declare class Map3<KEY1, KEY2, KEY3, VALUE> {
490
528
  get size(): number;
491
529
  forEach(callbackfn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3, map2: Map3<KEY1, KEY2, KEY3, VALUE>) => void, thisArg?: any): void;
492
530
  keys(): IterableIterator<[KEY1, KEY2, KEY3]>;
531
+ keysArray(): [KEY1, KEY2, KEY3][];
493
532
  values(): IterableIterator<VALUE>;
533
+ valuesArray(): VALUE[];
494
534
  entries(): IterableIterator<[KEY1, KEY2, KEY3, VALUE]>;
535
+ entriesArray(): [KEY1, KEY2, KEY3, VALUE][];
495
536
  [Symbol.iterator](): Generator<[KEY1, KEY2, KEY3, VALUE], void, any>;
537
+ clone(): Map3<KEY1, KEY2, KEY3, VALUE>;
538
+ merge(other: Map3<KEY1, KEY2, KEY3, VALUE>, conflictResolver?: (oldValue: VALUE, newValue: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => VALUE): this;
539
+ some(fn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => boolean): boolean;
540
+ every(fn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => boolean): boolean;
541
+ filter(fn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => boolean): Map3<KEY1, KEY2, KEY3, VALUE>;
542
+ reduce<R>(fn: (acc: R, value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => R, init: R): R;
543
+ mapEntries<R>(fn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => R): R[];
544
+ mapValues<R = VALUE>(fn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => R): Map3<KEY1, KEY2, KEY3, R>;
545
+ toMap(): Map<[KEY1, KEY2, KEY3], VALUE>;
546
+ toString(): string;
496
547
  }
497
548
 
498
549
  export { Assert, Cookies, Device, LRUCache, Map1, Map2, Map3, SmallIntCache, Stack, index as Utils, Vec2 };
package/dist/index.d.ts CHANGED
@@ -449,40 +449,78 @@ declare class SmallIntCache<V> {
449
449
  declare class Map1<KEY1, VALUE> {
450
450
  private map1;
451
451
  constructor();
452
+ constructor(map1: Map1<KEY1, VALUE>);
453
+ constructor(entries: Iterable<[KEY1, VALUE]>);
454
+ has(key1: KEY1): boolean;
452
455
  set(key1: KEY1, value: VALUE): VALUE;
453
456
  get(key1: KEY1): VALUE | undefined;
454
- has(key1: KEY1): boolean;
457
+ getOrDefault(key1: KEY1, defaultValue: VALUE): VALUE;
458
+ getOrCreate(key1: KEY1, creator: () => VALUE): VALUE;
455
459
  delete(key1: KEY1): boolean;
456
460
  clear(): void;
457
461
  get size(): number;
458
462
  forEach(callbackfn: (value: VALUE, key1: KEY1, map1: Map1<KEY1, VALUE>) => void, thisArg?: any): void;
459
463
  keys(): IterableIterator<KEY1>;
464
+ keysArray(): KEY1[];
460
465
  values(): IterableIterator<VALUE>;
466
+ valuesArray(): VALUE[];
461
467
  entries(): IterableIterator<[KEY1, VALUE]>;
468
+ entriesArray(): [KEY1, VALUE][];
462
469
  [Symbol.iterator](): Generator<[KEY1, VALUE], void, any>;
470
+ clone(): Map1<KEY1, VALUE>;
471
+ merge(other: Map1<KEY1, VALUE>, conflictResolver?: (oldValue: VALUE, newValue: VALUE, key1: KEY1) => VALUE): this;
472
+ some(fn: (value: VALUE, key1: KEY1) => boolean): boolean;
473
+ every(fn: (value: VALUE, key1: KEY1) => boolean): boolean;
474
+ filter(fn: (value: VALUE, key1: KEY1) => boolean): Map1<KEY1, VALUE>;
475
+ reduce<R>(fn: (acc: R, value: VALUE, key1: KEY1) => R, init: R): R;
476
+ mapEntries<R>(fn: (value: VALUE, key1: KEY1) => R): R[];
477
+ mapValues<R = VALUE>(fn: (value: VALUE, key1: KEY1) => R): Map1<KEY1, R>;
478
+ toMap(): Map<KEY1, VALUE>;
479
+ toString(): string;
463
480
  }
464
481
  declare class Map2<KEY1, KEY2, VALUE> {
465
482
  private map1;
466
483
  constructor();
484
+ constructor(map2: Map2<KEY1, KEY2, VALUE>);
485
+ constructor(entries: Iterable<[KEY1, KEY2, VALUE]>);
486
+ has(key1: KEY1, key2: KEY2): boolean;
467
487
  set(key1: KEY1, key2: KEY2, value: VALUE): VALUE;
468
488
  get(key1: KEY1, key2: KEY2): VALUE | undefined;
469
- has(key1: KEY1, key2: KEY2): boolean;
489
+ getOrDefault(key1: KEY1, key2: KEY2, defaultValue: VALUE): VALUE;
490
+ getOrCreate(key1: KEY1, key2: KEY2, creator: () => VALUE): VALUE;
470
491
  delete(key1: KEY1): boolean;
471
492
  delete(key1: KEY1, key2: KEY2): boolean;
472
493
  clear(): void;
473
494
  get size(): number;
474
495
  forEach(callbackfn: (value: VALUE, key1: KEY1, key2: KEY2, map2: Map2<KEY1, KEY2, VALUE>) => void, thisArg?: any): void;
475
496
  keys(): IterableIterator<[KEY1, KEY2]>;
497
+ keysArray(): [KEY1, KEY2][];
476
498
  values(): IterableIterator<VALUE>;
499
+ valuesArray(): VALUE[];
477
500
  entries(): IterableIterator<[KEY1, KEY2, VALUE]>;
501
+ entriesArray(): [KEY1, KEY2, VALUE][];
478
502
  [Symbol.iterator](): Generator<[KEY1, KEY2, VALUE], void, any>;
503
+ clone(): Map2<KEY1, KEY2, VALUE>;
504
+ merge(other: Map2<KEY1, KEY2, VALUE>, conflictResolver?: (oldValue: VALUE, newValue: VALUE, key1: KEY1, key2: KEY2) => VALUE): this;
505
+ some(fn: (value: VALUE, key1: KEY1, key2: KEY2) => boolean): boolean;
506
+ every(fn: (value: VALUE, key1: KEY1, key2: KEY2) => boolean): boolean;
507
+ filter(fn: (value: VALUE, key1: KEY1, key2: KEY2) => boolean): Map2<KEY1, KEY2, VALUE>;
508
+ reduce<R>(fn: (acc: R, value: VALUE, key1: KEY1, key2: KEY2) => R, init: R): R;
509
+ mapEntries<R>(fn: (value: VALUE, key1: KEY1, key2: KEY2) => R): R[];
510
+ mapValues<R = VALUE>(fn: (value: VALUE, key1: KEY1, key2: KEY2) => R): Map2<KEY1, KEY2, R>;
511
+ toMap(): Map<[KEY1, KEY2], VALUE>;
512
+ toString(): string;
479
513
  }
480
514
  declare class Map3<KEY1, KEY2, KEY3, VALUE> {
481
515
  private map1;
482
516
  constructor();
517
+ constructor(entries: Iterable<[KEY1, KEY2, KEY3, VALUE]>);
518
+ constructor(map3: Map3<KEY1, KEY2, KEY3, VALUE>);
519
+ has(key1: KEY1, key2: KEY2, key3: KEY3): boolean;
483
520
  set(key1: KEY1, key2: KEY2, key3: KEY3, value: VALUE): VALUE;
484
521
  get(key1: KEY1, key2: KEY2, key3: KEY3): VALUE | undefined;
485
- has(key1: KEY1, key2: KEY2, key3: KEY3): boolean;
522
+ getOrDefault(key1: KEY1, key2: KEY2, key3: KEY3, defaultValue: VALUE): VALUE;
523
+ getOrCreate(key1: KEY1, key2: KEY2, key3: KEY3, creator: () => VALUE): VALUE;
486
524
  delete(key1: KEY1): boolean;
487
525
  delete(key1: KEY1, key2: KEY2): boolean;
488
526
  delete(key1: KEY1, key2: KEY2, key3: KEY3): boolean;
@@ -490,9 +528,22 @@ declare class Map3<KEY1, KEY2, KEY3, VALUE> {
490
528
  get size(): number;
491
529
  forEach(callbackfn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3, map2: Map3<KEY1, KEY2, KEY3, VALUE>) => void, thisArg?: any): void;
492
530
  keys(): IterableIterator<[KEY1, KEY2, KEY3]>;
531
+ keysArray(): [KEY1, KEY2, KEY3][];
493
532
  values(): IterableIterator<VALUE>;
533
+ valuesArray(): VALUE[];
494
534
  entries(): IterableIterator<[KEY1, KEY2, KEY3, VALUE]>;
535
+ entriesArray(): [KEY1, KEY2, KEY3, VALUE][];
495
536
  [Symbol.iterator](): Generator<[KEY1, KEY2, KEY3, VALUE], void, any>;
537
+ clone(): Map3<KEY1, KEY2, KEY3, VALUE>;
538
+ merge(other: Map3<KEY1, KEY2, KEY3, VALUE>, conflictResolver?: (oldValue: VALUE, newValue: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => VALUE): this;
539
+ some(fn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => boolean): boolean;
540
+ every(fn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => boolean): boolean;
541
+ filter(fn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => boolean): Map3<KEY1, KEY2, KEY3, VALUE>;
542
+ reduce<R>(fn: (acc: R, value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => R, init: R): R;
543
+ mapEntries<R>(fn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => R): R[];
544
+ mapValues<R = VALUE>(fn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => R): Map3<KEY1, KEY2, KEY3, R>;
545
+ toMap(): Map<[KEY1, KEY2, KEY3], VALUE>;
546
+ toString(): string;
496
547
  }
497
548
 
498
549
  export { Assert, Cookies, Device, LRUCache, Map1, Map2, Map3, SmallIntCache, Stack, index as Utils, Vec2 };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* TsUtilsLib v1.12.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
1
+ /* TsUtilsLib v1.13.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;
@@ -1293,9 +1293,13 @@ var SmallIntCache = class {
1293
1293
  };
1294
1294
 
1295
1295
  // src/core/map.ts
1296
- var Map1 = class {
1297
- constructor() {
1298
- __publicField(this, "map1", /* @__PURE__ */ new Map());
1296
+ var Map1 = class _Map1 {
1297
+ constructor(entries) {
1298
+ __publicField(this, "map1");
1299
+ this.map1 = entries instanceof _Map1 ? new Map(entries.map1) : new Map(entries);
1300
+ }
1301
+ has(key1) {
1302
+ return this.map1.has(key1);
1299
1303
  }
1300
1304
  set(key1, value) {
1301
1305
  this.map1.set(key1, value);
@@ -1304,8 +1308,15 @@ var Map1 = class {
1304
1308
  get(key1) {
1305
1309
  return this.map1.get(key1);
1306
1310
  }
1307
- has(key1) {
1308
- return this.map1.has(key1);
1311
+ getOrDefault(key1, defaultValue) {
1312
+ return this.get(key1) ?? defaultValue;
1313
+ }
1314
+ getOrCreate(key1, creator) {
1315
+ let value = this.get(key1);
1316
+ if (!value) {
1317
+ this.set(key1, value = creator());
1318
+ }
1319
+ return value;
1309
1320
  }
1310
1321
  delete(key1) {
1311
1322
  return this.map1.delete(key1);
@@ -1322,20 +1333,101 @@ var Map1 = class {
1322
1333
  keys() {
1323
1334
  return this.map1.keys();
1324
1335
  }
1336
+ keysArray() {
1337
+ return [...this.keys()];
1338
+ }
1325
1339
  values() {
1326
1340
  return this.map1.values();
1327
1341
  }
1342
+ valuesArray() {
1343
+ return [...this.values()];
1344
+ }
1328
1345
  *entries() {
1329
1346
  for (const [key1, value] of this.map1)
1330
1347
  yield [key1, value];
1331
1348
  }
1349
+ entriesArray() {
1350
+ return [...this.entries()];
1351
+ }
1332
1352
  *[Symbol.iterator]() {
1333
1353
  yield* this.entries();
1334
1354
  }
1355
+ clone() {
1356
+ return new _Map1(this);
1357
+ }
1358
+ merge(other, conflictResolver) {
1359
+ for (const [key1, value] of other.entries()) {
1360
+ if (this.has(key1) && conflictResolver) {
1361
+ this.set(key1, conflictResolver(this.get(key1), value, key1));
1362
+ } else {
1363
+ this.set(key1, value);
1364
+ }
1365
+ }
1366
+ return this;
1367
+ }
1368
+ some(fn) {
1369
+ for (const [key1, value] of this.map1) {
1370
+ if (fn(value, key1)) return true;
1371
+ }
1372
+ return false;
1373
+ }
1374
+ every(fn) {
1375
+ for (const [key1, value] of this.map1) {
1376
+ if (!fn(value, key1)) return false;
1377
+ }
1378
+ return true;
1379
+ }
1380
+ filter(fn) {
1381
+ let result = new _Map1();
1382
+ for (const [key1, value] of this.map1) {
1383
+ if (fn(value, key1)) result.set(key1, value);
1384
+ }
1385
+ return result;
1386
+ }
1387
+ reduce(fn, init) {
1388
+ let acc = init;
1389
+ for (const [key1, value] of this.map1) {
1390
+ acc = fn(acc, value, key1);
1391
+ }
1392
+ return acc;
1393
+ }
1394
+ mapEntries(fn) {
1395
+ let result = [];
1396
+ for (const [key1, value] of this.map1) {
1397
+ result.push(fn(value, key1));
1398
+ }
1399
+ return result;
1400
+ }
1401
+ mapValues(fn) {
1402
+ let result = new _Map1();
1403
+ for (const [key1, value] of this.map1) {
1404
+ result.set(key1, fn(value, key1));
1405
+ }
1406
+ return result;
1407
+ }
1408
+ toMap() {
1409
+ return new Map(this.map1);
1410
+ }
1411
+ toString() {
1412
+ const entries = [...this.map1].map(([k, v]) => `${k} => ${v}`).join(", ");
1413
+ return `Map1(${this.map1.size}) { ${entries} }`;
1414
+ }
1335
1415
  };
1336
- var Map2 = class {
1337
- constructor() {
1416
+ var Map2 = class _Map2 {
1417
+ constructor(entries) {
1338
1418
  __publicField(this, "map1", /* @__PURE__ */ new Map());
1419
+ if (entries instanceof _Map2) {
1420
+ for (const [key1, inner] of entries.map1) {
1421
+ this.map1.set(key1, new Map(inner));
1422
+ }
1423
+ } else if (entries) {
1424
+ for (const [key1, key2, value] of entries) {
1425
+ this.set(key1, key2, value);
1426
+ }
1427
+ }
1428
+ }
1429
+ has(key1, key2) {
1430
+ return this.map1.get(key1)?.has(key2) ?? false;
1339
1431
  }
1340
1432
  set(key1, key2, value) {
1341
1433
  let map2 = this.map1.get(key1) ?? this.map1.set(key1, /* @__PURE__ */ new Map()).get(key1);
@@ -1345,8 +1437,15 @@ var Map2 = class {
1345
1437
  get(key1, key2) {
1346
1438
  return this.map1.get(key1)?.get(key2);
1347
1439
  }
1348
- has(key1, key2) {
1349
- return this.map1.get(key1)?.has(key2) ?? false;
1440
+ getOrDefault(key1, key2, defaultValue) {
1441
+ return this.get(key1, key2) ?? defaultValue;
1442
+ }
1443
+ getOrCreate(key1, key2, creator) {
1444
+ let value = this.get(key1, key2);
1445
+ if (!value) {
1446
+ this.set(key1, key2, value = creator());
1447
+ }
1448
+ return value;
1350
1449
  }
1351
1450
  delete(key1, key2) {
1352
1451
  if (key2 === void 0) return this.map1.delete(key1);
@@ -1369,12 +1468,15 @@ var Map2 = class {
1369
1468
  }
1370
1469
  keys() {
1371
1470
  function* gen(map1) {
1372
- for (const [k1, map2] of map1)
1373
- for (const k2 of map2.keys())
1374
- yield [k1, k2];
1471
+ for (const [key1, map2] of map1)
1472
+ for (const key2 of map2.keys())
1473
+ yield [key1, key2];
1375
1474
  }
1376
1475
  return gen(this.map1);
1377
1476
  }
1477
+ keysArray() {
1478
+ return [...this.keys()];
1479
+ }
1378
1480
  values() {
1379
1481
  function* gen(map1) {
1380
1482
  for (const map2 of map1.values())
@@ -1383,18 +1485,122 @@ var Map2 = class {
1383
1485
  }
1384
1486
  return gen(this.map1);
1385
1487
  }
1488
+ valuesArray() {
1489
+ return [...this.values()];
1490
+ }
1386
1491
  *entries() {
1387
1492
  for (const [key1, map2] of this.map1)
1388
1493
  for (const [key2, value] of map2)
1389
1494
  yield [key1, key2, value];
1390
1495
  }
1496
+ entriesArray() {
1497
+ return [...this.entries()];
1498
+ }
1391
1499
  *[Symbol.iterator]() {
1392
1500
  yield* this.entries();
1393
1501
  }
1502
+ clone() {
1503
+ return new _Map2(this);
1504
+ }
1505
+ merge(other, conflictResolver) {
1506
+ for (const [key1, key2, value] of other.entries()) {
1507
+ if (this.has(key1, key2) && conflictResolver) {
1508
+ this.set(key1, key2, conflictResolver(this.get(key1, key2), value, key1, key2));
1509
+ } else {
1510
+ this.set(key1, key2, value);
1511
+ }
1512
+ }
1513
+ return this;
1514
+ }
1515
+ some(fn) {
1516
+ for (const [key1, map2] of this.map1) {
1517
+ for (const [key2, value] of map2) {
1518
+ if (fn(value, key1, key2)) return true;
1519
+ }
1520
+ }
1521
+ return false;
1522
+ }
1523
+ every(fn) {
1524
+ for (const [key1, map2] of this.map1) {
1525
+ for (const [key2, value] of map2) {
1526
+ if (!fn(value, key1, key2)) return false;
1527
+ }
1528
+ }
1529
+ return true;
1530
+ }
1531
+ filter(fn) {
1532
+ let result = new _Map2();
1533
+ for (const [key1, map2] of this.map1) {
1534
+ for (const [key2, value] of map2) {
1535
+ if (fn(value, key1, key2)) result.set(key1, key2, value);
1536
+ }
1537
+ }
1538
+ return result;
1539
+ }
1540
+ reduce(fn, init) {
1541
+ let acc = init;
1542
+ for (const [key1, map2] of this.map1) {
1543
+ for (const [key2, value] of map2) {
1544
+ acc = fn(acc, value, key1, key2);
1545
+ }
1546
+ }
1547
+ return acc;
1548
+ }
1549
+ mapEntries(fn) {
1550
+ let result = [];
1551
+ for (const [key1, map2] of this.map1) {
1552
+ for (const [key2, value] of map2) {
1553
+ result.push(fn(value, key1, key2));
1554
+ }
1555
+ }
1556
+ return result;
1557
+ }
1558
+ mapValues(fn) {
1559
+ let result = new _Map2();
1560
+ for (const [key1, map2] of this.map1) {
1561
+ for (const [key2, value] of map2) {
1562
+ result.set(key1, key2, fn(value, key1, key2));
1563
+ }
1564
+ }
1565
+ return result;
1566
+ }
1567
+ toMap() {
1568
+ let result = /* @__PURE__ */ new Map();
1569
+ for (const [key1, map2] of this.map1) {
1570
+ for (const [key2, value] of map2) {
1571
+ result.set([key1, key2], value);
1572
+ }
1573
+ }
1574
+ return result;
1575
+ }
1576
+ toString() {
1577
+ const entries = [];
1578
+ for (const [key1, map2] of this.map1) {
1579
+ const inner = [...map2].map(([key2, v]) => `${key2} => ${v}`).join(", ");
1580
+ entries.push(`${key1} => { ${inner} }`);
1581
+ }
1582
+ return `Map2(${this.size}) { ${entries.join(", ")} }`;
1583
+ }
1394
1584
  };
1395
- var Map3 = class {
1396
- constructor() {
1585
+ var Map3 = class _Map3 {
1586
+ constructor(entries) {
1397
1587
  __publicField(this, "map1", /* @__PURE__ */ new Map());
1588
+ if (entries instanceof _Map3) {
1589
+ for (const [key1, map2] of entries.map1) {
1590
+ const newMap2 = /* @__PURE__ */ new Map();
1591
+ for (const [key2, map3] of map2) {
1592
+ newMap2.set(key2, new Map(map3));
1593
+ }
1594
+ this.map1.set(key1, newMap2);
1595
+ }
1596
+ } else if (entries) {
1597
+ for (const [key1, key2, key3, value] of entries) {
1598
+ this.set(key1, key2, key3, value);
1599
+ }
1600
+ }
1601
+ }
1602
+ has(key1, key2, key3) {
1603
+ return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
1398
1604
  }
1399
1605
  set(key1, key2, key3, value) {
1400
1606
  let map2 = this.map1.get(key1);
@@ -1407,8 +1613,15 @@ var Map3 = class {
1407
1613
  get(key1, key2, key3) {
1408
1614
  return this.map1.get(key1)?.get(key2)?.get(key3);
1409
1615
  }
1410
- has(key1, key2, key3) {
1411
- return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
1616
+ getOrDefault(key1, key2, key3, defaultValue) {
1617
+ return this.get(key1, key2, key3) ?? defaultValue;
1618
+ }
1619
+ getOrCreate(key1, key2, key3, creator) {
1620
+ let value = this.get(key1, key2, key3);
1621
+ if (!value) {
1622
+ this.set(key1, key2, key3, value = creator());
1623
+ }
1624
+ return value;
1412
1625
  }
1413
1626
  delete(key1, key2, key3) {
1414
1627
  if (key3 === void 0) {
@@ -1440,13 +1653,16 @@ var Map3 = class {
1440
1653
  }
1441
1654
  keys() {
1442
1655
  function* gen(map1) {
1443
- for (const [k1, map2] of map1)
1444
- for (const [k2, map3] of map2)
1445
- for (const k3 of map3.keys())
1446
- yield [k1, k2, k3];
1656
+ for (const [key1, map2] of map1)
1657
+ for (const [key2, map3] of map2)
1658
+ for (const key3 of map3.keys())
1659
+ yield [key1, key2, key3];
1447
1660
  }
1448
1661
  return gen(this.map1);
1449
1662
  }
1663
+ keysArray() {
1664
+ return [...this.keys()];
1665
+ }
1450
1666
  values() {
1451
1667
  function* gen(map1) {
1452
1668
  for (const map2 of map1.values())
@@ -1456,15 +1672,119 @@ var Map3 = class {
1456
1672
  }
1457
1673
  return gen(this.map1);
1458
1674
  }
1675
+ valuesArray() {
1676
+ return [...this.values()];
1677
+ }
1459
1678
  *entries() {
1460
1679
  for (const [key1, map2] of this.map1)
1461
1680
  for (const [key2, map3] of map2)
1462
1681
  for (const [key3, value] of map3)
1463
1682
  yield [key1, key2, key3, value];
1464
1683
  }
1684
+ entriesArray() {
1685
+ return [...this.entries()];
1686
+ }
1465
1687
  *[Symbol.iterator]() {
1466
1688
  yield* this.entries();
1467
1689
  }
1690
+ clone() {
1691
+ return new _Map3(this);
1692
+ }
1693
+ merge(other, conflictResolver) {
1694
+ for (const [key1, key2, key3, value] of other.entries()) {
1695
+ if (this.has(key1, key2, key3) && conflictResolver) {
1696
+ this.set(key1, key2, key3, conflictResolver(this.get(key1, key2, key3), value, key1, key2, key3));
1697
+ } else {
1698
+ this.set(key1, key2, key3, value);
1699
+ }
1700
+ }
1701
+ return this;
1702
+ }
1703
+ some(fn) {
1704
+ for (const [key1, map2] of this.map1) {
1705
+ for (const [key2, map3] of map2) {
1706
+ for (const [key3, value] of map3) {
1707
+ if (fn(value, key1, key2, key3)) return true;
1708
+ }
1709
+ }
1710
+ }
1711
+ return false;
1712
+ }
1713
+ every(fn) {
1714
+ for (const [key1, map2] of this.map1) {
1715
+ for (const [key2, map3] of map2) {
1716
+ for (const [key3, value] of map3) {
1717
+ if (!fn(value, key1, key2, key3)) return false;
1718
+ }
1719
+ }
1720
+ }
1721
+ return true;
1722
+ }
1723
+ filter(fn) {
1724
+ let result = new _Map3();
1725
+ for (const [key1, map2] of this.map1) {
1726
+ for (const [key2, map3] of map2) {
1727
+ for (const [key3, value] of map3) {
1728
+ if (fn(value, key1, key2, key3)) result.set(key1, key2, key3, value);
1729
+ }
1730
+ }
1731
+ }
1732
+ return result;
1733
+ }
1734
+ reduce(fn, init) {
1735
+ let acc = init;
1736
+ for (const [key1, map2] of this.map1) {
1737
+ for (const [key2, map3] of map2) {
1738
+ for (const [key3, value] of map3) {
1739
+ acc = fn(acc, value, key1, key2, key3);
1740
+ }
1741
+ }
1742
+ }
1743
+ return acc;
1744
+ }
1745
+ mapEntries(fn) {
1746
+ let result = [];
1747
+ for (const [key1, map2] of this.map1) {
1748
+ for (const [key2, map3] of map2) {
1749
+ for (const [key3, value] of map3) {
1750
+ result.push(fn(value, key1, key2, key3));
1751
+ }
1752
+ }
1753
+ }
1754
+ return result;
1755
+ }
1756
+ mapValues(fn) {
1757
+ let result = new _Map3();
1758
+ for (const [key1, map2] of this.map1) {
1759
+ for (const [key2, map3] of map2) {
1760
+ for (const [key3, value] of map3) {
1761
+ result.set(key1, key2, key3, fn(value, key1, key2, key3));
1762
+ }
1763
+ }
1764
+ }
1765
+ return result;
1766
+ }
1767
+ toMap() {
1768
+ let result = /* @__PURE__ */ new Map();
1769
+ for (const [key1, map2] of this.map1) {
1770
+ for (const [key2, map3] of map2) {
1771
+ for (const [key3, value] of map3) {
1772
+ result.set([key1, key2, key3], value);
1773
+ }
1774
+ }
1775
+ }
1776
+ return result;
1777
+ }
1778
+ toString() {
1779
+ const entries = [];
1780
+ for (const [key1, map2] of this.map1) {
1781
+ for (const [key2, map3] of map2) {
1782
+ const inner = [...map3].map(([key3, v]) => `${key3} => ${v}`).join(", ");
1783
+ entries.push(`${key1} => ${key2} => { ${inner} }`);
1784
+ }
1785
+ }
1786
+ return `Map3(${this.size}) { ${entries.join(", ")} }`;
1787
+ }
1468
1788
  };
1469
1789
  // Annotate the CommonJS export names for ESM import in node:
1470
1790
  0 && (module.exports = {
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.13.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) => {
@@ -1263,9 +1263,13 @@ var SmallIntCache = class {
1263
1263
  };
1264
1264
 
1265
1265
  // src/core/map.ts
1266
- var Map1 = class {
1267
- constructor() {
1268
- __publicField(this, "map1", /* @__PURE__ */ new Map());
1266
+ var Map1 = class _Map1 {
1267
+ constructor(entries) {
1268
+ __publicField(this, "map1");
1269
+ this.map1 = entries instanceof _Map1 ? new Map(entries.map1) : new Map(entries);
1270
+ }
1271
+ has(key1) {
1272
+ return this.map1.has(key1);
1269
1273
  }
1270
1274
  set(key1, value) {
1271
1275
  this.map1.set(key1, value);
@@ -1274,8 +1278,15 @@ var Map1 = class {
1274
1278
  get(key1) {
1275
1279
  return this.map1.get(key1);
1276
1280
  }
1277
- has(key1) {
1278
- return this.map1.has(key1);
1281
+ getOrDefault(key1, defaultValue) {
1282
+ return this.get(key1) ?? defaultValue;
1283
+ }
1284
+ getOrCreate(key1, creator) {
1285
+ let value = this.get(key1);
1286
+ if (!value) {
1287
+ this.set(key1, value = creator());
1288
+ }
1289
+ return value;
1279
1290
  }
1280
1291
  delete(key1) {
1281
1292
  return this.map1.delete(key1);
@@ -1292,20 +1303,101 @@ var Map1 = class {
1292
1303
  keys() {
1293
1304
  return this.map1.keys();
1294
1305
  }
1306
+ keysArray() {
1307
+ return [...this.keys()];
1308
+ }
1295
1309
  values() {
1296
1310
  return this.map1.values();
1297
1311
  }
1312
+ valuesArray() {
1313
+ return [...this.values()];
1314
+ }
1298
1315
  *entries() {
1299
1316
  for (const [key1, value] of this.map1)
1300
1317
  yield [key1, value];
1301
1318
  }
1319
+ entriesArray() {
1320
+ return [...this.entries()];
1321
+ }
1302
1322
  *[Symbol.iterator]() {
1303
1323
  yield* this.entries();
1304
1324
  }
1325
+ clone() {
1326
+ return new _Map1(this);
1327
+ }
1328
+ merge(other, conflictResolver) {
1329
+ for (const [key1, value] of other.entries()) {
1330
+ if (this.has(key1) && conflictResolver) {
1331
+ this.set(key1, conflictResolver(this.get(key1), value, key1));
1332
+ } else {
1333
+ this.set(key1, value);
1334
+ }
1335
+ }
1336
+ return this;
1337
+ }
1338
+ some(fn) {
1339
+ for (const [key1, value] of this.map1) {
1340
+ if (fn(value, key1)) return true;
1341
+ }
1342
+ return false;
1343
+ }
1344
+ every(fn) {
1345
+ for (const [key1, value] of this.map1) {
1346
+ if (!fn(value, key1)) return false;
1347
+ }
1348
+ return true;
1349
+ }
1350
+ filter(fn) {
1351
+ let result = new _Map1();
1352
+ for (const [key1, value] of this.map1) {
1353
+ if (fn(value, key1)) result.set(key1, value);
1354
+ }
1355
+ return result;
1356
+ }
1357
+ reduce(fn, init) {
1358
+ let acc = init;
1359
+ for (const [key1, value] of this.map1) {
1360
+ acc = fn(acc, value, key1);
1361
+ }
1362
+ return acc;
1363
+ }
1364
+ mapEntries(fn) {
1365
+ let result = [];
1366
+ for (const [key1, value] of this.map1) {
1367
+ result.push(fn(value, key1));
1368
+ }
1369
+ return result;
1370
+ }
1371
+ mapValues(fn) {
1372
+ let result = new _Map1();
1373
+ for (const [key1, value] of this.map1) {
1374
+ result.set(key1, fn(value, key1));
1375
+ }
1376
+ return result;
1377
+ }
1378
+ toMap() {
1379
+ return new Map(this.map1);
1380
+ }
1381
+ toString() {
1382
+ const entries = [...this.map1].map(([k, v]) => `${k} => ${v}`).join(", ");
1383
+ return `Map1(${this.map1.size}) { ${entries} }`;
1384
+ }
1305
1385
  };
1306
- var Map2 = class {
1307
- constructor() {
1386
+ var Map2 = class _Map2 {
1387
+ constructor(entries) {
1308
1388
  __publicField(this, "map1", /* @__PURE__ */ new Map());
1389
+ if (entries instanceof _Map2) {
1390
+ for (const [key1, inner] of entries.map1) {
1391
+ this.map1.set(key1, new Map(inner));
1392
+ }
1393
+ } else if (entries) {
1394
+ for (const [key1, key2, value] of entries) {
1395
+ this.set(key1, key2, value);
1396
+ }
1397
+ }
1398
+ }
1399
+ has(key1, key2) {
1400
+ return this.map1.get(key1)?.has(key2) ?? false;
1309
1401
  }
1310
1402
  set(key1, key2, value) {
1311
1403
  let map2 = this.map1.get(key1) ?? this.map1.set(key1, /* @__PURE__ */ new Map()).get(key1);
@@ -1315,8 +1407,15 @@ var Map2 = class {
1315
1407
  get(key1, key2) {
1316
1408
  return this.map1.get(key1)?.get(key2);
1317
1409
  }
1318
- has(key1, key2) {
1319
- return this.map1.get(key1)?.has(key2) ?? false;
1410
+ getOrDefault(key1, key2, defaultValue) {
1411
+ return this.get(key1, key2) ?? defaultValue;
1412
+ }
1413
+ getOrCreate(key1, key2, creator) {
1414
+ let value = this.get(key1, key2);
1415
+ if (!value) {
1416
+ this.set(key1, key2, value = creator());
1417
+ }
1418
+ return value;
1320
1419
  }
1321
1420
  delete(key1, key2) {
1322
1421
  if (key2 === void 0) return this.map1.delete(key1);
@@ -1339,12 +1438,15 @@ var Map2 = class {
1339
1438
  }
1340
1439
  keys() {
1341
1440
  function* gen(map1) {
1342
- for (const [k1, map2] of map1)
1343
- for (const k2 of map2.keys())
1344
- yield [k1, k2];
1441
+ for (const [key1, map2] of map1)
1442
+ for (const key2 of map2.keys())
1443
+ yield [key1, key2];
1345
1444
  }
1346
1445
  return gen(this.map1);
1347
1446
  }
1447
+ keysArray() {
1448
+ return [...this.keys()];
1449
+ }
1348
1450
  values() {
1349
1451
  function* gen(map1) {
1350
1452
  for (const map2 of map1.values())
@@ -1353,18 +1455,122 @@ var Map2 = class {
1353
1455
  }
1354
1456
  return gen(this.map1);
1355
1457
  }
1458
+ valuesArray() {
1459
+ return [...this.values()];
1460
+ }
1356
1461
  *entries() {
1357
1462
  for (const [key1, map2] of this.map1)
1358
1463
  for (const [key2, value] of map2)
1359
1464
  yield [key1, key2, value];
1360
1465
  }
1466
+ entriesArray() {
1467
+ return [...this.entries()];
1468
+ }
1361
1469
  *[Symbol.iterator]() {
1362
1470
  yield* this.entries();
1363
1471
  }
1472
+ clone() {
1473
+ return new _Map2(this);
1474
+ }
1475
+ merge(other, conflictResolver) {
1476
+ for (const [key1, key2, value] of other.entries()) {
1477
+ if (this.has(key1, key2) && conflictResolver) {
1478
+ this.set(key1, key2, conflictResolver(this.get(key1, key2), value, key1, key2));
1479
+ } else {
1480
+ this.set(key1, key2, value);
1481
+ }
1482
+ }
1483
+ return this;
1484
+ }
1485
+ some(fn) {
1486
+ for (const [key1, map2] of this.map1) {
1487
+ for (const [key2, value] of map2) {
1488
+ if (fn(value, key1, key2)) return true;
1489
+ }
1490
+ }
1491
+ return false;
1492
+ }
1493
+ every(fn) {
1494
+ for (const [key1, map2] of this.map1) {
1495
+ for (const [key2, value] of map2) {
1496
+ if (!fn(value, key1, key2)) return false;
1497
+ }
1498
+ }
1499
+ return true;
1500
+ }
1501
+ filter(fn) {
1502
+ let result = new _Map2();
1503
+ for (const [key1, map2] of this.map1) {
1504
+ for (const [key2, value] of map2) {
1505
+ if (fn(value, key1, key2)) result.set(key1, key2, value);
1506
+ }
1507
+ }
1508
+ return result;
1509
+ }
1510
+ reduce(fn, init) {
1511
+ let acc = init;
1512
+ for (const [key1, map2] of this.map1) {
1513
+ for (const [key2, value] of map2) {
1514
+ acc = fn(acc, value, key1, key2);
1515
+ }
1516
+ }
1517
+ return acc;
1518
+ }
1519
+ mapEntries(fn) {
1520
+ let result = [];
1521
+ for (const [key1, map2] of this.map1) {
1522
+ for (const [key2, value] of map2) {
1523
+ result.push(fn(value, key1, key2));
1524
+ }
1525
+ }
1526
+ return result;
1527
+ }
1528
+ mapValues(fn) {
1529
+ let result = new _Map2();
1530
+ for (const [key1, map2] of this.map1) {
1531
+ for (const [key2, value] of map2) {
1532
+ result.set(key1, key2, fn(value, key1, key2));
1533
+ }
1534
+ }
1535
+ return result;
1536
+ }
1537
+ toMap() {
1538
+ let result = /* @__PURE__ */ new Map();
1539
+ for (const [key1, map2] of this.map1) {
1540
+ for (const [key2, value] of map2) {
1541
+ result.set([key1, key2], value);
1542
+ }
1543
+ }
1544
+ return result;
1545
+ }
1546
+ toString() {
1547
+ const entries = [];
1548
+ for (const [key1, map2] of this.map1) {
1549
+ const inner = [...map2].map(([key2, v]) => `${key2} => ${v}`).join(", ");
1550
+ entries.push(`${key1} => { ${inner} }`);
1551
+ }
1552
+ return `Map2(${this.size}) { ${entries.join(", ")} }`;
1553
+ }
1364
1554
  };
1365
- var Map3 = class {
1366
- constructor() {
1555
+ var Map3 = class _Map3 {
1556
+ constructor(entries) {
1367
1557
  __publicField(this, "map1", /* @__PURE__ */ new Map());
1558
+ if (entries instanceof _Map3) {
1559
+ for (const [key1, map2] of entries.map1) {
1560
+ const newMap2 = /* @__PURE__ */ new Map();
1561
+ for (const [key2, map3] of map2) {
1562
+ newMap2.set(key2, new Map(map3));
1563
+ }
1564
+ this.map1.set(key1, newMap2);
1565
+ }
1566
+ } else if (entries) {
1567
+ for (const [key1, key2, key3, value] of entries) {
1568
+ this.set(key1, key2, key3, value);
1569
+ }
1570
+ }
1571
+ }
1572
+ has(key1, key2, key3) {
1573
+ return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
1368
1574
  }
1369
1575
  set(key1, key2, key3, value) {
1370
1576
  let map2 = this.map1.get(key1);
@@ -1377,8 +1583,15 @@ var Map3 = class {
1377
1583
  get(key1, key2, key3) {
1378
1584
  return this.map1.get(key1)?.get(key2)?.get(key3);
1379
1585
  }
1380
- has(key1, key2, key3) {
1381
- return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
1586
+ getOrDefault(key1, key2, key3, defaultValue) {
1587
+ return this.get(key1, key2, key3) ?? defaultValue;
1588
+ }
1589
+ getOrCreate(key1, key2, key3, creator) {
1590
+ let value = this.get(key1, key2, key3);
1591
+ if (!value) {
1592
+ this.set(key1, key2, key3, value = creator());
1593
+ }
1594
+ return value;
1382
1595
  }
1383
1596
  delete(key1, key2, key3) {
1384
1597
  if (key3 === void 0) {
@@ -1410,13 +1623,16 @@ var Map3 = class {
1410
1623
  }
1411
1624
  keys() {
1412
1625
  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];
1626
+ for (const [key1, map2] of map1)
1627
+ for (const [key2, map3] of map2)
1628
+ for (const key3 of map3.keys())
1629
+ yield [key1, key2, key3];
1417
1630
  }
1418
1631
  return gen(this.map1);
1419
1632
  }
1633
+ keysArray() {
1634
+ return [...this.keys()];
1635
+ }
1420
1636
  values() {
1421
1637
  function* gen(map1) {
1422
1638
  for (const map2 of map1.values())
@@ -1426,15 +1642,119 @@ var Map3 = class {
1426
1642
  }
1427
1643
  return gen(this.map1);
1428
1644
  }
1645
+ valuesArray() {
1646
+ return [...this.values()];
1647
+ }
1429
1648
  *entries() {
1430
1649
  for (const [key1, map2] of this.map1)
1431
1650
  for (const [key2, map3] of map2)
1432
1651
  for (const [key3, value] of map3)
1433
1652
  yield [key1, key2, key3, value];
1434
1653
  }
1654
+ entriesArray() {
1655
+ return [...this.entries()];
1656
+ }
1435
1657
  *[Symbol.iterator]() {
1436
1658
  yield* this.entries();
1437
1659
  }
1660
+ clone() {
1661
+ return new _Map3(this);
1662
+ }
1663
+ merge(other, conflictResolver) {
1664
+ for (const [key1, key2, key3, value] of other.entries()) {
1665
+ if (this.has(key1, key2, key3) && conflictResolver) {
1666
+ this.set(key1, key2, key3, conflictResolver(this.get(key1, key2, key3), value, key1, key2, key3));
1667
+ } else {
1668
+ this.set(key1, key2, key3, value);
1669
+ }
1670
+ }
1671
+ return this;
1672
+ }
1673
+ some(fn) {
1674
+ for (const [key1, map2] of this.map1) {
1675
+ for (const [key2, map3] of map2) {
1676
+ for (const [key3, value] of map3) {
1677
+ if (fn(value, key1, key2, key3)) return true;
1678
+ }
1679
+ }
1680
+ }
1681
+ return false;
1682
+ }
1683
+ every(fn) {
1684
+ for (const [key1, map2] of this.map1) {
1685
+ for (const [key2, map3] of map2) {
1686
+ for (const [key3, value] of map3) {
1687
+ if (!fn(value, key1, key2, key3)) return false;
1688
+ }
1689
+ }
1690
+ }
1691
+ return true;
1692
+ }
1693
+ filter(fn) {
1694
+ let result = new _Map3();
1695
+ for (const [key1, map2] of this.map1) {
1696
+ for (const [key2, map3] of map2) {
1697
+ for (const [key3, value] of map3) {
1698
+ if (fn(value, key1, key2, key3)) result.set(key1, key2, key3, value);
1699
+ }
1700
+ }
1701
+ }
1702
+ return result;
1703
+ }
1704
+ reduce(fn, init) {
1705
+ let acc = init;
1706
+ for (const [key1, map2] of this.map1) {
1707
+ for (const [key2, map3] of map2) {
1708
+ for (const [key3, value] of map3) {
1709
+ acc = fn(acc, value, key1, key2, key3);
1710
+ }
1711
+ }
1712
+ }
1713
+ return acc;
1714
+ }
1715
+ mapEntries(fn) {
1716
+ let result = [];
1717
+ for (const [key1, map2] of this.map1) {
1718
+ for (const [key2, map3] of map2) {
1719
+ for (const [key3, value] of map3) {
1720
+ result.push(fn(value, key1, key2, key3));
1721
+ }
1722
+ }
1723
+ }
1724
+ return result;
1725
+ }
1726
+ mapValues(fn) {
1727
+ let result = new _Map3();
1728
+ for (const [key1, map2] of this.map1) {
1729
+ for (const [key2, map3] of map2) {
1730
+ for (const [key3, value] of map3) {
1731
+ result.set(key1, key2, key3, fn(value, key1, key2, key3));
1732
+ }
1733
+ }
1734
+ }
1735
+ return result;
1736
+ }
1737
+ toMap() {
1738
+ let result = /* @__PURE__ */ new Map();
1739
+ for (const [key1, map2] of this.map1) {
1740
+ for (const [key2, map3] of map2) {
1741
+ for (const [key3, value] of map3) {
1742
+ result.set([key1, key2, key3], value);
1743
+ }
1744
+ }
1745
+ }
1746
+ return result;
1747
+ }
1748
+ toString() {
1749
+ const entries = [];
1750
+ for (const [key1, map2] of this.map1) {
1751
+ for (const [key2, map3] of map2) {
1752
+ const inner = [...map3].map(([key3, v]) => `${key3} => ${v}`).join(", ");
1753
+ entries.push(`${key1} => ${key2} => { ${inner} }`);
1754
+ }
1755
+ }
1756
+ return `Map3(${this.size}) { ${entries.join(", ")} }`;
1757
+ }
1438
1758
  };
1439
1759
  export {
1440
1760
  Assert,
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.13.0",
4
4
  "author": "PahkaSoft",
5
5
  "license": "MIT",
6
6
  "private": false,