@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.mjs 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
  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) => {
@@ -37,136 +37,175 @@ __export(arr_exports, {
37
37
  toArray: () => toArray
38
38
  });
39
39
 
40
- // src/utils/math/index.ts
41
- var math_exports = {};
42
- __export(math_exports, {
43
- avg: () => avg,
44
- calcNormal: () => calcNormal,
45
- clamp: () => clamp,
46
- cmp: () => cmp,
47
- interpolateCoord: () => interpolateCoord,
48
- interpolateY: () => interpolateY,
40
+ // src/utils/is/index.ts
41
+ var is_exports = {};
42
+ __export(is_exports, {
43
+ isArray: () => isArray,
44
+ isArrayOrUndefined: () => isArrayOrUndefined,
45
+ isBoolean: () => isBoolean,
46
+ isBooleanOrUndefined: () => isBooleanOrUndefined,
47
+ isEmptyArray: () => isEmptyArray,
48
+ isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined,
49
+ isEmptyString: () => isEmptyString,
50
+ isEmptyStringOrUndefined: () => isEmptyStringOrUndefined,
51
+ isEnumValue: () => isEnumValue,
52
+ isEnumValueOrUndefined: () => isEnumValueOrUndefined,
53
+ isFinite: () => isFinite2,
54
+ isFunction: () => isFunction,
55
+ isFunctionOrUndefined: () => isFunctionOrUndefined,
56
+ isInfinity: () => isInfinity,
49
57
  isInteger: () => isInteger,
50
- linearToDecibels: () => linearToDecibels,
51
- mod: () => mod,
52
- romanize: () => romanize,
53
- sum: () => sum,
54
- toOrdinalNumber: () => toOrdinalNumber
58
+ isIntegerBetween: () => isIntegerBetween,
59
+ isIntegerEq: () => isIntegerEq,
60
+ isIntegerGt: () => isIntegerGt,
61
+ isIntegerGte: () => isIntegerGte,
62
+ isIntegerLt: () => isIntegerLt,
63
+ isIntegerLte: () => isIntegerLte,
64
+ isIntegerOrUndefined: () => isIntegerOrUndefined,
65
+ isNaNValue: () => isNaNValue,
66
+ isNegInfinity: () => isNegInfinity,
67
+ isNonEmptyArray: () => isNonEmptyArray,
68
+ isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined,
69
+ isNonEmptyString: () => isNonEmptyString,
70
+ isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined,
71
+ isNull: () => isNull,
72
+ isNullish: () => isNullish,
73
+ isNumber: () => isNumber,
74
+ isNumberOrUndefined: () => isNumberOrUndefined,
75
+ isObject: () => isObject,
76
+ isObjectOrUndefined: () => isObjectOrUndefined,
77
+ isPosInfinity: () => isPosInfinity,
78
+ isString: () => isString,
79
+ isStringOrUndefined: () => isStringOrUndefined,
80
+ isUndefined: () => isUndefined
81
+ });
82
+
83
+ // src/utils/enum/index.ts
84
+ var enum_exports = {};
85
+ __export(enum_exports, {
86
+ getEnumValues: () => getEnumValues
55
87
  });
88
+ function getEnumValues(e) {
89
+ return Object.keys(e).filter((key) => Number.isNaN(Number(key))).map((key) => e[key]);
90
+ }
91
+
92
+ // src/utils/is/index.ts
93
+ function isUndefined(value) {
94
+ return value === void 0;
95
+ }
96
+ function isNull(value) {
97
+ return value === null;
98
+ }
99
+ function isNullish(value) {
100
+ return value === void 0 || value === null;
101
+ }
102
+ function isObject(value) {
103
+ return typeof value === "object" && value !== null && !isArray(value);
104
+ }
105
+ function isObjectOrUndefined(value) {
106
+ return value === void 0 || isObject(value);
107
+ }
108
+ function isArray(a) {
109
+ return !!a && Object.prototype.toString.call(a) === "[object Array]";
110
+ }
111
+ function isArrayOrUndefined(value) {
112
+ return value === void 0 || isArray(value);
113
+ }
114
+ function isEmptyArray(a) {
115
+ return isArray(a) && a.length === 0;
116
+ }
117
+ function isNonEmptyArray(a) {
118
+ return isArray(a) && a.length > 0;
119
+ }
120
+ function isEmptyArrayOrUndefined(a) {
121
+ return isArray(a) && a.length === 0 || a === void 0;
122
+ }
123
+ function isNonEmptyArrayOrUndefined(a) {
124
+ return isArray(a) && a.length > 0 || a === void 0;
125
+ }
126
+ function isString(value) {
127
+ return typeof value === "string";
128
+ }
129
+ function isEmptyString(value) {
130
+ return typeof value === "string" && value.length === 0;
131
+ }
132
+ function isNonEmptyString(value) {
133
+ return typeof value === "string" && value.length > 0;
134
+ }
135
+ function isStringOrUndefined(value) {
136
+ return value === void 0 || typeof value === "string";
137
+ }
138
+ function isEmptyStringOrUndefined(value) {
139
+ return typeof value === "string" && value.length === 0 || value === void 0;
140
+ }
141
+ function isNonEmptyStringOrUndefined(value) {
142
+ return typeof value === "string" && value.length > 0 || value === void 0;
143
+ }
144
+ function isBoolean(value) {
145
+ return typeof value === "boolean";
146
+ }
147
+ function isBooleanOrUndefined(value) {
148
+ return value === void 0 || typeof value === "boolean";
149
+ }
150
+ function isFunction(value) {
151
+ return typeof value === "function";
152
+ }
153
+ function isFunctionOrUndefined(value) {
154
+ return value === void 0 || typeof value === "function";
155
+ }
156
+ function isEnumValue(value, enumObj, name = "value") {
157
+ return getEnumValues(enumObj).some((v) => v === value);
158
+ }
159
+ function isEnumValueOrUndefined(value, enumObj, name = "value") {
160
+ return value === void 0 || getEnumValues(enumObj).some((v) => v === value);
161
+ }
162
+ function isNumber(value) {
163
+ return typeof value === "number";
164
+ }
165
+ function isNumberOrUndefined(value) {
166
+ return typeof value === "number" || value === void 0;
167
+ }
168
+ function isFinite2(value) {
169
+ return typeof value === "number" && Number.isFinite(value);
170
+ }
56
171
  function isInteger(n) {
57
- return typeof n === "number" && isFinite(n) && n === Math.trunc(n);
172
+ return typeof n === "number" && isFinite2(n) && n === Math.trunc(n);
58
173
  }
59
- function linearToDecibels(linearVolume) {
60
- if (!isFinite(linearVolume)) {
61
- throw new Error("linearToDecibel: Invalid linearVolume = " + linearVolume);
62
- } else if (linearVolume <= 0) {
63
- return -Infinity;
64
- } else {
65
- return 20 * Math.log10(linearVolume);
66
- }
174
+ function isIntegerOrUndefined(n) {
175
+ return typeof n === "number" && isFinite2(n) && n === Math.trunc(n) || n === void 0;
67
176
  }
68
- function mod(m, n) {
69
- return (m % n + n) % n;
177
+ function isIntegerEq(value, compareTo) {
178
+ return isInteger(value) && value === compareTo;
70
179
  }
71
- function romanize(n) {
72
- if (!isInteger(n) || n < 0) {
73
- throw new Error("romanize: Invalid n = " + n);
74
- }
75
- var digits = String(+n).split("");
76
- var key = [
77
- "",
78
- "C",
79
- "CC",
80
- "CCC",
81
- "CD",
82
- "D",
83
- "DC",
84
- "DCC",
85
- "DCCC",
86
- "CM",
87
- "",
88
- "X",
89
- "XX",
90
- "XXX",
91
- "XL",
92
- "L",
93
- "LX",
94
- "LXX",
95
- "LXXX",
96
- "XC",
97
- "",
98
- "I",
99
- "II",
100
- "III",
101
- "IV",
102
- "V",
103
- "VI",
104
- "VII",
105
- "VIII",
106
- "IX"
107
- ];
108
- var roman = "", i = 3;
109
- while (i--) roman = (key[+digits.pop() + i * 10] || "") + roman;
110
- return Array(+digits.join("") + 1).join("M") + roman;
180
+ function isIntegerGt(value, compareTo) {
181
+ return isInteger(value) && value > compareTo;
111
182
  }
112
- function toOrdinalNumber(n) {
113
- if (!isInteger(n)) {
114
- throw new Error("toOrdinalNumber: Invalid n = " + n);
115
- }
116
- const nStr = n.toString();
117
- const lastDigit = Number(nStr.charAt(nStr.length - 1));
118
- if (n === 1 || n >= 20 && lastDigit === 1) {
119
- return nStr + "st";
120
- } else if (n === 2 || n >= 20 && lastDigit === 2) {
121
- return nStr + "nd";
122
- } else if (n === 3 || n >= 20 && lastDigit === 3) {
123
- return nStr + "rd";
124
- } else {
125
- return nStr + "th";
126
- }
183
+ function isIntegerGte(value, compareTo) {
184
+ return isInteger(value) && value >= compareTo;
127
185
  }
128
- function interpolateCoord(startX, startY, endX, endY, t) {
129
- return {
130
- x: startX + (endX - startX) * t,
131
- y: startY + (endY - startY) * t
132
- };
186
+ function isIntegerLt(value, compareTo) {
187
+ return isInteger(value) && value < compareTo;
133
188
  }
134
- function interpolateY(startX, startY, endX, endY, x) {
135
- let t = (x - startX) / (endX - startX);
136
- return startY + (endY - startY) * t;
189
+ function isIntegerLte(value, compareTo) {
190
+ return isInteger(value) && value <= compareTo;
137
191
  }
138
- function clamp(num, min, max) {
139
- return Math.min(Math.max(num, min), max);
192
+ function isIntegerBetween(value, min, max) {
193
+ return isInteger(value) && value >= min && value <= max;
140
194
  }
141
- function calcNormal(x1, y1, x2, y2) {
142
- let dx = x2 - x1;
143
- let dy = y2 - y1;
144
- let nx = -dy;
145
- let ny = dx;
146
- let len = Math.sqrt(nx * nx + ny * ny);
147
- if (len > 0) {
148
- nx /= len;
149
- ny /= len;
150
- } else {
151
- nx = 0;
152
- ny = 1;
153
- }
154
- return { nx, ny };
195
+ function isNaNValue(value) {
196
+ return typeof value === "number" && Number.isNaN(value);
155
197
  }
156
- function sum(arr) {
157
- return arr.reduce((prev, cur) => cur + prev, 0);
198
+ function isInfinity(value) {
199
+ return typeof value === "number" && Math.abs(value) === Infinity;
158
200
  }
159
- function avg(...values) {
160
- return sum(values) / values.length;
201
+ function isPosInfinity(value) {
202
+ return typeof value === "number" && value === Infinity;
161
203
  }
162
- function cmp(a, b) {
163
- return a < b ? -1 : a > b ? 1 : 0;
204
+ function isNegInfinity(value) {
205
+ return typeof value === "number" && value === -Infinity;
164
206
  }
165
207
 
166
208
  // src/utils/arr/index.ts
167
- function isArray(a) {
168
- return !!a && Object.prototype.toString.call(a) === "[object Array]";
169
- }
170
209
  function toArray(a) {
171
210
  return isArray(a) ? a : [a];
172
211
  }
@@ -253,15 +292,6 @@ __export(dom_exports, {
253
292
  styleLayoutChanged: () => styleLayoutChanged
254
293
  });
255
294
 
256
- // src/utils/enum/index.ts
257
- var enum_exports = {};
258
- __export(enum_exports, {
259
- getEnumValues: () => getEnumValues
260
- });
261
- function getEnumValues(e) {
262
- return Object.keys(e).filter((key) => Number.isNaN(Number(key))).map((key) => e[key]);
263
- }
264
-
265
295
  // src/modules/assert.ts
266
296
  var Assert;
267
297
  ((Assert2) => {
@@ -681,172 +711,139 @@ function getCanvasTextWidth(text, font) {
681
711
  return ctx.measureText(text).width;
682
712
  }
683
713
 
684
- // src/utils/is/index.ts
685
- var is_exports = {};
686
- __export(is_exports, {
687
- isArray: () => isArray2,
688
- isArrayOrUndefined: () => isArrayOrUndefined,
689
- isBoolean: () => isBoolean,
690
- isBooleanOrUndefined: () => isBooleanOrUndefined,
691
- isEmptyArray: () => isEmptyArray,
692
- isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined,
693
- isEmptyString: () => isEmptyString,
694
- isEmptyStringOrUndefined: () => isEmptyStringOrUndefined,
695
- isEnumValue: () => isEnumValue,
696
- isEnumValueOrUndefined: () => isEnumValueOrUndefined,
697
- isFinite: () => isFinite2,
698
- isFunction: () => isFunction,
699
- isFunctionOrUndefined: () => isFunctionOrUndefined,
700
- isInfinity: () => isInfinity,
701
- isInteger: () => isInteger2,
702
- isIntegerBetween: () => isIntegerBetween,
703
- isIntegerEq: () => isIntegerEq,
704
- isIntegerGt: () => isIntegerGt,
705
- isIntegerGte: () => isIntegerGte,
706
- isIntegerLt: () => isIntegerLt,
707
- isIntegerLte: () => isIntegerLte,
708
- isIntegerOrUndefined: () => isIntegerOrUndefined,
709
- isNaNValue: () => isNaNValue,
710
- isNegInfinity: () => isNegInfinity,
711
- isNonEmptyArray: () => isNonEmptyArray,
712
- isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined,
713
- isNonEmptyString: () => isNonEmptyString,
714
- isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined,
715
- isNull: () => isNull,
716
- isNullish: () => isNullish,
717
- isNumber: () => isNumber,
718
- isNumberOrUndefined: () => isNumberOrUndefined,
719
- isObject: () => isObject,
720
- isObjectOrUndefined: () => isObjectOrUndefined,
721
- isPosInfinity: () => isPosInfinity,
722
- isString: () => isString,
723
- isStringOrUndefined: () => isStringOrUndefined,
724
- isUndefined: () => isUndefined
714
+ // src/utils/map/index.ts
715
+ var map_exports = {};
716
+ __export(map_exports, {
717
+ getMapKeys: () => getMapKeys
725
718
  });
726
- function isUndefined(value) {
727
- return value === void 0;
728
- }
729
- function isNull(value) {
730
- return value === null;
731
- }
732
- function isNullish(value) {
733
- return value === void 0 || value === null;
734
- }
735
- function isObject(value) {
736
- return typeof value === "object" && value !== null && !isArray2(value);
737
- }
738
- function isObjectOrUndefined(value) {
739
- return value === void 0 || isObject(value);
740
- }
741
- function isArray2(a) {
742
- return !!a && Object.prototype.toString.call(a) === "[object Array]";
743
- }
744
- function isArrayOrUndefined(value) {
745
- return value === void 0 || isArray2(value);
746
- }
747
- function isEmptyArray(a) {
748
- return isArray2(a) && a.length === 0;
749
- }
750
- function isNonEmptyArray(a) {
751
- return isArray2(a) && a.length > 0;
752
- }
753
- function isEmptyArrayOrUndefined(a) {
754
- return isArray2(a) && a.length === 0 || a === void 0;
755
- }
756
- function isNonEmptyArrayOrUndefined(a) {
757
- return isArray2(a) && a.length > 0 || a === void 0;
758
- }
759
- function isString(value) {
760
- return typeof value === "string";
761
- }
762
- function isEmptyString(value) {
763
- return typeof value === "string" && value.length === 0;
764
- }
765
- function isNonEmptyString(value) {
766
- return typeof value === "string" && value.length > 0;
767
- }
768
- function isStringOrUndefined(value) {
769
- return value === void 0 || typeof value === "string";
770
- }
771
- function isEmptyStringOrUndefined(value) {
772
- return typeof value === "string" && value.length === 0 || value === void 0;
773
- }
774
- function isNonEmptyStringOrUndefined(value) {
775
- return typeof value === "string" && value.length > 0 || value === void 0;
776
- }
777
- function isBoolean(value) {
778
- return typeof value === "boolean";
779
- }
780
- function isBooleanOrUndefined(value) {
781
- return value === void 0 || typeof value === "boolean";
782
- }
783
- function isFunction(value) {
784
- return typeof value === "function";
785
- }
786
- function isFunctionOrUndefined(value) {
787
- return value === void 0 || typeof value === "function";
788
- }
789
- function isEnumValue(value, enumObj, name = "value") {
790
- return getEnumValues(enumObj).some((v) => v === value);
791
- }
792
- function isEnumValueOrUndefined(value, enumObj, name = "value") {
793
- return value === void 0 || getEnumValues(enumObj).some((v) => v === value);
794
- }
795
- function isNumber(value) {
796
- return typeof value === "number";
797
- }
798
- function isNumberOrUndefined(value) {
799
- return typeof value === "number" || value === void 0;
800
- }
801
- function isFinite2(value) {
802
- return typeof value === "number" && Number.isFinite(value);
803
- }
804
- function isInteger2(n) {
805
- return typeof n === "number" && isFinite2(n) && n === Math.trunc(n);
806
- }
807
- function isIntegerOrUndefined(n) {
808
- return typeof n === "number" && isFinite2(n) && n === Math.trunc(n) || n === void 0;
719
+ function getMapKeys(map) {
720
+ let keys = [];
721
+ map.forEach((value, key) => keys.push(key));
722
+ return keys;
809
723
  }
810
- function isIntegerEq(value, compareTo) {
811
- return isInteger2(value) && value === compareTo;
724
+
725
+ // src/utils/math/index.ts
726
+ var math_exports = {};
727
+ __export(math_exports, {
728
+ avg: () => avg,
729
+ calcNormal: () => calcNormal,
730
+ clamp: () => clamp,
731
+ cmp: () => cmp,
732
+ interpolateCoord: () => interpolateCoord,
733
+ interpolateY: () => interpolateY,
734
+ isInteger: () => isInteger,
735
+ isNumber: () => isNumber,
736
+ linearToDecibels: () => linearToDecibels,
737
+ mod: () => mod,
738
+ romanize: () => romanize,
739
+ sum: () => sum,
740
+ toOrdinalNumber: () => toOrdinalNumber
741
+ });
742
+ function linearToDecibels(linearVolume) {
743
+ if (!isFinite(linearVolume)) {
744
+ throw new Error("linearToDecibel: Invalid linearVolume = " + linearVolume);
745
+ } else if (linearVolume <= 0) {
746
+ return -Infinity;
747
+ } else {
748
+ return 20 * Math.log10(linearVolume);
749
+ }
812
750
  }
813
- function isIntegerGt(value, compareTo) {
814
- return isInteger2(value) && value > compareTo;
751
+ function mod(m, n) {
752
+ return (m % n + n) % n;
815
753
  }
816
- function isIntegerGte(value, compareTo) {
817
- return isInteger2(value) && value >= compareTo;
754
+ function romanize(n) {
755
+ if (!isInteger(n) || n < 0) {
756
+ throw new Error("romanize: Invalid n = " + n);
757
+ }
758
+ var digits = String(+n).split("");
759
+ var key = [
760
+ "",
761
+ "C",
762
+ "CC",
763
+ "CCC",
764
+ "CD",
765
+ "D",
766
+ "DC",
767
+ "DCC",
768
+ "DCCC",
769
+ "CM",
770
+ "",
771
+ "X",
772
+ "XX",
773
+ "XXX",
774
+ "XL",
775
+ "L",
776
+ "LX",
777
+ "LXX",
778
+ "LXXX",
779
+ "XC",
780
+ "",
781
+ "I",
782
+ "II",
783
+ "III",
784
+ "IV",
785
+ "V",
786
+ "VI",
787
+ "VII",
788
+ "VIII",
789
+ "IX"
790
+ ];
791
+ var roman = "", i = 3;
792
+ while (i--) roman = (key[+digits.pop() + i * 10] || "") + roman;
793
+ return Array(+digits.join("") + 1).join("M") + roman;
818
794
  }
819
- function isIntegerLt(value, compareTo) {
820
- return isInteger2(value) && value < compareTo;
795
+ function toOrdinalNumber(n) {
796
+ if (!isInteger(n)) {
797
+ throw new Error("toOrdinalNumber: Invalid n = " + n);
798
+ }
799
+ const nStr = n.toString();
800
+ const lastDigit = Number(nStr.charAt(nStr.length - 1));
801
+ if (n === 1 || n >= 20 && lastDigit === 1) {
802
+ return nStr + "st";
803
+ } else if (n === 2 || n >= 20 && lastDigit === 2) {
804
+ return nStr + "nd";
805
+ } else if (n === 3 || n >= 20 && lastDigit === 3) {
806
+ return nStr + "rd";
807
+ } else {
808
+ return nStr + "th";
809
+ }
821
810
  }
822
- function isIntegerLte(value, compareTo) {
823
- return isInteger2(value) && value <= compareTo;
811
+ function interpolateCoord(startX, startY, endX, endY, t) {
812
+ return {
813
+ x: startX + (endX - startX) * t,
814
+ y: startY + (endY - startY) * t
815
+ };
824
816
  }
825
- function isIntegerBetween(value, min, max) {
826
- return isInteger2(value) && value >= min && value <= max;
817
+ function interpolateY(startX, startY, endX, endY, x) {
818
+ let t = (x - startX) / (endX - startX);
819
+ return startY + (endY - startY) * t;
827
820
  }
828
- function isNaNValue(value) {
829
- return typeof value === "number" && Number.isNaN(value);
821
+ function clamp(num, min, max) {
822
+ return Math.min(Math.max(num, min), max);
830
823
  }
831
- function isInfinity(value) {
832
- return typeof value === "number" && Math.abs(value) === Infinity;
824
+ function calcNormal(x1, y1, x2, y2) {
825
+ let dx = x2 - x1;
826
+ let dy = y2 - y1;
827
+ let nx = -dy;
828
+ let ny = dx;
829
+ let len = Math.sqrt(nx * nx + ny * ny);
830
+ if (len > 0) {
831
+ nx /= len;
832
+ ny /= len;
833
+ } else {
834
+ nx = 0;
835
+ ny = 1;
836
+ }
837
+ return { nx, ny };
833
838
  }
834
- function isPosInfinity(value) {
835
- return typeof value === "number" && value === Infinity;
839
+ function sum(arr) {
840
+ return arr.reduce((prev, cur) => cur + prev, 0);
836
841
  }
837
- function isNegInfinity(value) {
838
- return typeof value === "number" && value === -Infinity;
842
+ function avg(...values) {
843
+ return sum(values) / values.length;
839
844
  }
840
-
841
- // src/utils/map/index.ts
842
- var map_exports = {};
843
- __export(map_exports, {
844
- getMapKeys: () => getMapKeys
845
- });
846
- function getMapKeys(map) {
847
- let keys = [];
848
- map.forEach((value, key) => keys.push(key));
849
- return keys;
845
+ function cmp(a, b) {
846
+ return a < b ? -1 : a > b ? 1 : 0;
850
847
  }
851
848
 
852
849
  // src/utils/obj/index.ts
@@ -854,13 +851,10 @@ var obj_exports = {};
854
851
  __export(obj_exports, {
855
852
  deepEqual: () => deepEqual,
856
853
  hasProperties: () => hasProperties,
857
- isObject: () => isObject2
854
+ isObject: () => isObject
858
855
  });
859
- function isObject2(obj) {
860
- return typeof obj === "object" && obj !== null && !isArray(obj);
861
- }
862
856
  function hasProperties(obj, props) {
863
- return isObject2(obj) && props.every((p) => p in obj);
857
+ return isObject(obj) && props.every((p) => p in obj);
864
858
  }
865
859
  function deepEqual(a, b) {
866
860
  if (a === b) return true;
@@ -887,6 +881,7 @@ __export(str_exports, {
887
881
  charCount: () => charCount,
888
882
  chunkString: () => chunkString,
889
883
  insertAt: () => insertAt,
884
+ isString: () => isString,
890
885
  makeSentenceFromPascal: () => makeSentenceFromPascal,
891
886
  removeAt: () => removeAt,
892
887
  repeatString: () => repeatString,
@@ -1162,103 +1157,316 @@ var LRUCache = class {
1162
1157
  if (this.size >= this.capacity) {
1163
1158
  this.evict();
1164
1159
  }
1165
- this.cache[key] = value;
1166
- this.addToTail(key);
1167
- this.size++;
1160
+ this.cache[key] = value;
1161
+ this.addToTail(key);
1162
+ this.size++;
1163
+ }
1164
+ // Marks a key as most recently used
1165
+ touch(key) {
1166
+ if (this.tail === key) return;
1167
+ this.removeKey(key);
1168
+ this.addToTail(key);
1169
+ }
1170
+ // Evicts the least recently used item (at the head)
1171
+ evict() {
1172
+ if (this.head !== null) {
1173
+ const oldestKey = this.head;
1174
+ this.removeKey(oldestKey);
1175
+ delete this.cache[oldestKey];
1176
+ this.size--;
1177
+ }
1178
+ }
1179
+ // Removes a key from the linked list
1180
+ removeKey(key) {
1181
+ const prevKey = this.prev[key];
1182
+ const nextKey = this.next[key];
1183
+ if (prevKey !== void 0) {
1184
+ this.next[prevKey] = nextKey;
1185
+ } else {
1186
+ this.head = nextKey ?? null;
1187
+ }
1188
+ if (nextKey !== void 0) {
1189
+ this.prev[nextKey] = prevKey;
1190
+ } else {
1191
+ this.tail = prevKey ?? null;
1192
+ }
1193
+ delete this.prev[key];
1194
+ delete this.next[key];
1195
+ }
1196
+ // Adds a key to the tail (most recently used position)
1197
+ addToTail(key) {
1198
+ if (this.tail !== null) {
1199
+ this.next[this.tail] = key;
1200
+ this.prev[key] = this.tail;
1201
+ } else {
1202
+ this.head = key;
1203
+ }
1204
+ this.tail = key;
1205
+ }
1206
+ };
1207
+
1208
+ // src/core/small-int-cache.ts
1209
+ var SmallIntCache = class {
1210
+ // for keys < 0
1211
+ constructor() {
1212
+ __publicField(this, "pos");
1213
+ // for keys >= 0
1214
+ __publicField(this, "neg");
1215
+ this.pos = [];
1216
+ this.neg = [];
1217
+ }
1218
+ set(key, value) {
1219
+ if (!isInteger(key)) {
1220
+ throw new Error("Key must be an integer");
1221
+ } else if (key >= 0) {
1222
+ this.pos[key] = value;
1223
+ } else {
1224
+ this.neg[-key - 1] = value;
1225
+ }
1226
+ }
1227
+ get(key) {
1228
+ if (!isInteger(key)) {
1229
+ throw new Error("Key must be an integer");
1230
+ } else if (key >= 0) {
1231
+ return this.pos[key];
1232
+ } else {
1233
+ return this.neg[-key - 1];
1234
+ }
1235
+ }
1236
+ has(key) {
1237
+ if (!isInteger(key)) {
1238
+ return false;
1239
+ } else if (key >= 0) {
1240
+ return key in this.pos;
1241
+ } else {
1242
+ return -key - 1 in this.neg;
1243
+ }
1244
+ }
1245
+ delete(key) {
1246
+ if (!isInteger(key)) {
1247
+ return;
1248
+ } else if (key >= 0) {
1249
+ delete this.pos[key];
1250
+ } else {
1251
+ delete this.neg[-key - 1];
1252
+ }
1253
+ }
1254
+ clear() {
1255
+ this.pos = [];
1256
+ this.neg = [];
1257
+ }
1258
+ };
1259
+
1260
+ // src/core/index-array.ts
1261
+ var IndexArray = class _IndexArray {
1262
+ constructor(entries) {
1263
+ // for indexes >= 0
1264
+ __publicField(this, "posEl");
1265
+ __publicField(this, "hasPos");
1266
+ // number of elems
1267
+ __publicField(this, "elCount");
1268
+ if (entries instanceof _IndexArray) {
1269
+ this.posEl = entries.posEl.slice();
1270
+ this.hasPos = entries.hasPos.slice();
1271
+ this.elCount = entries.elCount;
1272
+ } else {
1273
+ this.posEl = [];
1274
+ this.hasPos = [];
1275
+ this.elCount = 0;
1276
+ if (entries) {
1277
+ for (const [id, el] of entries) {
1278
+ this.set(id, el);
1279
+ }
1280
+ }
1281
+ }
1282
+ }
1283
+ static toNegIndex(id) {
1284
+ return -id - 1;
1285
+ }
1286
+ static validateIndex(id) {
1287
+ if (!isIntegerGte(id, 0)) throw new Error(`Invalid index ${id} - must be an integer >= 0!`);
1288
+ return id;
1289
+ }
1290
+ get posLen() {
1291
+ return this.hasPos.length;
1292
+ }
1293
+ get size() {
1294
+ return this.elCount;
1295
+ }
1296
+ isEmpty() {
1297
+ return this.size === 0;
1298
+ }
1299
+ has(id) {
1300
+ _IndexArray.validateIndex(id);
1301
+ return this.hasPos[id] === true;
1302
+ }
1303
+ set(id, el) {
1304
+ _IndexArray.validateIndex(id);
1305
+ if (this.hasPos[id] !== true) this.elCount++;
1306
+ this.posEl[id] = el;
1307
+ this.hasPos[id] = true;
1308
+ }
1309
+ get(id) {
1310
+ _IndexArray.validateIndex(id);
1311
+ return this.hasPos[id] ? this.posEl[id] : void 0;
1312
+ }
1313
+ getOrDefault(id, defaultValue) {
1314
+ return this.get(id) ?? defaultValue;
1315
+ }
1316
+ getOrCreate(id, creatorOrValue) {
1317
+ if (!this.has(id)) {
1318
+ const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
1319
+ this.set(id, value);
1320
+ return value;
1321
+ }
1322
+ return this.get(id);
1323
+ }
1324
+ delete(id) {
1325
+ _IndexArray.validateIndex(id);
1326
+ if (!this.hasPos[id]) return false;
1327
+ this.posEl[id] = void 0;
1328
+ this.hasPos[id] = false;
1329
+ this.elCount--;
1330
+ return true;
1331
+ }
1332
+ clear() {
1333
+ this.posEl = [];
1334
+ this.hasPos = [];
1335
+ this.elCount = 0;
1336
+ }
1337
+ forEach(callbackfn, thisArg) {
1338
+ for (const [id, el] of this.entries()) {
1339
+ callbackfn.call(thisArg, el, id, this);
1340
+ }
1341
+ }
1342
+ *indices() {
1343
+ for (let id = 0; id < this.posLen; id++) {
1344
+ if (this.hasPos[id]) yield id;
1345
+ }
1346
+ }
1347
+ *values() {
1348
+ for (let id = 0; id < this.posLen; id++) {
1349
+ if (this.hasPos[id]) yield this.posEl[id];
1350
+ }
1351
+ }
1352
+ *entries() {
1353
+ for (let id = 0; id < this.posLen; id++) {
1354
+ if (this.hasPos[id]) yield [id, this.posEl[id]];
1355
+ }
1356
+ }
1357
+ indicesArray() {
1358
+ return [...this.indices()];
1359
+ }
1360
+ valuesArray() {
1361
+ return [...this.values()];
1362
+ }
1363
+ entriesArray() {
1364
+ return [...this.entries()];
1365
+ }
1366
+ *kvKeys() {
1367
+ for (const id of this.indices()) {
1368
+ yield [id];
1369
+ }
1168
1370
  }
1169
- // Marks a key as most recently used
1170
- touch(key) {
1171
- if (this.tail === key) return;
1172
- this.removeKey(key);
1173
- this.addToTail(key);
1371
+ *kvValues() {
1372
+ for (const el of this.values()) {
1373
+ yield el;
1374
+ }
1174
1375
  }
1175
- // Evicts the least recently used item (at the head)
1176
- evict() {
1177
- if (this.head !== null) {
1178
- const oldestKey = this.head;
1179
- this.removeKey(oldestKey);
1180
- delete this.cache[oldestKey];
1181
- this.size--;
1376
+ *kvEntries() {
1377
+ for (const [id, el] of this.entries()) {
1378
+ yield [[id], el];
1182
1379
  }
1183
1380
  }
1184
- // Removes a key from the linked list
1185
- removeKey(key) {
1186
- const prevKey = this.prev[key];
1187
- const nextKey = this.next[key];
1188
- if (prevKey !== void 0) {
1189
- this.next[prevKey] = nextKey;
1190
- } else {
1191
- this.head = nextKey ?? null;
1381
+ *[Symbol.iterator]() {
1382
+ yield* this.entries();
1383
+ }
1384
+ clone() {
1385
+ return new _IndexArray(this);
1386
+ }
1387
+ merge(other, conflictResolver) {
1388
+ for (const [id, value] of other.entries()) {
1389
+ if (this.has(id) && conflictResolver) {
1390
+ this.set(id, conflictResolver(this.get(id), value, id));
1391
+ } else {
1392
+ this.set(id, value);
1393
+ }
1192
1394
  }
1193
- if (nextKey !== void 0) {
1194
- this.prev[nextKey] = prevKey;
1195
- } else {
1196
- this.tail = prevKey ?? null;
1395
+ return this;
1396
+ }
1397
+ some(fn) {
1398
+ for (const [id, el] of this.entries()) {
1399
+ if (fn(el, id)) return true;
1197
1400
  }
1198
- delete this.prev[key];
1199
- delete this.next[key];
1401
+ return false;
1200
1402
  }
1201
- // Adds a key to the tail (most recently used position)
1202
- addToTail(key) {
1203
- if (this.tail !== null) {
1204
- this.next[this.tail] = key;
1205
- this.prev[key] = this.tail;
1206
- } else {
1207
- this.head = key;
1403
+ every(fn) {
1404
+ for (const [id, el] of this.entries()) {
1405
+ if (!fn(el, id)) return false;
1208
1406
  }
1209
- this.tail = key;
1407
+ return true;
1210
1408
  }
1211
- };
1212
-
1213
- // src/core/small-int-cache.ts
1214
- var SmallIntCache = class {
1215
- // for keys < 0
1216
- constructor() {
1217
- __publicField(this, "pos");
1218
- // for keys >= 0
1219
- __publicField(this, "neg");
1220
- this.pos = [];
1221
- this.neg = [];
1409
+ filter(fn) {
1410
+ let result = new _IndexArray();
1411
+ for (const [id, el] of this.entries()) {
1412
+ if (fn(el, id)) result.set(id, el);
1413
+ }
1414
+ return result;
1222
1415
  }
1223
- set(key, value) {
1224
- if (!isInteger(key)) {
1225
- throw new Error("Key must be an integer");
1226
- } else if (key >= 0) {
1227
- this.pos[key] = value;
1416
+ reduce(fn, init) {
1417
+ let iterator = this.entries();
1418
+ let first = iterator.next();
1419
+ if (first.done) {
1420
+ if (arguments.length < 2) {
1421
+ throw new TypeError("Reduce of empty IndexArray with no initial value!");
1422
+ }
1423
+ return init;
1424
+ }
1425
+ let acc;
1426
+ let start;
1427
+ if (arguments.length < 2) {
1428
+ acc = first.value[1];
1429
+ start = iterator.next();
1228
1430
  } else {
1229
- this.neg[-key - 1] = value;
1431
+ acc = init;
1432
+ start = first;
1433
+ }
1434
+ for (let current = start; !current.done; current = iterator.next()) {
1435
+ const [id, el] = current.value;
1436
+ acc = fn(acc, el, id);
1230
1437
  }
1438
+ return acc;
1231
1439
  }
1232
- get(key) {
1233
- if (!isInteger(key)) {
1234
- throw new Error("Key must be an integer");
1235
- } else if (key >= 0) {
1236
- return this.pos[key];
1237
- } else {
1238
- return this.neg[-key - 1];
1440
+ mapToArray(fn) {
1441
+ let result = [];
1442
+ for (const [id, el] of this.entries()) {
1443
+ result.push(fn(el, id));
1239
1444
  }
1445
+ return result;
1240
1446
  }
1241
- has(key) {
1242
- if (!isInteger(key)) {
1243
- return false;
1244
- } else if (key >= 0) {
1245
- return key in this.pos;
1246
- } else {
1247
- return -key - 1 in this.neg;
1447
+ map(fn) {
1448
+ let result = new _IndexArray();
1449
+ for (const [id, el] of this.entries()) {
1450
+ result.set(id, fn(el, id));
1248
1451
  }
1452
+ return result;
1249
1453
  }
1250
- delete(key) {
1251
- if (!isInteger(key)) {
1252
- return;
1253
- } else if (key >= 0) {
1254
- delete this.pos[key];
1255
- } else {
1256
- delete this.neg[-key - 1];
1454
+ equals(other, eq) {
1455
+ if (this.size !== other.size) return false;
1456
+ eq ?? (eq = (a, b) => a === b);
1457
+ const posLen = Math.max(this.posLen, other.posLen);
1458
+ for (let i = 0; i < posLen; ++i) {
1459
+ const hasA = this.hasPos[i];
1460
+ const hasB = other.hasPos[i];
1461
+ if (hasA !== hasB) return false;
1462
+ if (hasA && !eq(this.posEl[i], other.posEl[i])) return false;
1257
1463
  }
1464
+ return true;
1258
1465
  }
1259
- clear() {
1260
- this.pos = [];
1261
- this.neg = [];
1466
+ toString() {
1467
+ if (this.size === 0) return `IndexArray[ ]`;
1468
+ const entries = this.entriesArray().map(([id, el]) => `${id}: ${el}`).join(", ");
1469
+ return `IndexArray[ ${entries} ]`;
1262
1470
  }
1263
1471
  };
1264
1472
 
@@ -1295,38 +1503,50 @@ var SignedIndexArray = class _SignedIndexArray {
1295
1503
  static toNegIndex(id) {
1296
1504
  return -id - 1;
1297
1505
  }
1506
+ static validateIndex(id) {
1507
+ if (!isInteger(id)) throw new Error(`Invalid index ${id} - must be an integer!`);
1508
+ return id;
1509
+ }
1298
1510
  get size() {
1299
1511
  return this.elCount;
1300
1512
  }
1513
+ isEmpty() {
1514
+ return this.size === 0;
1515
+ }
1516
+ get posLen() {
1517
+ return this.hasPos.length;
1518
+ }
1519
+ get negLen() {
1520
+ return this.hasNeg.length;
1521
+ }
1301
1522
  has(id) {
1302
- if (!isInteger(id)) {
1303
- return false;
1304
- } else if (id >= 0) {
1523
+ _SignedIndexArray.validateIndex(id);
1524
+ if (id >= 0) {
1305
1525
  return this.hasPos[id] === true;
1306
1526
  } else {
1307
1527
  return this.hasNeg[_SignedIndexArray.toNegIndex(id)] === true;
1308
1528
  }
1309
1529
  }
1310
1530
  set(id, el) {
1311
- if (!isInteger(id)) {
1312
- throw new Error("Index must be an integer");
1313
- } else if (id >= 0) {
1531
+ _SignedIndexArray.validateIndex(id);
1532
+ if (id >= 0) {
1314
1533
  if (this.hasPos[id] !== true) this.elCount++;
1315
1534
  this.posEl[id] = el;
1316
1535
  this.hasPos[id] = true;
1317
1536
  } else {
1318
- if (this.hasNeg[_SignedIndexArray.toNegIndex(id)] !== true) this.elCount++;
1319
- this.negEl[_SignedIndexArray.toNegIndex(id)] = el;
1320
- this.hasNeg[_SignedIndexArray.toNegIndex(id)] = true;
1537
+ let negId = _SignedIndexArray.toNegIndex(id);
1538
+ if (this.hasNeg[negId] !== true) this.elCount++;
1539
+ this.negEl[negId] = el;
1540
+ this.hasNeg[negId] = true;
1321
1541
  }
1322
1542
  }
1323
1543
  get(id) {
1324
- if (!isInteger(id)) {
1325
- throw new Error("Index must be an integer");
1326
- } else if (id >= 0) {
1544
+ _SignedIndexArray.validateIndex(id);
1545
+ if (id >= 0) {
1327
1546
  return this.hasPos[id] ? this.posEl[id] : void 0;
1328
1547
  } else {
1329
- return this.hasNeg[_SignedIndexArray.toNegIndex(id)] ? this.negEl[_SignedIndexArray.toNegIndex(id)] : void 0;
1548
+ let negId = _SignedIndexArray.toNegIndex(id);
1549
+ return this.hasNeg[negId] ? this.negEl[negId] : void 0;
1330
1550
  }
1331
1551
  }
1332
1552
  getOrDefault(id, defaultValue) {
@@ -1341,7 +1561,7 @@ var SignedIndexArray = class _SignedIndexArray {
1341
1561
  return this.get(id);
1342
1562
  }
1343
1563
  delete(id) {
1344
- if (!isInteger(id)) return false;
1564
+ _SignedIndexArray.validateIndex(id);
1345
1565
  const isPos = id >= 0;
1346
1566
  const arr = isPos ? this.posEl : this.negEl;
1347
1567
  const has = isPos ? this.hasPos : this.hasNeg;
@@ -1364,45 +1584,54 @@ var SignedIndexArray = class _SignedIndexArray {
1364
1584
  callbackfn.call(thisArg, el, id, this);
1365
1585
  }
1366
1586
  }
1367
- indices() {
1368
- function* gen(self) {
1369
- for (let id = self.negEl.length - 1; id >= 0; id--) {
1370
- if (self.hasNeg[id]) yield _SignedIndexArray.toNegIndex(id);
1371
- }
1372
- for (let id = 0; id < self.posEl.length; id++) {
1373
- if (self.hasPos[id]) yield id;
1374
- }
1587
+ *indices() {
1588
+ for (let id = this.negLen - 1; id >= 0; id--) {
1589
+ if (this.hasNeg[id]) yield _SignedIndexArray.toNegIndex(id);
1375
1590
  }
1376
- return gen(this);
1377
- }
1378
- indicesArray() {
1379
- return [...this.indices()];
1380
- }
1381
- values() {
1382
- function* gen(self) {
1383
- for (let id = self.negEl.length - 1; id >= 0; id--) {
1384
- if (self.hasNeg[id]) yield self.negEl[id];
1385
- }
1386
- for (let id = 0; id < self.posEl.length; id++) {
1387
- if (self.hasPos[id]) yield self.posEl[id];
1388
- }
1591
+ for (let id = 0; id < this.posLen; id++) {
1592
+ if (this.hasPos[id]) yield id;
1389
1593
  }
1390
- return gen(this);
1391
1594
  }
1392
- valuesArray() {
1393
- return [...this.values()];
1595
+ *values() {
1596
+ for (let id = this.negLen - 1; id >= 0; id--) {
1597
+ if (this.hasNeg[id]) yield this.negEl[id];
1598
+ }
1599
+ for (let id = 0; id < this.posLen; id++) {
1600
+ if (this.hasPos[id]) yield this.posEl[id];
1601
+ }
1394
1602
  }
1395
1603
  *entries() {
1396
- for (let id = this.negEl.length - 1; id >= 0; id--) {
1604
+ for (let id = this.negLen - 1; id >= 0; id--) {
1397
1605
  if (this.hasNeg[id]) yield [_SignedIndexArray.toNegIndex(id), this.negEl[id]];
1398
1606
  }
1399
- for (let id = 0; id < this.posEl.length; id++) {
1607
+ for (let id = 0; id < this.posLen; id++) {
1400
1608
  if (this.hasPos[id]) yield [id, this.posEl[id]];
1401
1609
  }
1402
1610
  }
1611
+ indicesArray() {
1612
+ return [...this.indices()];
1613
+ }
1614
+ valuesArray() {
1615
+ return [...this.values()];
1616
+ }
1403
1617
  entriesArray() {
1404
1618
  return [...this.entries()];
1405
1619
  }
1620
+ *kvKeys() {
1621
+ for (const id of this.indices()) {
1622
+ yield [id];
1623
+ }
1624
+ }
1625
+ *kvValues() {
1626
+ for (const el of this.values()) {
1627
+ yield el;
1628
+ }
1629
+ }
1630
+ *kvEntries() {
1631
+ for (const [id, el] of this.entries()) {
1632
+ yield [[id], el];
1633
+ }
1634
+ }
1406
1635
  *[Symbol.iterator]() {
1407
1636
  yield* this.entries();
1408
1637
  }
@@ -1476,7 +1705,27 @@ var SignedIndexArray = class _SignedIndexArray {
1476
1705
  }
1477
1706
  return result;
1478
1707
  }
1708
+ equals(other, eq) {
1709
+ if (this.size !== other.size) return false;
1710
+ eq ?? (eq = (a, b) => a === b);
1711
+ const posLen = Math.max(this.posLen, other.posLen);
1712
+ for (let i = 0; i < posLen; ++i) {
1713
+ const hasA = this.hasPos[i];
1714
+ const hasB = other.hasPos[i];
1715
+ if (hasA !== hasB) return false;
1716
+ if (hasA && !eq(this.posEl[i], other.posEl[i])) return false;
1717
+ }
1718
+ const negLen = Math.max(this.negLen, other.negLen);
1719
+ for (let i = 0; i < negLen; ++i) {
1720
+ const hasA = this.hasNeg[i];
1721
+ const hasB = other.hasNeg[i];
1722
+ if (hasA !== hasB) return false;
1723
+ if (hasA && !eq(this.negEl[i], other.negEl[i])) return false;
1724
+ }
1725
+ return true;
1726
+ }
1479
1727
  toString() {
1728
+ if (this.size === 0) return `SignedIndexArray[ ]`;
1480
1729
  const entries = this.entriesArray().map(([id, el]) => `${id}: ${el}`).join(", ");
1481
1730
  return `SignedIndexArray[ ${entries} ]`;
1482
1731
  }
@@ -1518,28 +1767,46 @@ var Map1 = class _Map1 {
1518
1767
  get size() {
1519
1768
  return this.map1.size;
1520
1769
  }
1770
+ isEmpty() {
1771
+ return this.size === 0;
1772
+ }
1521
1773
  forEach(callbackfn, thisArg) {
1522
1774
  this.map1.forEach((value, key1) => callbackfn.call(thisArg, value, key1, this));
1523
1775
  }
1524
- keys() {
1525
- return this.map1.keys();
1776
+ *keys() {
1777
+ yield* this.map1.keys();
1778
+ }
1779
+ *values() {
1780
+ yield* this.map1.values();
1781
+ }
1782
+ *entries() {
1783
+ for (const [key1, value] of this.map1)
1784
+ yield [key1, value];
1526
1785
  }
1527
1786
  keysArray() {
1528
1787
  return [...this.keys()];
1529
1788
  }
1530
- values() {
1531
- return this.map1.values();
1532
- }
1533
1789
  valuesArray() {
1534
1790
  return [...this.values()];
1535
1791
  }
1536
- *entries() {
1537
- for (const [key1, value] of this.map1)
1538
- yield [key1, value];
1539
- }
1540
1792
  entriesArray() {
1541
1793
  return [...this.entries()];
1542
1794
  }
1795
+ *kvKeys() {
1796
+ for (const key of this.keys()) {
1797
+ yield [key];
1798
+ }
1799
+ }
1800
+ *kvValues() {
1801
+ for (const el of this.values()) {
1802
+ yield el;
1803
+ }
1804
+ }
1805
+ *kvEntries() {
1806
+ for (const [key, el] of this.entries()) {
1807
+ yield [[key], el];
1808
+ }
1809
+ }
1543
1810
  *[Symbol.iterator]() {
1544
1811
  yield* this.entries();
1545
1812
  }
@@ -1655,39 +1922,48 @@ var Map2 = class _Map2 {
1655
1922
  }
1656
1923
  return count;
1657
1924
  }
1925
+ isEmpty() {
1926
+ return this.size === 0;
1927
+ }
1658
1928
  forEach(callbackfn, thisArg) {
1659
1929
  this.map1.forEach((map2, key1) => map2.forEach((value, key2) => callbackfn.call(thisArg, value, key1, key2, this)));
1660
1930
  }
1661
- keys() {
1662
- function* gen(map1) {
1663
- for (const [key1, map2] of map1)
1664
- for (const key2 of map2.keys())
1665
- yield [key1, key2];
1666
- }
1667
- return gen(this.map1);
1668
- }
1669
- keysArray() {
1670
- return [...this.keys()];
1671
- }
1672
- values() {
1673
- function* gen(map1) {
1674
- for (const map2 of map1.values())
1675
- for (const value of map2.values())
1676
- yield value;
1677
- }
1678
- return gen(this.map1);
1931
+ *keys() {
1932
+ for (const [key1, map2] of this.map1)
1933
+ for (const key2 of map2.keys())
1934
+ yield [key1, key2];
1679
1935
  }
1680
- valuesArray() {
1681
- return [...this.values()];
1936
+ *values() {
1937
+ for (const map2 of this.map1.values())
1938
+ for (const value of map2.values())
1939
+ yield value;
1682
1940
  }
1683
1941
  *entries() {
1684
1942
  for (const [key1, map2] of this.map1)
1685
1943
  for (const [key2, value] of map2)
1686
1944
  yield [key1, key2, value];
1687
1945
  }
1946
+ keysArray() {
1947
+ return [...this.keys()];
1948
+ }
1949
+ valuesArray() {
1950
+ return [...this.values()];
1951
+ }
1688
1952
  entriesArray() {
1689
1953
  return [...this.entries()];
1690
1954
  }
1955
+ *kvKeys() {
1956
+ for (const [key1, key2] of this.keys())
1957
+ yield [key1, key2];
1958
+ }
1959
+ *kvValues() {
1960
+ for (const el of this.values())
1961
+ yield el;
1962
+ }
1963
+ *kvEntries() {
1964
+ for (const [key1, key2, el] of this.entries())
1965
+ yield [[key1, key2], el];
1966
+ }
1691
1967
  *[Symbol.iterator]() {
1692
1968
  yield* this.entries();
1693
1969
  }
@@ -1841,32 +2117,23 @@ var Map3 = class _Map3 {
1841
2117
  }
1842
2118
  return count;
1843
2119
  }
2120
+ isEmpty() {
2121
+ return this.size === 0;
2122
+ }
1844
2123
  forEach(callbackfn, thisArg) {
1845
2124
  this.map1.forEach((map2, key1) => map2.forEach((map3, key2) => map3.forEach((value, key3) => callbackfn.call(thisArg, value, key1, key2, key3, this))));
1846
2125
  }
1847
- keys() {
1848
- function* gen(map1) {
1849
- for (const [key1, map2] of map1)
1850
- for (const [key2, map3] of map2)
1851
- for (const key3 of map3.keys())
1852
- yield [key1, key2, key3];
1853
- }
1854
- return gen(this.map1);
1855
- }
1856
- keysArray() {
1857
- return [...this.keys()];
1858
- }
1859
- values() {
1860
- function* gen(map1) {
1861
- for (const map2 of map1.values())
1862
- for (const map3 of map2.values())
1863
- for (const value of map3.values())
1864
- yield value;
1865
- }
1866
- return gen(this.map1);
2126
+ *keys() {
2127
+ for (const [key1, map2] of this.map1)
2128
+ for (const [key2, map3] of map2)
2129
+ for (const key3 of map3.keys())
2130
+ yield [key1, key2, key3];
1867
2131
  }
1868
- valuesArray() {
1869
- return [...this.values()];
2132
+ *values() {
2133
+ for (const map2 of this.map1.values())
2134
+ for (const map3 of map2.values())
2135
+ for (const value of map3.values())
2136
+ yield value;
1870
2137
  }
1871
2138
  *entries() {
1872
2139
  for (const [key1, map2] of this.map1)
@@ -1874,9 +2141,27 @@ var Map3 = class _Map3 {
1874
2141
  for (const [key3, value] of map3)
1875
2142
  yield [key1, key2, key3, value];
1876
2143
  }
2144
+ keysArray() {
2145
+ return [...this.keys()];
2146
+ }
2147
+ valuesArray() {
2148
+ return [...this.values()];
2149
+ }
1877
2150
  entriesArray() {
1878
2151
  return [...this.entries()];
1879
2152
  }
2153
+ *kvKeys() {
2154
+ for (const [key1, key2, key3] of this.keys())
2155
+ yield [key1, key2, key3];
2156
+ }
2157
+ *kvValues() {
2158
+ for (const el of this.values())
2159
+ yield el;
2160
+ }
2161
+ *kvEntries() {
2162
+ for (const [key1, key2, key3, el] of this.entries())
2163
+ yield [[key1, key2, key3], el];
2164
+ }
1880
2165
  *[Symbol.iterator]() {
1881
2166
  yield* this.entries();
1882
2167
  }
@@ -1979,18 +2264,90 @@ var Map3 = class _Map3 {
1979
2264
  return `Map3(${this.size}) { ${entries.join(", ")} }`;
1980
2265
  }
1981
2266
  };
2267
+
2268
+ // src/core/multi-container.ts
2269
+ var MultiContainer = class {
2270
+ constructor(base) {
2271
+ this.base = base;
2272
+ }
2273
+ isEmpty() {
2274
+ return this.base.isEmpty();
2275
+ }
2276
+ clear() {
2277
+ this.base.clear?.();
2278
+ }
2279
+ add(...keysAndValue) {
2280
+ const keys = keysAndValue.slice(0, -1);
2281
+ const value = keysAndValue[keysAndValue.length - 1];
2282
+ const arr = this.base.get(...keys);
2283
+ this.base.set(...[...keys, arr ? [...arr, value] : [value]]);
2284
+ return value;
2285
+ }
2286
+ remove(...keysAndValue) {
2287
+ const keys = keysAndValue.slice(0, -1);
2288
+ const value = keysAndValue[keysAndValue.length - 1];
2289
+ const arr = this.base.get(...keys);
2290
+ if (!arr) return false;
2291
+ const i = arr.indexOf(value);
2292
+ if (i === -1) return false;
2293
+ arr.splice(i, 1);
2294
+ if (arr.length === 0) this.base.delete(...keys);
2295
+ return true;
2296
+ }
2297
+ getAll(...keys) {
2298
+ return this.base.get(...keys) ?? [];
2299
+ }
2300
+ *iterAll(...keys) {
2301
+ yield* this.getAll(...keys);
2302
+ }
2303
+ *values() {
2304
+ for (const keys of this.keys()) {
2305
+ yield* this.getAll(...keys);
2306
+ }
2307
+ }
2308
+ *keys() {
2309
+ for (const keys of this.base.kvKeys()) {
2310
+ yield keys;
2311
+ }
2312
+ }
2313
+ *entries() {
2314
+ for (const keys of this.keys()) {
2315
+ const arr = this.getAll(...keys);
2316
+ if (arr.length > 0) yield [keys, arr];
2317
+ }
2318
+ }
2319
+ [Symbol.iterator]() {
2320
+ return this.entries();
2321
+ }
2322
+ toString() {
2323
+ const entries = [];
2324
+ for (const keys of this.keys()) {
2325
+ const arr = this.getAll(...keys);
2326
+ const keyStr = Array.isArray(keys) ? `[${keys.map((k) => JSON.stringify(k)).join(", ")}]` : `[${JSON.stringify(keys)}]`;
2327
+ const valuesStr = Array.isArray(arr) ? `[${arr.map((v) => JSON.stringify(v)).join(", ")}]` : "[]";
2328
+ entries.push(`${keyStr} => ${valuesStr}`);
2329
+ }
2330
+ return `MultiContainer{ ${entries.join(", ")} }`;
2331
+ }
2332
+ };
2333
+ function asMulti(base) {
2334
+ return new MultiContainer(base);
2335
+ }
1982
2336
  export {
1983
2337
  Assert,
1984
2338
  Cookies,
1985
2339
  Device,
2340
+ IndexArray,
1986
2341
  LRUCache,
1987
2342
  Map1,
1988
2343
  Map2,
1989
2344
  Map3,
2345
+ MultiContainer,
1990
2346
  SignedIndexArray,
1991
2347
  SmallIntCache,
1992
2348
  Stack,
1993
2349
  utils_exports as Utils,
1994
- Vec2
2350
+ Vec2,
2351
+ asMulti
1995
2352
  };
1996
2353
  //# sourceMappingURL=index.mjs.map