@tspro/ts-utils-lib 1.14.0 → 1.16.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.js CHANGED
@@ -1,4 +1,4 @@
1
- /* TsUtilsLib v1.14.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
1
+ /* TsUtilsLib v1.16.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;
@@ -26,15 +26,18 @@ __export(index_exports, {
26
26
  Assert: () => Assert,
27
27
  Cookies: () => Cookies,
28
28
  Device: () => Device,
29
+ IndexArray: () => IndexArray,
29
30
  LRUCache: () => LRUCache,
30
31
  Map1: () => Map1,
31
32
  Map2: () => Map2,
32
33
  Map3: () => Map3,
34
+ MultiContainer: () => MultiContainer,
33
35
  SignedIndexArray: () => SignedIndexArray,
34
36
  SmallIntCache: () => SmallIntCache,
35
37
  Stack: () => Stack,
36
38
  Utils: () => utils_exports,
37
- Vec2: () => Vec2
39
+ Vec2: () => Vec2,
40
+ asMulti: () => asMulti
38
41
  });
39
42
  module.exports = __toCommonJS(index_exports);
40
43
 
@@ -68,136 +71,175 @@ __export(arr_exports, {
68
71
  toArray: () => toArray
69
72
  });
70
73
 
71
- // src/utils/math/index.ts
72
- var math_exports = {};
73
- __export(math_exports, {
74
- avg: () => avg,
75
- calcNormal: () => calcNormal,
76
- clamp: () => clamp,
77
- cmp: () => cmp,
78
- interpolateCoord: () => interpolateCoord,
79
- interpolateY: () => interpolateY,
74
+ // src/utils/is/index.ts
75
+ var is_exports = {};
76
+ __export(is_exports, {
77
+ isArray: () => isArray,
78
+ isArrayOrUndefined: () => isArrayOrUndefined,
79
+ isBoolean: () => isBoolean,
80
+ isBooleanOrUndefined: () => isBooleanOrUndefined,
81
+ isEmptyArray: () => isEmptyArray,
82
+ isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined,
83
+ isEmptyString: () => isEmptyString,
84
+ isEmptyStringOrUndefined: () => isEmptyStringOrUndefined,
85
+ isEnumValue: () => isEnumValue,
86
+ isEnumValueOrUndefined: () => isEnumValueOrUndefined,
87
+ isFinite: () => isFinite2,
88
+ isFunction: () => isFunction,
89
+ isFunctionOrUndefined: () => isFunctionOrUndefined,
90
+ isInfinity: () => isInfinity,
80
91
  isInteger: () => isInteger,
81
- linearToDecibels: () => linearToDecibels,
82
- mod: () => mod,
83
- romanize: () => romanize,
84
- sum: () => sum,
85
- toOrdinalNumber: () => toOrdinalNumber
92
+ isIntegerBetween: () => isIntegerBetween,
93
+ isIntegerEq: () => isIntegerEq,
94
+ isIntegerGt: () => isIntegerGt,
95
+ isIntegerGte: () => isIntegerGte,
96
+ isIntegerLt: () => isIntegerLt,
97
+ isIntegerLte: () => isIntegerLte,
98
+ isIntegerOrUndefined: () => isIntegerOrUndefined,
99
+ isNaNValue: () => isNaNValue,
100
+ isNegInfinity: () => isNegInfinity,
101
+ isNonEmptyArray: () => isNonEmptyArray,
102
+ isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined,
103
+ isNonEmptyString: () => isNonEmptyString,
104
+ isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined,
105
+ isNull: () => isNull,
106
+ isNullish: () => isNullish,
107
+ isNumber: () => isNumber,
108
+ isNumberOrUndefined: () => isNumberOrUndefined,
109
+ isObject: () => isObject,
110
+ isObjectOrUndefined: () => isObjectOrUndefined,
111
+ isPosInfinity: () => isPosInfinity,
112
+ isString: () => isString,
113
+ isStringOrUndefined: () => isStringOrUndefined,
114
+ isUndefined: () => isUndefined
115
+ });
116
+
117
+ // src/utils/enum/index.ts
118
+ var enum_exports = {};
119
+ __export(enum_exports, {
120
+ getEnumValues: () => getEnumValues
86
121
  });
122
+ function getEnumValues(e) {
123
+ return Object.keys(e).filter((key) => Number.isNaN(Number(key))).map((key) => e[key]);
124
+ }
125
+
126
+ // src/utils/is/index.ts
127
+ function isUndefined(value) {
128
+ return value === void 0;
129
+ }
130
+ function isNull(value) {
131
+ return value === null;
132
+ }
133
+ function isNullish(value) {
134
+ return value === void 0 || value === null;
135
+ }
136
+ function isObject(value) {
137
+ return typeof value === "object" && value !== null && !isArray(value);
138
+ }
139
+ function isObjectOrUndefined(value) {
140
+ return value === void 0 || isObject(value);
141
+ }
142
+ function isArray(a) {
143
+ return !!a && Object.prototype.toString.call(a) === "[object Array]";
144
+ }
145
+ function isArrayOrUndefined(value) {
146
+ return value === void 0 || isArray(value);
147
+ }
148
+ function isEmptyArray(a) {
149
+ return isArray(a) && a.length === 0;
150
+ }
151
+ function isNonEmptyArray(a) {
152
+ return isArray(a) && a.length > 0;
153
+ }
154
+ function isEmptyArrayOrUndefined(a) {
155
+ return isArray(a) && a.length === 0 || a === void 0;
156
+ }
157
+ function isNonEmptyArrayOrUndefined(a) {
158
+ return isArray(a) && a.length > 0 || a === void 0;
159
+ }
160
+ function isString(value) {
161
+ return typeof value === "string";
162
+ }
163
+ function isEmptyString(value) {
164
+ return typeof value === "string" && value.length === 0;
165
+ }
166
+ function isNonEmptyString(value) {
167
+ return typeof value === "string" && value.length > 0;
168
+ }
169
+ function isStringOrUndefined(value) {
170
+ return value === void 0 || typeof value === "string";
171
+ }
172
+ function isEmptyStringOrUndefined(value) {
173
+ return typeof value === "string" && value.length === 0 || value === void 0;
174
+ }
175
+ function isNonEmptyStringOrUndefined(value) {
176
+ return typeof value === "string" && value.length > 0 || value === void 0;
177
+ }
178
+ function isBoolean(value) {
179
+ return typeof value === "boolean";
180
+ }
181
+ function isBooleanOrUndefined(value) {
182
+ return value === void 0 || typeof value === "boolean";
183
+ }
184
+ function isFunction(value) {
185
+ return typeof value === "function";
186
+ }
187
+ function isFunctionOrUndefined(value) {
188
+ return value === void 0 || typeof value === "function";
189
+ }
190
+ function isEnumValue(value, enumObj, name = "value") {
191
+ return getEnumValues(enumObj).some((v) => v === value);
192
+ }
193
+ function isEnumValueOrUndefined(value, enumObj, name = "value") {
194
+ return value === void 0 || getEnumValues(enumObj).some((v) => v === value);
195
+ }
196
+ function isNumber(value) {
197
+ return typeof value === "number";
198
+ }
199
+ function isNumberOrUndefined(value) {
200
+ return typeof value === "number" || value === void 0;
201
+ }
202
+ function isFinite2(value) {
203
+ return typeof value === "number" && Number.isFinite(value);
204
+ }
87
205
  function isInteger(n) {
88
- return typeof n === "number" && isFinite(n) && n === Math.trunc(n);
206
+ return typeof n === "number" && isFinite2(n) && n === Math.trunc(n);
89
207
  }
90
- function linearToDecibels(linearVolume) {
91
- if (!isFinite(linearVolume)) {
92
- throw new Error("linearToDecibel: Invalid linearVolume = " + linearVolume);
93
- } else if (linearVolume <= 0) {
94
- return -Infinity;
95
- } else {
96
- return 20 * Math.log10(linearVolume);
97
- }
208
+ function isIntegerOrUndefined(n) {
209
+ return typeof n === "number" && isFinite2(n) && n === Math.trunc(n) || n === void 0;
98
210
  }
99
- function mod(m, n) {
100
- return (m % n + n) % n;
211
+ function isIntegerEq(value, compareTo) {
212
+ return isInteger(value) && value === compareTo;
101
213
  }
102
- function romanize(n) {
103
- if (!isInteger(n) || n < 0) {
104
- throw new Error("romanize: Invalid n = " + n);
105
- }
106
- var digits = String(+n).split("");
107
- var key = [
108
- "",
109
- "C",
110
- "CC",
111
- "CCC",
112
- "CD",
113
- "D",
114
- "DC",
115
- "DCC",
116
- "DCCC",
117
- "CM",
118
- "",
119
- "X",
120
- "XX",
121
- "XXX",
122
- "XL",
123
- "L",
124
- "LX",
125
- "LXX",
126
- "LXXX",
127
- "XC",
128
- "",
129
- "I",
130
- "II",
131
- "III",
132
- "IV",
133
- "V",
134
- "VI",
135
- "VII",
136
- "VIII",
137
- "IX"
138
- ];
139
- var roman = "", i = 3;
140
- while (i--) roman = (key[+digits.pop() + i * 10] || "") + roman;
141
- return Array(+digits.join("") + 1).join("M") + roman;
214
+ function isIntegerGt(value, compareTo) {
215
+ return isInteger(value) && value > compareTo;
142
216
  }
143
- function toOrdinalNumber(n) {
144
- if (!isInteger(n)) {
145
- throw new Error("toOrdinalNumber: Invalid n = " + n);
146
- }
147
- const nStr = n.toString();
148
- const lastDigit = Number(nStr.charAt(nStr.length - 1));
149
- if (n === 1 || n >= 20 && lastDigit === 1) {
150
- return nStr + "st";
151
- } else if (n === 2 || n >= 20 && lastDigit === 2) {
152
- return nStr + "nd";
153
- } else if (n === 3 || n >= 20 && lastDigit === 3) {
154
- return nStr + "rd";
155
- } else {
156
- return nStr + "th";
157
- }
217
+ function isIntegerGte(value, compareTo) {
218
+ return isInteger(value) && value >= compareTo;
158
219
  }
159
- function interpolateCoord(startX, startY, endX, endY, t) {
160
- return {
161
- x: startX + (endX - startX) * t,
162
- y: startY + (endY - startY) * t
163
- };
220
+ function isIntegerLt(value, compareTo) {
221
+ return isInteger(value) && value < compareTo;
164
222
  }
165
- function interpolateY(startX, startY, endX, endY, x) {
166
- let t = (x - startX) / (endX - startX);
167
- return startY + (endY - startY) * t;
223
+ function isIntegerLte(value, compareTo) {
224
+ return isInteger(value) && value <= compareTo;
168
225
  }
169
- function clamp(num, min, max) {
170
- return Math.min(Math.max(num, min), max);
226
+ function isIntegerBetween(value, min, max) {
227
+ return isInteger(value) && value >= min && value <= max;
171
228
  }
172
- function calcNormal(x1, y1, x2, y2) {
173
- let dx = x2 - x1;
174
- let dy = y2 - y1;
175
- let nx = -dy;
176
- let ny = dx;
177
- let len = Math.sqrt(nx * nx + ny * ny);
178
- if (len > 0) {
179
- nx /= len;
180
- ny /= len;
181
- } else {
182
- nx = 0;
183
- ny = 1;
184
- }
185
- return { nx, ny };
229
+ function isNaNValue(value) {
230
+ return typeof value === "number" && Number.isNaN(value);
186
231
  }
187
- function sum(arr) {
188
- return arr.reduce((prev, cur) => cur + prev, 0);
232
+ function isInfinity(value) {
233
+ return typeof value === "number" && Math.abs(value) === Infinity;
189
234
  }
190
- function avg(...values) {
191
- return sum(values) / values.length;
235
+ function isPosInfinity(value) {
236
+ return typeof value === "number" && value === Infinity;
192
237
  }
193
- function cmp(a, b) {
194
- return a < b ? -1 : a > b ? 1 : 0;
238
+ function isNegInfinity(value) {
239
+ return typeof value === "number" && value === -Infinity;
195
240
  }
196
241
 
197
242
  // src/utils/arr/index.ts
198
- function isArray(a) {
199
- return !!a && Object.prototype.toString.call(a) === "[object Array]";
200
- }
201
243
  function toArray(a) {
202
244
  return isArray(a) ? a : [a];
203
245
  }
@@ -284,15 +326,6 @@ __export(dom_exports, {
284
326
  styleLayoutChanged: () => styleLayoutChanged
285
327
  });
286
328
 
287
- // src/utils/enum/index.ts
288
- var enum_exports = {};
289
- __export(enum_exports, {
290
- getEnumValues: () => getEnumValues
291
- });
292
- function getEnumValues(e) {
293
- return Object.keys(e).filter((key) => Number.isNaN(Number(key))).map((key) => e[key]);
294
- }
295
-
296
329
  // src/modules/assert.ts
297
330
  var Assert;
298
331
  ((Assert2) => {
@@ -712,172 +745,139 @@ function getCanvasTextWidth(text, font) {
712
745
  return ctx.measureText(text).width;
713
746
  }
714
747
 
715
- // src/utils/is/index.ts
716
- var is_exports = {};
717
- __export(is_exports, {
718
- isArray: () => isArray2,
719
- isArrayOrUndefined: () => isArrayOrUndefined,
720
- isBoolean: () => isBoolean,
721
- isBooleanOrUndefined: () => isBooleanOrUndefined,
722
- isEmptyArray: () => isEmptyArray,
723
- isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined,
724
- isEmptyString: () => isEmptyString,
725
- isEmptyStringOrUndefined: () => isEmptyStringOrUndefined,
726
- isEnumValue: () => isEnumValue,
727
- isEnumValueOrUndefined: () => isEnumValueOrUndefined,
728
- isFinite: () => isFinite2,
729
- isFunction: () => isFunction,
730
- isFunctionOrUndefined: () => isFunctionOrUndefined,
731
- isInfinity: () => isInfinity,
732
- isInteger: () => isInteger2,
733
- isIntegerBetween: () => isIntegerBetween,
734
- isIntegerEq: () => isIntegerEq,
735
- isIntegerGt: () => isIntegerGt,
736
- isIntegerGte: () => isIntegerGte,
737
- isIntegerLt: () => isIntegerLt,
738
- isIntegerLte: () => isIntegerLte,
739
- isIntegerOrUndefined: () => isIntegerOrUndefined,
740
- isNaNValue: () => isNaNValue,
741
- isNegInfinity: () => isNegInfinity,
742
- isNonEmptyArray: () => isNonEmptyArray,
743
- isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined,
744
- isNonEmptyString: () => isNonEmptyString,
745
- isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined,
746
- isNull: () => isNull,
747
- isNullish: () => isNullish,
748
- isNumber: () => isNumber,
749
- isNumberOrUndefined: () => isNumberOrUndefined,
750
- isObject: () => isObject,
751
- isObjectOrUndefined: () => isObjectOrUndefined,
752
- isPosInfinity: () => isPosInfinity,
753
- isString: () => isString,
754
- isStringOrUndefined: () => isStringOrUndefined,
755
- isUndefined: () => isUndefined
748
+ // src/utils/map/index.ts
749
+ var map_exports = {};
750
+ __export(map_exports, {
751
+ getMapKeys: () => getMapKeys
756
752
  });
757
- function isUndefined(value) {
758
- return value === void 0;
759
- }
760
- function isNull(value) {
761
- return value === null;
762
- }
763
- function isNullish(value) {
764
- return value === void 0 || value === null;
765
- }
766
- function isObject(value) {
767
- return typeof value === "object" && value !== null && !isArray2(value);
768
- }
769
- function isObjectOrUndefined(value) {
770
- return value === void 0 || isObject(value);
771
- }
772
- function isArray2(a) {
773
- return !!a && Object.prototype.toString.call(a) === "[object Array]";
774
- }
775
- function isArrayOrUndefined(value) {
776
- return value === void 0 || isArray2(value);
777
- }
778
- function isEmptyArray(a) {
779
- return isArray2(a) && a.length === 0;
780
- }
781
- function isNonEmptyArray(a) {
782
- return isArray2(a) && a.length > 0;
783
- }
784
- function isEmptyArrayOrUndefined(a) {
785
- return isArray2(a) && a.length === 0 || a === void 0;
786
- }
787
- function isNonEmptyArrayOrUndefined(a) {
788
- return isArray2(a) && a.length > 0 || a === void 0;
789
- }
790
- function isString(value) {
791
- return typeof value === "string";
792
- }
793
- function isEmptyString(value) {
794
- return typeof value === "string" && value.length === 0;
795
- }
796
- function isNonEmptyString(value) {
797
- return typeof value === "string" && value.length > 0;
798
- }
799
- function isStringOrUndefined(value) {
800
- return value === void 0 || typeof value === "string";
801
- }
802
- function isEmptyStringOrUndefined(value) {
803
- return typeof value === "string" && value.length === 0 || value === void 0;
804
- }
805
- function isNonEmptyStringOrUndefined(value) {
806
- return typeof value === "string" && value.length > 0 || value === void 0;
807
- }
808
- function isBoolean(value) {
809
- return typeof value === "boolean";
810
- }
811
- function isBooleanOrUndefined(value) {
812
- return value === void 0 || typeof value === "boolean";
813
- }
814
- function isFunction(value) {
815
- return typeof value === "function";
816
- }
817
- function isFunctionOrUndefined(value) {
818
- return value === void 0 || typeof value === "function";
819
- }
820
- function isEnumValue(value, enumObj, name = "value") {
821
- return getEnumValues(enumObj).some((v) => v === value);
822
- }
823
- function isEnumValueOrUndefined(value, enumObj, name = "value") {
824
- return value === void 0 || getEnumValues(enumObj).some((v) => v === value);
825
- }
826
- function isNumber(value) {
827
- return typeof value === "number";
828
- }
829
- function isNumberOrUndefined(value) {
830
- return typeof value === "number" || value === void 0;
831
- }
832
- function isFinite2(value) {
833
- return typeof value === "number" && Number.isFinite(value);
834
- }
835
- function isInteger2(n) {
836
- return typeof n === "number" && isFinite2(n) && n === Math.trunc(n);
837
- }
838
- function isIntegerOrUndefined(n) {
839
- return typeof n === "number" && isFinite2(n) && n === Math.trunc(n) || n === void 0;
753
+ function getMapKeys(map) {
754
+ let keys = [];
755
+ map.forEach((value, key) => keys.push(key));
756
+ return keys;
840
757
  }
841
- function isIntegerEq(value, compareTo) {
842
- return isInteger2(value) && value === compareTo;
758
+
759
+ // src/utils/math/index.ts
760
+ var math_exports = {};
761
+ __export(math_exports, {
762
+ avg: () => avg,
763
+ calcNormal: () => calcNormal,
764
+ clamp: () => clamp,
765
+ cmp: () => cmp,
766
+ interpolateCoord: () => interpolateCoord,
767
+ interpolateY: () => interpolateY,
768
+ isInteger: () => isInteger,
769
+ isNumber: () => isNumber,
770
+ linearToDecibels: () => linearToDecibels,
771
+ mod: () => mod,
772
+ romanize: () => romanize,
773
+ sum: () => sum,
774
+ toOrdinalNumber: () => toOrdinalNumber
775
+ });
776
+ function linearToDecibels(linearVolume) {
777
+ if (!isFinite(linearVolume)) {
778
+ throw new Error("linearToDecibel: Invalid linearVolume = " + linearVolume);
779
+ } else if (linearVolume <= 0) {
780
+ return -Infinity;
781
+ } else {
782
+ return 20 * Math.log10(linearVolume);
783
+ }
843
784
  }
844
- function isIntegerGt(value, compareTo) {
845
- return isInteger2(value) && value > compareTo;
785
+ function mod(m, n) {
786
+ return (m % n + n) % n;
846
787
  }
847
- function isIntegerGte(value, compareTo) {
848
- return isInteger2(value) && value >= compareTo;
788
+ function romanize(n) {
789
+ if (!isInteger(n) || n < 0) {
790
+ throw new Error("romanize: Invalid n = " + n);
791
+ }
792
+ var digits = String(+n).split("");
793
+ var key = [
794
+ "",
795
+ "C",
796
+ "CC",
797
+ "CCC",
798
+ "CD",
799
+ "D",
800
+ "DC",
801
+ "DCC",
802
+ "DCCC",
803
+ "CM",
804
+ "",
805
+ "X",
806
+ "XX",
807
+ "XXX",
808
+ "XL",
809
+ "L",
810
+ "LX",
811
+ "LXX",
812
+ "LXXX",
813
+ "XC",
814
+ "",
815
+ "I",
816
+ "II",
817
+ "III",
818
+ "IV",
819
+ "V",
820
+ "VI",
821
+ "VII",
822
+ "VIII",
823
+ "IX"
824
+ ];
825
+ var roman = "", i = 3;
826
+ while (i--) roman = (key[+digits.pop() + i * 10] || "") + roman;
827
+ return Array(+digits.join("") + 1).join("M") + roman;
849
828
  }
850
- function isIntegerLt(value, compareTo) {
851
- return isInteger2(value) && value < compareTo;
829
+ function toOrdinalNumber(n) {
830
+ if (!isInteger(n)) {
831
+ throw new Error("toOrdinalNumber: Invalid n = " + n);
832
+ }
833
+ const nStr = n.toString();
834
+ const lastDigit = Number(nStr.charAt(nStr.length - 1));
835
+ if (n === 1 || n >= 20 && lastDigit === 1) {
836
+ return nStr + "st";
837
+ } else if (n === 2 || n >= 20 && lastDigit === 2) {
838
+ return nStr + "nd";
839
+ } else if (n === 3 || n >= 20 && lastDigit === 3) {
840
+ return nStr + "rd";
841
+ } else {
842
+ return nStr + "th";
843
+ }
852
844
  }
853
- function isIntegerLte(value, compareTo) {
854
- return isInteger2(value) && value <= compareTo;
845
+ function interpolateCoord(startX, startY, endX, endY, t) {
846
+ return {
847
+ x: startX + (endX - startX) * t,
848
+ y: startY + (endY - startY) * t
849
+ };
855
850
  }
856
- function isIntegerBetween(value, min, max) {
857
- return isInteger2(value) && value >= min && value <= max;
851
+ function interpolateY(startX, startY, endX, endY, x) {
852
+ let t = (x - startX) / (endX - startX);
853
+ return startY + (endY - startY) * t;
858
854
  }
859
- function isNaNValue(value) {
860
- return typeof value === "number" && Number.isNaN(value);
855
+ function clamp(num, min, max) {
856
+ return Math.min(Math.max(num, min), max);
861
857
  }
862
- function isInfinity(value) {
863
- return typeof value === "number" && Math.abs(value) === Infinity;
858
+ function calcNormal(x1, y1, x2, y2) {
859
+ let dx = x2 - x1;
860
+ let dy = y2 - y1;
861
+ let nx = -dy;
862
+ let ny = dx;
863
+ let len = Math.sqrt(nx * nx + ny * ny);
864
+ if (len > 0) {
865
+ nx /= len;
866
+ ny /= len;
867
+ } else {
868
+ nx = 0;
869
+ ny = 1;
870
+ }
871
+ return { nx, ny };
864
872
  }
865
- function isPosInfinity(value) {
866
- return typeof value === "number" && value === Infinity;
873
+ function sum(arr) {
874
+ return arr.reduce((prev, cur) => cur + prev, 0);
867
875
  }
868
- function isNegInfinity(value) {
869
- return typeof value === "number" && value === -Infinity;
876
+ function avg(...values) {
877
+ return sum(values) / values.length;
870
878
  }
871
-
872
- // src/utils/map/index.ts
873
- var map_exports = {};
874
- __export(map_exports, {
875
- getMapKeys: () => getMapKeys
876
- });
877
- function getMapKeys(map) {
878
- let keys = [];
879
- map.forEach((value, key) => keys.push(key));
880
- return keys;
879
+ function cmp(a, b) {
880
+ return a < b ? -1 : a > b ? 1 : 0;
881
881
  }
882
882
 
883
883
  // src/utils/obj/index.ts
@@ -885,13 +885,10 @@ var obj_exports = {};
885
885
  __export(obj_exports, {
886
886
  deepEqual: () => deepEqual,
887
887
  hasProperties: () => hasProperties,
888
- isObject: () => isObject2
888
+ isObject: () => isObject
889
889
  });
890
- function isObject2(obj) {
891
- return typeof obj === "object" && obj !== null && !isArray(obj);
892
- }
893
890
  function hasProperties(obj, props) {
894
- return isObject2(obj) && props.every((p) => p in obj);
891
+ return isObject(obj) && props.every((p) => p in obj);
895
892
  }
896
893
  function deepEqual(a, b) {
897
894
  if (a === b) return true;
@@ -918,6 +915,7 @@ __export(str_exports, {
918
915
  charCount: () => charCount,
919
916
  chunkString: () => chunkString,
920
917
  insertAt: () => insertAt,
918
+ isString: () => isString,
921
919
  makeSentenceFromPascal: () => makeSentenceFromPascal,
922
920
  removeAt: () => removeAt,
923
921
  repeatString: () => repeatString,
@@ -1193,103 +1191,316 @@ var LRUCache = class {
1193
1191
  if (this.size >= this.capacity) {
1194
1192
  this.evict();
1195
1193
  }
1196
- this.cache[key] = value;
1197
- this.addToTail(key);
1198
- this.size++;
1194
+ this.cache[key] = value;
1195
+ this.addToTail(key);
1196
+ this.size++;
1197
+ }
1198
+ // Marks a key as most recently used
1199
+ touch(key) {
1200
+ if (this.tail === key) return;
1201
+ this.removeKey(key);
1202
+ this.addToTail(key);
1203
+ }
1204
+ // Evicts the least recently used item (at the head)
1205
+ evict() {
1206
+ if (this.head !== null) {
1207
+ const oldestKey = this.head;
1208
+ this.removeKey(oldestKey);
1209
+ delete this.cache[oldestKey];
1210
+ this.size--;
1211
+ }
1212
+ }
1213
+ // Removes a key from the linked list
1214
+ removeKey(key) {
1215
+ const prevKey = this.prev[key];
1216
+ const nextKey = this.next[key];
1217
+ if (prevKey !== void 0) {
1218
+ this.next[prevKey] = nextKey;
1219
+ } else {
1220
+ this.head = nextKey ?? null;
1221
+ }
1222
+ if (nextKey !== void 0) {
1223
+ this.prev[nextKey] = prevKey;
1224
+ } else {
1225
+ this.tail = prevKey ?? null;
1226
+ }
1227
+ delete this.prev[key];
1228
+ delete this.next[key];
1229
+ }
1230
+ // Adds a key to the tail (most recently used position)
1231
+ addToTail(key) {
1232
+ if (this.tail !== null) {
1233
+ this.next[this.tail] = key;
1234
+ this.prev[key] = this.tail;
1235
+ } else {
1236
+ this.head = key;
1237
+ }
1238
+ this.tail = key;
1239
+ }
1240
+ };
1241
+
1242
+ // src/core/small-int-cache.ts
1243
+ var SmallIntCache = class {
1244
+ // for keys < 0
1245
+ constructor() {
1246
+ __publicField(this, "pos");
1247
+ // for keys >= 0
1248
+ __publicField(this, "neg");
1249
+ this.pos = [];
1250
+ this.neg = [];
1251
+ }
1252
+ set(key, value) {
1253
+ if (!isInteger(key)) {
1254
+ throw new Error("Key must be an integer");
1255
+ } else if (key >= 0) {
1256
+ this.pos[key] = value;
1257
+ } else {
1258
+ this.neg[-key - 1] = value;
1259
+ }
1260
+ }
1261
+ get(key) {
1262
+ if (!isInteger(key)) {
1263
+ throw new Error("Key must be an integer");
1264
+ } else if (key >= 0) {
1265
+ return this.pos[key];
1266
+ } else {
1267
+ return this.neg[-key - 1];
1268
+ }
1269
+ }
1270
+ has(key) {
1271
+ if (!isInteger(key)) {
1272
+ return false;
1273
+ } else if (key >= 0) {
1274
+ return key in this.pos;
1275
+ } else {
1276
+ return -key - 1 in this.neg;
1277
+ }
1278
+ }
1279
+ delete(key) {
1280
+ if (!isInteger(key)) {
1281
+ return;
1282
+ } else if (key >= 0) {
1283
+ delete this.pos[key];
1284
+ } else {
1285
+ delete this.neg[-key - 1];
1286
+ }
1287
+ }
1288
+ clear() {
1289
+ this.pos = [];
1290
+ this.neg = [];
1291
+ }
1292
+ };
1293
+
1294
+ // src/core/index-array.ts
1295
+ var IndexArray = class _IndexArray {
1296
+ constructor(entries) {
1297
+ // for indexes >= 0
1298
+ __publicField(this, "posEl");
1299
+ __publicField(this, "hasPos");
1300
+ // number of elems
1301
+ __publicField(this, "elCount");
1302
+ if (entries instanceof _IndexArray) {
1303
+ this.posEl = entries.posEl.slice();
1304
+ this.hasPos = entries.hasPos.slice();
1305
+ this.elCount = entries.elCount;
1306
+ } else {
1307
+ this.posEl = [];
1308
+ this.hasPos = [];
1309
+ this.elCount = 0;
1310
+ if (entries) {
1311
+ for (const [id, el] of entries) {
1312
+ this.set(id, el);
1313
+ }
1314
+ }
1315
+ }
1316
+ }
1317
+ static toNegIndex(id) {
1318
+ return -id - 1;
1319
+ }
1320
+ static validateIndex(id) {
1321
+ if (!isIntegerGte(id, 0)) throw new Error(`Invalid index ${id} - must be an integer >= 0!`);
1322
+ return id;
1323
+ }
1324
+ get posLen() {
1325
+ return this.hasPos.length;
1326
+ }
1327
+ get size() {
1328
+ return this.elCount;
1329
+ }
1330
+ isEmpty() {
1331
+ return this.size === 0;
1332
+ }
1333
+ has(id) {
1334
+ _IndexArray.validateIndex(id);
1335
+ return this.hasPos[id] === true;
1336
+ }
1337
+ set(id, el) {
1338
+ _IndexArray.validateIndex(id);
1339
+ if (this.hasPos[id] !== true) this.elCount++;
1340
+ this.posEl[id] = el;
1341
+ this.hasPos[id] = true;
1342
+ }
1343
+ get(id) {
1344
+ _IndexArray.validateIndex(id);
1345
+ return this.hasPos[id] ? this.posEl[id] : void 0;
1346
+ }
1347
+ getOrDefault(id, defaultValue) {
1348
+ return this.get(id) ?? defaultValue;
1349
+ }
1350
+ getOrCreate(id, creatorOrValue) {
1351
+ if (!this.has(id)) {
1352
+ const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
1353
+ this.set(id, value);
1354
+ return value;
1355
+ }
1356
+ return this.get(id);
1357
+ }
1358
+ delete(id) {
1359
+ _IndexArray.validateIndex(id);
1360
+ if (!this.hasPos[id]) return false;
1361
+ this.posEl[id] = void 0;
1362
+ this.hasPos[id] = false;
1363
+ this.elCount--;
1364
+ return true;
1365
+ }
1366
+ clear() {
1367
+ this.posEl = [];
1368
+ this.hasPos = [];
1369
+ this.elCount = 0;
1370
+ }
1371
+ forEach(callbackfn, thisArg) {
1372
+ for (const [id, el] of this.entries()) {
1373
+ callbackfn.call(thisArg, el, id, this);
1374
+ }
1375
+ }
1376
+ *indices() {
1377
+ for (let id = 0; id < this.posLen; id++) {
1378
+ if (this.hasPos[id]) yield id;
1379
+ }
1380
+ }
1381
+ *values() {
1382
+ for (let id = 0; id < this.posLen; id++) {
1383
+ if (this.hasPos[id]) yield this.posEl[id];
1384
+ }
1385
+ }
1386
+ *entries() {
1387
+ for (let id = 0; id < this.posLen; id++) {
1388
+ if (this.hasPos[id]) yield [id, this.posEl[id]];
1389
+ }
1390
+ }
1391
+ indicesArray() {
1392
+ return [...this.indices()];
1393
+ }
1394
+ valuesArray() {
1395
+ return [...this.values()];
1396
+ }
1397
+ entriesArray() {
1398
+ return [...this.entries()];
1399
+ }
1400
+ *kvKeys() {
1401
+ for (const id of this.indices()) {
1402
+ yield [id];
1403
+ }
1199
1404
  }
1200
- // Marks a key as most recently used
1201
- touch(key) {
1202
- if (this.tail === key) return;
1203
- this.removeKey(key);
1204
- this.addToTail(key);
1405
+ *kvValues() {
1406
+ for (const el of this.values()) {
1407
+ yield el;
1408
+ }
1205
1409
  }
1206
- // Evicts the least recently used item (at the head)
1207
- evict() {
1208
- if (this.head !== null) {
1209
- const oldestKey = this.head;
1210
- this.removeKey(oldestKey);
1211
- delete this.cache[oldestKey];
1212
- this.size--;
1410
+ *kvEntries() {
1411
+ for (const [id, el] of this.entries()) {
1412
+ yield [[id], el];
1213
1413
  }
1214
1414
  }
1215
- // Removes a key from the linked list
1216
- removeKey(key) {
1217
- const prevKey = this.prev[key];
1218
- const nextKey = this.next[key];
1219
- if (prevKey !== void 0) {
1220
- this.next[prevKey] = nextKey;
1221
- } else {
1222
- this.head = nextKey ?? null;
1415
+ *[Symbol.iterator]() {
1416
+ yield* this.entries();
1417
+ }
1418
+ clone() {
1419
+ return new _IndexArray(this);
1420
+ }
1421
+ merge(other, conflictResolver) {
1422
+ for (const [id, value] of other.entries()) {
1423
+ if (this.has(id) && conflictResolver) {
1424
+ this.set(id, conflictResolver(this.get(id), value, id));
1425
+ } else {
1426
+ this.set(id, value);
1427
+ }
1223
1428
  }
1224
- if (nextKey !== void 0) {
1225
- this.prev[nextKey] = prevKey;
1226
- } else {
1227
- this.tail = prevKey ?? null;
1429
+ return this;
1430
+ }
1431
+ some(fn) {
1432
+ for (const [id, el] of this.entries()) {
1433
+ if (fn(el, id)) return true;
1228
1434
  }
1229
- delete this.prev[key];
1230
- delete this.next[key];
1435
+ return false;
1231
1436
  }
1232
- // Adds a key to the tail (most recently used position)
1233
- addToTail(key) {
1234
- if (this.tail !== null) {
1235
- this.next[this.tail] = key;
1236
- this.prev[key] = this.tail;
1237
- } else {
1238
- this.head = key;
1437
+ every(fn) {
1438
+ for (const [id, el] of this.entries()) {
1439
+ if (!fn(el, id)) return false;
1239
1440
  }
1240
- this.tail = key;
1441
+ return true;
1241
1442
  }
1242
- };
1243
-
1244
- // src/core/small-int-cache.ts
1245
- var SmallIntCache = class {
1246
- // for keys < 0
1247
- constructor() {
1248
- __publicField(this, "pos");
1249
- // for keys >= 0
1250
- __publicField(this, "neg");
1251
- this.pos = [];
1252
- this.neg = [];
1443
+ filter(fn) {
1444
+ let result = new _IndexArray();
1445
+ for (const [id, el] of this.entries()) {
1446
+ if (fn(el, id)) result.set(id, el);
1447
+ }
1448
+ return result;
1253
1449
  }
1254
- set(key, value) {
1255
- if (!isInteger(key)) {
1256
- throw new Error("Key must be an integer");
1257
- } else if (key >= 0) {
1258
- this.pos[key] = value;
1450
+ reduce(fn, init) {
1451
+ let iterator = this.entries();
1452
+ let first = iterator.next();
1453
+ if (first.done) {
1454
+ if (arguments.length < 2) {
1455
+ throw new TypeError("Reduce of empty IndexArray with no initial value!");
1456
+ }
1457
+ return init;
1458
+ }
1459
+ let acc;
1460
+ let start;
1461
+ if (arguments.length < 2) {
1462
+ acc = first.value[1];
1463
+ start = iterator.next();
1259
1464
  } else {
1260
- this.neg[-key - 1] = value;
1465
+ acc = init;
1466
+ start = first;
1467
+ }
1468
+ for (let current = start; !current.done; current = iterator.next()) {
1469
+ const [id, el] = current.value;
1470
+ acc = fn(acc, el, id);
1261
1471
  }
1472
+ return acc;
1262
1473
  }
1263
- get(key) {
1264
- if (!isInteger(key)) {
1265
- throw new Error("Key must be an integer");
1266
- } else if (key >= 0) {
1267
- return this.pos[key];
1268
- } else {
1269
- return this.neg[-key - 1];
1474
+ mapToArray(fn) {
1475
+ let result = [];
1476
+ for (const [id, el] of this.entries()) {
1477
+ result.push(fn(el, id));
1270
1478
  }
1479
+ return result;
1271
1480
  }
1272
- has(key) {
1273
- if (!isInteger(key)) {
1274
- return false;
1275
- } else if (key >= 0) {
1276
- return key in this.pos;
1277
- } else {
1278
- return -key - 1 in this.neg;
1481
+ map(fn) {
1482
+ let result = new _IndexArray();
1483
+ for (const [id, el] of this.entries()) {
1484
+ result.set(id, fn(el, id));
1279
1485
  }
1486
+ return result;
1280
1487
  }
1281
- delete(key) {
1282
- if (!isInteger(key)) {
1283
- return;
1284
- } else if (key >= 0) {
1285
- delete this.pos[key];
1286
- } else {
1287
- delete this.neg[-key - 1];
1488
+ equals(other, eq) {
1489
+ if (this.size !== other.size) return false;
1490
+ eq ?? (eq = (a, b) => a === b);
1491
+ const posLen = Math.max(this.posLen, other.posLen);
1492
+ for (let i = 0; i < posLen; ++i) {
1493
+ const hasA = this.hasPos[i];
1494
+ const hasB = other.hasPos[i];
1495
+ if (hasA !== hasB) return false;
1496
+ if (hasA && !eq(this.posEl[i], other.posEl[i])) return false;
1288
1497
  }
1498
+ return true;
1289
1499
  }
1290
- clear() {
1291
- this.pos = [];
1292
- this.neg = [];
1500
+ toString() {
1501
+ if (this.size === 0) return `IndexArray[ ]`;
1502
+ const entries = this.entriesArray().map(([id, el]) => `${id}: ${el}`).join(", ");
1503
+ return `IndexArray[ ${entries} ]`;
1293
1504
  }
1294
1505
  };
1295
1506
 
@@ -1326,38 +1537,50 @@ var SignedIndexArray = class _SignedIndexArray {
1326
1537
  static toNegIndex(id) {
1327
1538
  return -id - 1;
1328
1539
  }
1540
+ static validateIndex(id) {
1541
+ if (!isInteger(id)) throw new Error(`Invalid index ${id} - must be an integer!`);
1542
+ return id;
1543
+ }
1329
1544
  get size() {
1330
1545
  return this.elCount;
1331
1546
  }
1547
+ isEmpty() {
1548
+ return this.size === 0;
1549
+ }
1550
+ get posLen() {
1551
+ return this.hasPos.length;
1552
+ }
1553
+ get negLen() {
1554
+ return this.hasNeg.length;
1555
+ }
1332
1556
  has(id) {
1333
- if (!isInteger(id)) {
1334
- return false;
1335
- } else if (id >= 0) {
1557
+ _SignedIndexArray.validateIndex(id);
1558
+ if (id >= 0) {
1336
1559
  return this.hasPos[id] === true;
1337
1560
  } else {
1338
1561
  return this.hasNeg[_SignedIndexArray.toNegIndex(id)] === true;
1339
1562
  }
1340
1563
  }
1341
1564
  set(id, el) {
1342
- if (!isInteger(id)) {
1343
- throw new Error("Index must be an integer");
1344
- } else if (id >= 0) {
1565
+ _SignedIndexArray.validateIndex(id);
1566
+ if (id >= 0) {
1345
1567
  if (this.hasPos[id] !== true) this.elCount++;
1346
1568
  this.posEl[id] = el;
1347
1569
  this.hasPos[id] = true;
1348
1570
  } else {
1349
- if (this.hasNeg[_SignedIndexArray.toNegIndex(id)] !== true) this.elCount++;
1350
- this.negEl[_SignedIndexArray.toNegIndex(id)] = el;
1351
- this.hasNeg[_SignedIndexArray.toNegIndex(id)] = true;
1571
+ let negId = _SignedIndexArray.toNegIndex(id);
1572
+ if (this.hasNeg[negId] !== true) this.elCount++;
1573
+ this.negEl[negId] = el;
1574
+ this.hasNeg[negId] = true;
1352
1575
  }
1353
1576
  }
1354
1577
  get(id) {
1355
- if (!isInteger(id)) {
1356
- throw new Error("Index must be an integer");
1357
- } else if (id >= 0) {
1578
+ _SignedIndexArray.validateIndex(id);
1579
+ if (id >= 0) {
1358
1580
  return this.hasPos[id] ? this.posEl[id] : void 0;
1359
1581
  } else {
1360
- return this.hasNeg[_SignedIndexArray.toNegIndex(id)] ? this.negEl[_SignedIndexArray.toNegIndex(id)] : void 0;
1582
+ let negId = _SignedIndexArray.toNegIndex(id);
1583
+ return this.hasNeg[negId] ? this.negEl[negId] : void 0;
1361
1584
  }
1362
1585
  }
1363
1586
  getOrDefault(id, defaultValue) {
@@ -1372,7 +1595,7 @@ var SignedIndexArray = class _SignedIndexArray {
1372
1595
  return this.get(id);
1373
1596
  }
1374
1597
  delete(id) {
1375
- if (!isInteger(id)) return false;
1598
+ _SignedIndexArray.validateIndex(id);
1376
1599
  const isPos = id >= 0;
1377
1600
  const arr = isPos ? this.posEl : this.negEl;
1378
1601
  const has = isPos ? this.hasPos : this.hasNeg;
@@ -1395,45 +1618,54 @@ var SignedIndexArray = class _SignedIndexArray {
1395
1618
  callbackfn.call(thisArg, el, id, this);
1396
1619
  }
1397
1620
  }
1398
- indices() {
1399
- function* gen(self) {
1400
- for (let id = self.negEl.length - 1; id >= 0; id--) {
1401
- if (self.hasNeg[id]) yield _SignedIndexArray.toNegIndex(id);
1402
- }
1403
- for (let id = 0; id < self.posEl.length; id++) {
1404
- if (self.hasPos[id]) yield id;
1405
- }
1621
+ *indices() {
1622
+ for (let id = this.negLen - 1; id >= 0; id--) {
1623
+ if (this.hasNeg[id]) yield _SignedIndexArray.toNegIndex(id);
1406
1624
  }
1407
- return gen(this);
1408
- }
1409
- indicesArray() {
1410
- return [...this.indices()];
1411
- }
1412
- values() {
1413
- function* gen(self) {
1414
- for (let id = self.negEl.length - 1; id >= 0; id--) {
1415
- if (self.hasNeg[id]) yield self.negEl[id];
1416
- }
1417
- for (let id = 0; id < self.posEl.length; id++) {
1418
- if (self.hasPos[id]) yield self.posEl[id];
1419
- }
1625
+ for (let id = 0; id < this.posLen; id++) {
1626
+ if (this.hasPos[id]) yield id;
1420
1627
  }
1421
- return gen(this);
1422
1628
  }
1423
- valuesArray() {
1424
- return [...this.values()];
1629
+ *values() {
1630
+ for (let id = this.negLen - 1; id >= 0; id--) {
1631
+ if (this.hasNeg[id]) yield this.negEl[id];
1632
+ }
1633
+ for (let id = 0; id < this.posLen; id++) {
1634
+ if (this.hasPos[id]) yield this.posEl[id];
1635
+ }
1425
1636
  }
1426
1637
  *entries() {
1427
- for (let id = this.negEl.length - 1; id >= 0; id--) {
1638
+ for (let id = this.negLen - 1; id >= 0; id--) {
1428
1639
  if (this.hasNeg[id]) yield [_SignedIndexArray.toNegIndex(id), this.negEl[id]];
1429
1640
  }
1430
- for (let id = 0; id < this.posEl.length; id++) {
1641
+ for (let id = 0; id < this.posLen; id++) {
1431
1642
  if (this.hasPos[id]) yield [id, this.posEl[id]];
1432
1643
  }
1433
1644
  }
1645
+ indicesArray() {
1646
+ return [...this.indices()];
1647
+ }
1648
+ valuesArray() {
1649
+ return [...this.values()];
1650
+ }
1434
1651
  entriesArray() {
1435
1652
  return [...this.entries()];
1436
1653
  }
1654
+ *kvKeys() {
1655
+ for (const id of this.indices()) {
1656
+ yield [id];
1657
+ }
1658
+ }
1659
+ *kvValues() {
1660
+ for (const el of this.values()) {
1661
+ yield el;
1662
+ }
1663
+ }
1664
+ *kvEntries() {
1665
+ for (const [id, el] of this.entries()) {
1666
+ yield [[id], el];
1667
+ }
1668
+ }
1437
1669
  *[Symbol.iterator]() {
1438
1670
  yield* this.entries();
1439
1671
  }
@@ -1507,7 +1739,27 @@ var SignedIndexArray = class _SignedIndexArray {
1507
1739
  }
1508
1740
  return result;
1509
1741
  }
1742
+ equals(other, eq) {
1743
+ if (this.size !== other.size) return false;
1744
+ eq ?? (eq = (a, b) => a === b);
1745
+ const posLen = Math.max(this.posLen, other.posLen);
1746
+ for (let i = 0; i < posLen; ++i) {
1747
+ const hasA = this.hasPos[i];
1748
+ const hasB = other.hasPos[i];
1749
+ if (hasA !== hasB) return false;
1750
+ if (hasA && !eq(this.posEl[i], other.posEl[i])) return false;
1751
+ }
1752
+ const negLen = Math.max(this.negLen, other.negLen);
1753
+ for (let i = 0; i < negLen; ++i) {
1754
+ const hasA = this.hasNeg[i];
1755
+ const hasB = other.hasNeg[i];
1756
+ if (hasA !== hasB) return false;
1757
+ if (hasA && !eq(this.negEl[i], other.negEl[i])) return false;
1758
+ }
1759
+ return true;
1760
+ }
1510
1761
  toString() {
1762
+ if (this.size === 0) return `SignedIndexArray[ ]`;
1511
1763
  const entries = this.entriesArray().map(([id, el]) => `${id}: ${el}`).join(", ");
1512
1764
  return `SignedIndexArray[ ${entries} ]`;
1513
1765
  }
@@ -1549,28 +1801,46 @@ var Map1 = class _Map1 {
1549
1801
  get size() {
1550
1802
  return this.map1.size;
1551
1803
  }
1804
+ isEmpty() {
1805
+ return this.size === 0;
1806
+ }
1552
1807
  forEach(callbackfn, thisArg) {
1553
1808
  this.map1.forEach((value, key1) => callbackfn.call(thisArg, value, key1, this));
1554
1809
  }
1555
- keys() {
1556
- return this.map1.keys();
1810
+ *keys() {
1811
+ yield* this.map1.keys();
1812
+ }
1813
+ *values() {
1814
+ yield* this.map1.values();
1815
+ }
1816
+ *entries() {
1817
+ for (const [key1, value] of this.map1)
1818
+ yield [key1, value];
1557
1819
  }
1558
1820
  keysArray() {
1559
1821
  return [...this.keys()];
1560
1822
  }
1561
- values() {
1562
- return this.map1.values();
1563
- }
1564
1823
  valuesArray() {
1565
1824
  return [...this.values()];
1566
1825
  }
1567
- *entries() {
1568
- for (const [key1, value] of this.map1)
1569
- yield [key1, value];
1570
- }
1571
1826
  entriesArray() {
1572
1827
  return [...this.entries()];
1573
1828
  }
1829
+ *kvKeys() {
1830
+ for (const key of this.keys()) {
1831
+ yield [key];
1832
+ }
1833
+ }
1834
+ *kvValues() {
1835
+ for (const el of this.values()) {
1836
+ yield el;
1837
+ }
1838
+ }
1839
+ *kvEntries() {
1840
+ for (const [key, el] of this.entries()) {
1841
+ yield [[key], el];
1842
+ }
1843
+ }
1574
1844
  *[Symbol.iterator]() {
1575
1845
  yield* this.entries();
1576
1846
  }
@@ -1686,39 +1956,48 @@ var Map2 = class _Map2 {
1686
1956
  }
1687
1957
  return count;
1688
1958
  }
1959
+ isEmpty() {
1960
+ return this.size === 0;
1961
+ }
1689
1962
  forEach(callbackfn, thisArg) {
1690
1963
  this.map1.forEach((map2, key1) => map2.forEach((value, key2) => callbackfn.call(thisArg, value, key1, key2, this)));
1691
1964
  }
1692
- keys() {
1693
- function* gen(map1) {
1694
- for (const [key1, map2] of map1)
1695
- for (const key2 of map2.keys())
1696
- yield [key1, key2];
1697
- }
1698
- return gen(this.map1);
1699
- }
1700
- keysArray() {
1701
- return [...this.keys()];
1702
- }
1703
- values() {
1704
- function* gen(map1) {
1705
- for (const map2 of map1.values())
1706
- for (const value of map2.values())
1707
- yield value;
1708
- }
1709
- return gen(this.map1);
1965
+ *keys() {
1966
+ for (const [key1, map2] of this.map1)
1967
+ for (const key2 of map2.keys())
1968
+ yield [key1, key2];
1710
1969
  }
1711
- valuesArray() {
1712
- return [...this.values()];
1970
+ *values() {
1971
+ for (const map2 of this.map1.values())
1972
+ for (const value of map2.values())
1973
+ yield value;
1713
1974
  }
1714
1975
  *entries() {
1715
1976
  for (const [key1, map2] of this.map1)
1716
1977
  for (const [key2, value] of map2)
1717
1978
  yield [key1, key2, value];
1718
1979
  }
1980
+ keysArray() {
1981
+ return [...this.keys()];
1982
+ }
1983
+ valuesArray() {
1984
+ return [...this.values()];
1985
+ }
1719
1986
  entriesArray() {
1720
1987
  return [...this.entries()];
1721
1988
  }
1989
+ *kvKeys() {
1990
+ for (const [key1, key2] of this.keys())
1991
+ yield [key1, key2];
1992
+ }
1993
+ *kvValues() {
1994
+ for (const el of this.values())
1995
+ yield el;
1996
+ }
1997
+ *kvEntries() {
1998
+ for (const [key1, key2, el] of this.entries())
1999
+ yield [[key1, key2], el];
2000
+ }
1722
2001
  *[Symbol.iterator]() {
1723
2002
  yield* this.entries();
1724
2003
  }
@@ -1872,32 +2151,23 @@ var Map3 = class _Map3 {
1872
2151
  }
1873
2152
  return count;
1874
2153
  }
2154
+ isEmpty() {
2155
+ return this.size === 0;
2156
+ }
1875
2157
  forEach(callbackfn, thisArg) {
1876
2158
  this.map1.forEach((map2, key1) => map2.forEach((map3, key2) => map3.forEach((value, key3) => callbackfn.call(thisArg, value, key1, key2, key3, this))));
1877
2159
  }
1878
- keys() {
1879
- function* gen(map1) {
1880
- for (const [key1, map2] of map1)
1881
- for (const [key2, map3] of map2)
1882
- for (const key3 of map3.keys())
1883
- yield [key1, key2, key3];
1884
- }
1885
- return gen(this.map1);
1886
- }
1887
- keysArray() {
1888
- return [...this.keys()];
1889
- }
1890
- values() {
1891
- function* gen(map1) {
1892
- for (const map2 of map1.values())
1893
- for (const map3 of map2.values())
1894
- for (const value of map3.values())
1895
- yield value;
1896
- }
1897
- return gen(this.map1);
2160
+ *keys() {
2161
+ for (const [key1, map2] of this.map1)
2162
+ for (const [key2, map3] of map2)
2163
+ for (const key3 of map3.keys())
2164
+ yield [key1, key2, key3];
1898
2165
  }
1899
- valuesArray() {
1900
- return [...this.values()];
2166
+ *values() {
2167
+ for (const map2 of this.map1.values())
2168
+ for (const map3 of map2.values())
2169
+ for (const value of map3.values())
2170
+ yield value;
1901
2171
  }
1902
2172
  *entries() {
1903
2173
  for (const [key1, map2] of this.map1)
@@ -1905,9 +2175,27 @@ var Map3 = class _Map3 {
1905
2175
  for (const [key3, value] of map3)
1906
2176
  yield [key1, key2, key3, value];
1907
2177
  }
2178
+ keysArray() {
2179
+ return [...this.keys()];
2180
+ }
2181
+ valuesArray() {
2182
+ return [...this.values()];
2183
+ }
1908
2184
  entriesArray() {
1909
2185
  return [...this.entries()];
1910
2186
  }
2187
+ *kvKeys() {
2188
+ for (const [key1, key2, key3] of this.keys())
2189
+ yield [key1, key2, key3];
2190
+ }
2191
+ *kvValues() {
2192
+ for (const el of this.values())
2193
+ yield el;
2194
+ }
2195
+ *kvEntries() {
2196
+ for (const [key1, key2, key3, el] of this.entries())
2197
+ yield [[key1, key2, key3], el];
2198
+ }
1911
2199
  *[Symbol.iterator]() {
1912
2200
  yield* this.entries();
1913
2201
  }
@@ -2010,19 +2298,91 @@ var Map3 = class _Map3 {
2010
2298
  return `Map3(${this.size}) { ${entries.join(", ")} }`;
2011
2299
  }
2012
2300
  };
2301
+
2302
+ // src/core/multi-container.ts
2303
+ var MultiContainer = class {
2304
+ constructor(base) {
2305
+ this.base = base;
2306
+ }
2307
+ isEmpty() {
2308
+ return this.base.isEmpty();
2309
+ }
2310
+ clear() {
2311
+ this.base.clear?.();
2312
+ }
2313
+ add(...keysAndValue) {
2314
+ const keys = keysAndValue.slice(0, -1);
2315
+ const value = keysAndValue[keysAndValue.length - 1];
2316
+ const arr = this.base.get(...keys);
2317
+ this.base.set(...[...keys, arr ? [...arr, value] : [value]]);
2318
+ return value;
2319
+ }
2320
+ remove(...keysAndValue) {
2321
+ const keys = keysAndValue.slice(0, -1);
2322
+ const value = keysAndValue[keysAndValue.length - 1];
2323
+ const arr = this.base.get(...keys);
2324
+ if (!arr) return false;
2325
+ const i = arr.indexOf(value);
2326
+ if (i === -1) return false;
2327
+ arr.splice(i, 1);
2328
+ if (arr.length === 0) this.base.delete(...keys);
2329
+ return true;
2330
+ }
2331
+ getAll(...keys) {
2332
+ return this.base.get(...keys) ?? [];
2333
+ }
2334
+ *iterAll(...keys) {
2335
+ yield* this.getAll(...keys);
2336
+ }
2337
+ *values() {
2338
+ for (const keys of this.keys()) {
2339
+ yield* this.getAll(...keys);
2340
+ }
2341
+ }
2342
+ *keys() {
2343
+ for (const keys of this.base.kvKeys()) {
2344
+ yield keys;
2345
+ }
2346
+ }
2347
+ *entries() {
2348
+ for (const keys of this.keys()) {
2349
+ const arr = this.getAll(...keys);
2350
+ if (arr.length > 0) yield [keys, arr];
2351
+ }
2352
+ }
2353
+ [Symbol.iterator]() {
2354
+ return this.entries();
2355
+ }
2356
+ toString() {
2357
+ const entries = [];
2358
+ for (const keys of this.keys()) {
2359
+ const arr = this.getAll(...keys);
2360
+ const keyStr = Array.isArray(keys) ? `[${keys.map((k) => JSON.stringify(k)).join(", ")}]` : `[${JSON.stringify(keys)}]`;
2361
+ const valuesStr = Array.isArray(arr) ? `[${arr.map((v) => JSON.stringify(v)).join(", ")}]` : "[]";
2362
+ entries.push(`${keyStr} => ${valuesStr}`);
2363
+ }
2364
+ return `MultiContainer{ ${entries.join(", ")} }`;
2365
+ }
2366
+ };
2367
+ function asMulti(base) {
2368
+ return new MultiContainer(base);
2369
+ }
2013
2370
  // Annotate the CommonJS export names for ESM import in node:
2014
2371
  0 && (module.exports = {
2015
2372
  Assert,
2016
2373
  Cookies,
2017
2374
  Device,
2375
+ IndexArray,
2018
2376
  LRUCache,
2019
2377
  Map1,
2020
2378
  Map2,
2021
2379
  Map3,
2380
+ MultiContainer,
2022
2381
  SignedIndexArray,
2023
2382
  SmallIntCache,
2024
2383
  Stack,
2025
2384
  Utils,
2026
- Vec2
2385
+ Vec2,
2386
+ asMulti
2027
2387
  });
2028
2388
  //# sourceMappingURL=index.js.map