@tspro/ts-utils-lib 1.11.0 → 1.12.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.12.0] - 2025-10-15
4
+ ### Added
5
+ - Added more functionality to Map1, Map2 and Map3.
6
+
3
7
  ## [1.11.0] - 2025-10-15
4
8
  ### Added
5
9
  - Forgot to build 1.10.0, now added Map1, Map2 and Map3.
package/dist/index.d.mts CHANGED
@@ -453,6 +453,13 @@ declare class Map1<KEY1, VALUE> {
453
453
  get(key1: KEY1): VALUE | undefined;
454
454
  has(key1: KEY1): boolean;
455
455
  delete(key1: KEY1): boolean;
456
+ clear(): void;
457
+ get size(): number;
458
+ forEach(callbackfn: (value: VALUE, key1: KEY1, map1: Map1<KEY1, VALUE>) => void, thisArg?: any): void;
459
+ keys(): IterableIterator<KEY1>;
460
+ values(): IterableIterator<VALUE>;
461
+ entries(): IterableIterator<[KEY1, VALUE]>;
462
+ [Symbol.iterator](): Generator<[KEY1, VALUE], void, any>;
456
463
  }
457
464
  declare class Map2<KEY1, KEY2, VALUE> {
458
465
  private map1;
@@ -460,7 +467,15 @@ declare class Map2<KEY1, KEY2, VALUE> {
460
467
  set(key1: KEY1, key2: KEY2, value: VALUE): VALUE;
461
468
  get(key1: KEY1, key2: KEY2): VALUE | undefined;
462
469
  has(key1: KEY1, key2: KEY2): boolean;
470
+ delete(key1: KEY1): boolean;
463
471
  delete(key1: KEY1, key2: KEY2): boolean;
472
+ clear(): void;
473
+ get size(): number;
474
+ forEach(callbackfn: (value: VALUE, key1: KEY1, key2: KEY2, map2: Map2<KEY1, KEY2, VALUE>) => void, thisArg?: any): void;
475
+ keys(): IterableIterator<[KEY1, KEY2]>;
476
+ values(): IterableIterator<VALUE>;
477
+ entries(): IterableIterator<[KEY1, KEY2, VALUE]>;
478
+ [Symbol.iterator](): Generator<[KEY1, KEY2, VALUE], void, any>;
464
479
  }
465
480
  declare class Map3<KEY1, KEY2, KEY3, VALUE> {
466
481
  private map1;
@@ -468,7 +483,16 @@ declare class Map3<KEY1, KEY2, KEY3, VALUE> {
468
483
  set(key1: KEY1, key2: KEY2, key3: KEY3, value: VALUE): VALUE;
469
484
  get(key1: KEY1, key2: KEY2, key3: KEY3): VALUE | undefined;
470
485
  has(key1: KEY1, key2: KEY2, key3: KEY3): boolean;
486
+ delete(key1: KEY1): boolean;
487
+ delete(key1: KEY1, key2: KEY2): boolean;
471
488
  delete(key1: KEY1, key2: KEY2, key3: KEY3): boolean;
489
+ clear(): void;
490
+ get size(): number;
491
+ forEach(callbackfn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3, map2: Map3<KEY1, KEY2, KEY3, VALUE>) => void, thisArg?: any): void;
492
+ keys(): IterableIterator<[KEY1, KEY2, KEY3]>;
493
+ values(): IterableIterator<VALUE>;
494
+ entries(): IterableIterator<[KEY1, KEY2, KEY3, VALUE]>;
495
+ [Symbol.iterator](): Generator<[KEY1, KEY2, KEY3, VALUE], void, any>;
472
496
  }
473
497
 
474
498
  export { Assert, Cookies, Device, LRUCache, Map1, Map2, Map3, SmallIntCache, Stack, index as Utils, Vec2 };
package/dist/index.d.ts CHANGED
@@ -453,6 +453,13 @@ declare class Map1<KEY1, VALUE> {
453
453
  get(key1: KEY1): VALUE | undefined;
454
454
  has(key1: KEY1): boolean;
455
455
  delete(key1: KEY1): boolean;
456
+ clear(): void;
457
+ get size(): number;
458
+ forEach(callbackfn: (value: VALUE, key1: KEY1, map1: Map1<KEY1, VALUE>) => void, thisArg?: any): void;
459
+ keys(): IterableIterator<KEY1>;
460
+ values(): IterableIterator<VALUE>;
461
+ entries(): IterableIterator<[KEY1, VALUE]>;
462
+ [Symbol.iterator](): Generator<[KEY1, VALUE], void, any>;
456
463
  }
457
464
  declare class Map2<KEY1, KEY2, VALUE> {
458
465
  private map1;
@@ -460,7 +467,15 @@ declare class Map2<KEY1, KEY2, VALUE> {
460
467
  set(key1: KEY1, key2: KEY2, value: VALUE): VALUE;
461
468
  get(key1: KEY1, key2: KEY2): VALUE | undefined;
462
469
  has(key1: KEY1, key2: KEY2): boolean;
470
+ delete(key1: KEY1): boolean;
463
471
  delete(key1: KEY1, key2: KEY2): boolean;
472
+ clear(): void;
473
+ get size(): number;
474
+ forEach(callbackfn: (value: VALUE, key1: KEY1, key2: KEY2, map2: Map2<KEY1, KEY2, VALUE>) => void, thisArg?: any): void;
475
+ keys(): IterableIterator<[KEY1, KEY2]>;
476
+ values(): IterableIterator<VALUE>;
477
+ entries(): IterableIterator<[KEY1, KEY2, VALUE]>;
478
+ [Symbol.iterator](): Generator<[KEY1, KEY2, VALUE], void, any>;
464
479
  }
465
480
  declare class Map3<KEY1, KEY2, KEY3, VALUE> {
466
481
  private map1;
@@ -468,7 +483,16 @@ declare class Map3<KEY1, KEY2, KEY3, VALUE> {
468
483
  set(key1: KEY1, key2: KEY2, key3: KEY3, value: VALUE): VALUE;
469
484
  get(key1: KEY1, key2: KEY2, key3: KEY3): VALUE | undefined;
470
485
  has(key1: KEY1, key2: KEY2, key3: KEY3): boolean;
486
+ delete(key1: KEY1): boolean;
487
+ delete(key1: KEY1, key2: KEY2): boolean;
471
488
  delete(key1: KEY1, key2: KEY2, key3: KEY3): boolean;
489
+ clear(): void;
490
+ get size(): number;
491
+ forEach(callbackfn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3, map2: Map3<KEY1, KEY2, KEY3, VALUE>) => void, thisArg?: any): void;
492
+ keys(): IterableIterator<[KEY1, KEY2, KEY3]>;
493
+ values(): IterableIterator<VALUE>;
494
+ entries(): IterableIterator<[KEY1, KEY2, KEY3, VALUE]>;
495
+ [Symbol.iterator](): Generator<[KEY1, KEY2, KEY3, VALUE], void, any>;
472
496
  }
473
497
 
474
498
  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.11.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
1
+ /* TsUtilsLib v1.12.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;
@@ -1310,40 +1310,87 @@ var Map1 = class {
1310
1310
  delete(key1) {
1311
1311
  return this.map1.delete(key1);
1312
1312
  }
1313
+ clear() {
1314
+ this.map1.clear();
1315
+ }
1316
+ get size() {
1317
+ return this.map1.size;
1318
+ }
1319
+ forEach(callbackfn, thisArg) {
1320
+ this.map1.forEach((value, key1) => callbackfn.call(thisArg, value, key1, this));
1321
+ }
1322
+ keys() {
1323
+ return this.map1.keys();
1324
+ }
1325
+ values() {
1326
+ return this.map1.values();
1327
+ }
1328
+ *entries() {
1329
+ for (const [key1, value] of this.map1)
1330
+ yield [key1, value];
1331
+ }
1332
+ *[Symbol.iterator]() {
1333
+ yield* this.entries();
1334
+ }
1313
1335
  };
1314
1336
  var Map2 = class {
1315
1337
  constructor() {
1316
1338
  __publicField(this, "map1", /* @__PURE__ */ new Map());
1317
1339
  }
1318
1340
  set(key1, key2, value) {
1319
- let map2 = this.map1.get(key1);
1320
- if (!map2) {
1321
- this.map1.set(key1, map2 = /* @__PURE__ */ new Map());
1322
- }
1341
+ let map2 = this.map1.get(key1) ?? this.map1.set(key1, /* @__PURE__ */ new Map()).get(key1);
1323
1342
  map2.set(key2, value);
1324
1343
  return value;
1325
1344
  }
1326
1345
  get(key1, key2) {
1327
- let map2 = this.map1.get(key1);
1328
- if (!map2) {
1329
- return void 0;
1330
- }
1331
- return map2.get(key2);
1346
+ return this.map1.get(key1)?.get(key2);
1332
1347
  }
1333
1348
  has(key1, key2) {
1334
- let map2 = this.map1.get(key1);
1335
- if (!map2) {
1336
- return false;
1337
- }
1338
- return map2.has(key2);
1349
+ return this.map1.get(key1)?.has(key2) ?? false;
1339
1350
  }
1340
1351
  delete(key1, key2) {
1341
- let map2 = this.map1.get(key1);
1342
- if (!map2) {
1343
- return false;
1344
- }
1352
+ if (key2 === void 0) return this.map1.delete(key1);
1353
+ const map2 = this.map1.get(key1);
1354
+ if (!map2) return false;
1345
1355
  return map2.delete(key2);
1346
1356
  }
1357
+ clear() {
1358
+ this.map1.clear();
1359
+ }
1360
+ get size() {
1361
+ let count = 0;
1362
+ for (const map2 of this.map1.values()) {
1363
+ count += map2.size;
1364
+ }
1365
+ return count;
1366
+ }
1367
+ forEach(callbackfn, thisArg) {
1368
+ this.map1.forEach((map2, key1) => map2.forEach((value, key2) => callbackfn.call(thisArg, value, key1, key2, this)));
1369
+ }
1370
+ keys() {
1371
+ function* gen(map1) {
1372
+ for (const [k1, map2] of map1)
1373
+ for (const k2 of map2.keys())
1374
+ yield [k1, k2];
1375
+ }
1376
+ return gen(this.map1);
1377
+ }
1378
+ values() {
1379
+ function* gen(map1) {
1380
+ for (const map2 of map1.values())
1381
+ for (const value of map2.values())
1382
+ yield value;
1383
+ }
1384
+ return gen(this.map1);
1385
+ }
1386
+ *entries() {
1387
+ for (const [key1, map2] of this.map1)
1388
+ for (const [key2, value] of map2)
1389
+ yield [key1, key2, value];
1390
+ }
1391
+ *[Symbol.iterator]() {
1392
+ yield* this.entries();
1393
+ }
1347
1394
  };
1348
1395
  var Map3 = class {
1349
1396
  constructor() {
@@ -1351,48 +1398,72 @@ var Map3 = class {
1351
1398
  }
1352
1399
  set(key1, key2, key3, value) {
1353
1400
  let map2 = this.map1.get(key1);
1354
- if (!map2) {
1355
- this.map1.set(key1, map2 = /* @__PURE__ */ new Map());
1356
- }
1401
+ if (!map2) this.map1.set(key1, map2 = /* @__PURE__ */ new Map());
1357
1402
  let map3 = map2.get(key2);
1358
- if (!map3) {
1359
- map2.set(key2, map3 = /* @__PURE__ */ new Map());
1360
- }
1403
+ if (!map3) map2.set(key2, map3 = /* @__PURE__ */ new Map());
1361
1404
  map3.set(key3, value);
1362
1405
  return value;
1363
1406
  }
1364
1407
  get(key1, key2, key3) {
1365
- let map2 = this.map1.get(key1);
1366
- if (!map2) {
1367
- return void 0;
1368
- }
1369
- let map3 = map2.get(key2);
1370
- if (!map3) {
1371
- return void 0;
1372
- }
1373
- return map3.get(key3);
1408
+ return this.map1.get(key1)?.get(key2)?.get(key3);
1374
1409
  }
1375
1410
  has(key1, key2, key3) {
1376
- let map2 = this.map1.get(key1);
1377
- if (!map2) {
1378
- return false;
1411
+ return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
1412
+ }
1413
+ delete(key1, key2, key3) {
1414
+ if (key3 === void 0) {
1415
+ if (key2 === void 0) return this.map1.delete(key1);
1416
+ const map2 = this.map1.get(key1);
1417
+ if (!map2) return false;
1418
+ return map2.delete(key2);
1419
+ } else {
1420
+ if (key2 === void 0) return this.map1.delete(key1);
1421
+ const map3 = this.map1.get(key1)?.get(key2);
1422
+ if (!map3) return false;
1423
+ return map3.delete(key3);
1379
1424
  }
1380
- let map3 = map2.get(key2);
1381
- if (!map3) {
1382
- return false;
1425
+ }
1426
+ clear() {
1427
+ this.map1.clear();
1428
+ }
1429
+ get size() {
1430
+ let count = 0;
1431
+ for (const map2 of this.map1.values()) {
1432
+ for (const map3 of map2.values()) {
1433
+ count += map3.size;
1434
+ }
1383
1435
  }
1384
- return map3.has(key3);
1436
+ return count;
1385
1437
  }
1386
- delete(key1, key2, key3) {
1387
- let map2 = this.map1.get(key1);
1388
- if (!map2) {
1389
- return false;
1438
+ forEach(callbackfn, thisArg) {
1439
+ this.map1.forEach((map2, key1) => map2.forEach((map3, key2) => map3.forEach((value, key3) => callbackfn.call(thisArg, value, key1, key2, key3, this))));
1440
+ }
1441
+ keys() {
1442
+ 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];
1390
1447
  }
1391
- let map3 = map2.get(key2);
1392
- if (!map3) {
1393
- return false;
1448
+ return gen(this.map1);
1449
+ }
1450
+ values() {
1451
+ function* gen(map1) {
1452
+ for (const map2 of map1.values())
1453
+ for (const map3 of map2.values())
1454
+ for (const value of map3.values())
1455
+ yield value;
1394
1456
  }
1395
- return map3.delete(key3);
1457
+ return gen(this.map1);
1458
+ }
1459
+ *entries() {
1460
+ for (const [key1, map2] of this.map1)
1461
+ for (const [key2, map3] of map2)
1462
+ for (const [key3, value] of map3)
1463
+ yield [key1, key2, key3, value];
1464
+ }
1465
+ *[Symbol.iterator]() {
1466
+ yield* this.entries();
1396
1467
  }
1397
1468
  };
1398
1469
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /* TsUtilsLib v1.11.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
1
+ /* TsUtilsLib v1.12.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) => {
@@ -1280,40 +1280,87 @@ var Map1 = class {
1280
1280
  delete(key1) {
1281
1281
  return this.map1.delete(key1);
1282
1282
  }
1283
+ clear() {
1284
+ this.map1.clear();
1285
+ }
1286
+ get size() {
1287
+ return this.map1.size;
1288
+ }
1289
+ forEach(callbackfn, thisArg) {
1290
+ this.map1.forEach((value, key1) => callbackfn.call(thisArg, value, key1, this));
1291
+ }
1292
+ keys() {
1293
+ return this.map1.keys();
1294
+ }
1295
+ values() {
1296
+ return this.map1.values();
1297
+ }
1298
+ *entries() {
1299
+ for (const [key1, value] of this.map1)
1300
+ yield [key1, value];
1301
+ }
1302
+ *[Symbol.iterator]() {
1303
+ yield* this.entries();
1304
+ }
1283
1305
  };
1284
1306
  var Map2 = class {
1285
1307
  constructor() {
1286
1308
  __publicField(this, "map1", /* @__PURE__ */ new Map());
1287
1309
  }
1288
1310
  set(key1, key2, value) {
1289
- let map2 = this.map1.get(key1);
1290
- if (!map2) {
1291
- this.map1.set(key1, map2 = /* @__PURE__ */ new Map());
1292
- }
1311
+ let map2 = this.map1.get(key1) ?? this.map1.set(key1, /* @__PURE__ */ new Map()).get(key1);
1293
1312
  map2.set(key2, value);
1294
1313
  return value;
1295
1314
  }
1296
1315
  get(key1, key2) {
1297
- let map2 = this.map1.get(key1);
1298
- if (!map2) {
1299
- return void 0;
1300
- }
1301
- return map2.get(key2);
1316
+ return this.map1.get(key1)?.get(key2);
1302
1317
  }
1303
1318
  has(key1, key2) {
1304
- let map2 = this.map1.get(key1);
1305
- if (!map2) {
1306
- return false;
1307
- }
1308
- return map2.has(key2);
1319
+ return this.map1.get(key1)?.has(key2) ?? false;
1309
1320
  }
1310
1321
  delete(key1, key2) {
1311
- let map2 = this.map1.get(key1);
1312
- if (!map2) {
1313
- return false;
1314
- }
1322
+ if (key2 === void 0) return this.map1.delete(key1);
1323
+ const map2 = this.map1.get(key1);
1324
+ if (!map2) return false;
1315
1325
  return map2.delete(key2);
1316
1326
  }
1327
+ clear() {
1328
+ this.map1.clear();
1329
+ }
1330
+ get size() {
1331
+ let count = 0;
1332
+ for (const map2 of this.map1.values()) {
1333
+ count += map2.size;
1334
+ }
1335
+ return count;
1336
+ }
1337
+ forEach(callbackfn, thisArg) {
1338
+ this.map1.forEach((map2, key1) => map2.forEach((value, key2) => callbackfn.call(thisArg, value, key1, key2, this)));
1339
+ }
1340
+ keys() {
1341
+ function* gen(map1) {
1342
+ for (const [k1, map2] of map1)
1343
+ for (const k2 of map2.keys())
1344
+ yield [k1, k2];
1345
+ }
1346
+ return gen(this.map1);
1347
+ }
1348
+ values() {
1349
+ function* gen(map1) {
1350
+ for (const map2 of map1.values())
1351
+ for (const value of map2.values())
1352
+ yield value;
1353
+ }
1354
+ return gen(this.map1);
1355
+ }
1356
+ *entries() {
1357
+ for (const [key1, map2] of this.map1)
1358
+ for (const [key2, value] of map2)
1359
+ yield [key1, key2, value];
1360
+ }
1361
+ *[Symbol.iterator]() {
1362
+ yield* this.entries();
1363
+ }
1317
1364
  };
1318
1365
  var Map3 = class {
1319
1366
  constructor() {
@@ -1321,48 +1368,72 @@ var Map3 = class {
1321
1368
  }
1322
1369
  set(key1, key2, key3, value) {
1323
1370
  let map2 = this.map1.get(key1);
1324
- if (!map2) {
1325
- this.map1.set(key1, map2 = /* @__PURE__ */ new Map());
1326
- }
1371
+ if (!map2) this.map1.set(key1, map2 = /* @__PURE__ */ new Map());
1327
1372
  let map3 = map2.get(key2);
1328
- if (!map3) {
1329
- map2.set(key2, map3 = /* @__PURE__ */ new Map());
1330
- }
1373
+ if (!map3) map2.set(key2, map3 = /* @__PURE__ */ new Map());
1331
1374
  map3.set(key3, value);
1332
1375
  return value;
1333
1376
  }
1334
1377
  get(key1, key2, key3) {
1335
- let map2 = this.map1.get(key1);
1336
- if (!map2) {
1337
- return void 0;
1338
- }
1339
- let map3 = map2.get(key2);
1340
- if (!map3) {
1341
- return void 0;
1342
- }
1343
- return map3.get(key3);
1378
+ return this.map1.get(key1)?.get(key2)?.get(key3);
1344
1379
  }
1345
1380
  has(key1, key2, key3) {
1346
- let map2 = this.map1.get(key1);
1347
- if (!map2) {
1348
- return false;
1381
+ return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
1382
+ }
1383
+ delete(key1, key2, key3) {
1384
+ if (key3 === void 0) {
1385
+ if (key2 === void 0) return this.map1.delete(key1);
1386
+ const map2 = this.map1.get(key1);
1387
+ if (!map2) return false;
1388
+ return map2.delete(key2);
1389
+ } else {
1390
+ if (key2 === void 0) return this.map1.delete(key1);
1391
+ const map3 = this.map1.get(key1)?.get(key2);
1392
+ if (!map3) return false;
1393
+ return map3.delete(key3);
1349
1394
  }
1350
- let map3 = map2.get(key2);
1351
- if (!map3) {
1352
- return false;
1395
+ }
1396
+ clear() {
1397
+ this.map1.clear();
1398
+ }
1399
+ get size() {
1400
+ let count = 0;
1401
+ for (const map2 of this.map1.values()) {
1402
+ for (const map3 of map2.values()) {
1403
+ count += map3.size;
1404
+ }
1353
1405
  }
1354
- return map3.has(key3);
1406
+ return count;
1355
1407
  }
1356
- delete(key1, key2, key3) {
1357
- let map2 = this.map1.get(key1);
1358
- if (!map2) {
1359
- return false;
1408
+ forEach(callbackfn, thisArg) {
1409
+ this.map1.forEach((map2, key1) => map2.forEach((map3, key2) => map3.forEach((value, key3) => callbackfn.call(thisArg, value, key1, key2, key3, this))));
1410
+ }
1411
+ keys() {
1412
+ 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];
1360
1417
  }
1361
- let map3 = map2.get(key2);
1362
- if (!map3) {
1363
- return false;
1418
+ return gen(this.map1);
1419
+ }
1420
+ values() {
1421
+ function* gen(map1) {
1422
+ for (const map2 of map1.values())
1423
+ for (const map3 of map2.values())
1424
+ for (const value of map3.values())
1425
+ yield value;
1364
1426
  }
1365
- return map3.delete(key3);
1427
+ return gen(this.map1);
1428
+ }
1429
+ *entries() {
1430
+ for (const [key1, map2] of this.map1)
1431
+ for (const [key2, map3] of map2)
1432
+ for (const [key3, value] of map3)
1433
+ yield [key1, key2, key3, value];
1434
+ }
1435
+ *[Symbol.iterator]() {
1436
+ yield* this.entries();
1366
1437
  }
1367
1438
  };
1368
1439
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tspro/ts-utils-lib",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "author": "PahkaSoft",
5
5
  "license": "MIT",
6
6
  "private": false,