@tspro/ts-utils-lib 1.14.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +10 -4
- package/dist/index.d.mts +215 -130
- package/dist/index.d.ts +215 -130
- package/dist/index.js +577 -318
- package/dist/index.mjs +573 -317
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* TsUtilsLib v1.
|
|
1
|
+
/* TsUtilsLib v1.15.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/
|
|
72
|
-
var
|
|
73
|
-
__export(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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" &&
|
|
206
|
+
return typeof n === "number" && isFinite2(n) && n === Math.trunc(n);
|
|
89
207
|
}
|
|
90
|
-
function
|
|
91
|
-
|
|
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
|
|
100
|
-
return (
|
|
211
|
+
function isIntegerEq(value, compareTo) {
|
|
212
|
+
return isInteger(value) && value === compareTo;
|
|
101
213
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
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
|
|
144
|
-
|
|
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
|
|
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
|
|
166
|
-
|
|
167
|
-
return startY + (endY - startY) * t;
|
|
223
|
+
function isIntegerLte(value, compareTo) {
|
|
224
|
+
return isInteger(value) && value <= compareTo;
|
|
168
225
|
}
|
|
169
|
-
function
|
|
170
|
-
return
|
|
226
|
+
function isIntegerBetween(value, min, max) {
|
|
227
|
+
return isInteger(value) && value >= min && value <= max;
|
|
171
228
|
}
|
|
172
|
-
function
|
|
173
|
-
|
|
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
|
|
188
|
-
return
|
|
232
|
+
function isInfinity(value) {
|
|
233
|
+
return typeof value === "number" && Math.abs(value) === Infinity;
|
|
189
234
|
}
|
|
190
|
-
function
|
|
191
|
-
return
|
|
235
|
+
function isPosInfinity(value) {
|
|
236
|
+
return typeof value === "number" && value === Infinity;
|
|
192
237
|
}
|
|
193
|
-
function
|
|
194
|
-
return
|
|
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/
|
|
716
|
-
var
|
|
717
|
-
__export(
|
|
718
|
-
|
|
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
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
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
|
-
|
|
842
|
-
|
|
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
|
|
845
|
-
return
|
|
785
|
+
function mod(m, n) {
|
|
786
|
+
return (m % n + n) % n;
|
|
846
787
|
}
|
|
847
|
-
function
|
|
848
|
-
|
|
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
|
|
851
|
-
|
|
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
|
|
854
|
-
return
|
|
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
|
|
857
|
-
|
|
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
|
|
860
|
-
return
|
|
855
|
+
function clamp(num, min, max) {
|
|
856
|
+
return Math.min(Math.max(num, min), max);
|
|
861
857
|
}
|
|
862
|
-
function
|
|
863
|
-
|
|
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
|
|
866
|
-
return
|
|
873
|
+
function sum(arr) {
|
|
874
|
+
return arr.reduce((prev, cur) => cur + prev, 0);
|
|
867
875
|
}
|
|
868
|
-
function
|
|
869
|
-
return
|
|
876
|
+
function avg(...values) {
|
|
877
|
+
return sum(values) / values.length;
|
|
870
878
|
}
|
|
871
|
-
|
|
872
|
-
|
|
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: () =>
|
|
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
|
|
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,
|
|
@@ -1293,6 +1291,201 @@ var SmallIntCache = class {
|
|
|
1293
1291
|
}
|
|
1294
1292
|
};
|
|
1295
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 size() {
|
|
1325
|
+
return this.elCount;
|
|
1326
|
+
}
|
|
1327
|
+
get posLen() {
|
|
1328
|
+
return this.hasPos.length;
|
|
1329
|
+
}
|
|
1330
|
+
has(id) {
|
|
1331
|
+
_IndexArray.validateIndex(id);
|
|
1332
|
+
return this.hasPos[id] === true;
|
|
1333
|
+
}
|
|
1334
|
+
set(id, el) {
|
|
1335
|
+
_IndexArray.validateIndex(id);
|
|
1336
|
+
if (this.hasPos[id] !== true) this.elCount++;
|
|
1337
|
+
this.posEl[id] = el;
|
|
1338
|
+
this.hasPos[id] = true;
|
|
1339
|
+
}
|
|
1340
|
+
get(id) {
|
|
1341
|
+
_IndexArray.validateIndex(id);
|
|
1342
|
+
return this.hasPos[id] ? this.posEl[id] : void 0;
|
|
1343
|
+
}
|
|
1344
|
+
getOrDefault(id, defaultValue) {
|
|
1345
|
+
return this.get(id) ?? defaultValue;
|
|
1346
|
+
}
|
|
1347
|
+
getOrCreate(id, creatorOrValue) {
|
|
1348
|
+
if (!this.has(id)) {
|
|
1349
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
1350
|
+
this.set(id, value);
|
|
1351
|
+
return value;
|
|
1352
|
+
}
|
|
1353
|
+
return this.get(id);
|
|
1354
|
+
}
|
|
1355
|
+
delete(id) {
|
|
1356
|
+
_IndexArray.validateIndex(id);
|
|
1357
|
+
if (!this.hasPos[id]) return false;
|
|
1358
|
+
this.posEl[id] = void 0;
|
|
1359
|
+
this.hasPos[id] = false;
|
|
1360
|
+
this.elCount--;
|
|
1361
|
+
return true;
|
|
1362
|
+
}
|
|
1363
|
+
clear() {
|
|
1364
|
+
this.posEl = [];
|
|
1365
|
+
this.hasPos = [];
|
|
1366
|
+
this.elCount = 0;
|
|
1367
|
+
}
|
|
1368
|
+
forEach(callbackfn, thisArg) {
|
|
1369
|
+
for (const [id, el] of this.entries()) {
|
|
1370
|
+
callbackfn.call(thisArg, el, id, this);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
*indices() {
|
|
1374
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
1375
|
+
if (this.hasPos[id]) yield id;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
indicesArray() {
|
|
1379
|
+
return [...this.indices()];
|
|
1380
|
+
}
|
|
1381
|
+
*values() {
|
|
1382
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
1383
|
+
if (this.hasPos[id]) yield this.posEl[id];
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
valuesArray() {
|
|
1387
|
+
return [...this.values()];
|
|
1388
|
+
}
|
|
1389
|
+
*entries() {
|
|
1390
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
1391
|
+
if (this.hasPos[id]) yield [id, this.posEl[id]];
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
entriesArray() {
|
|
1395
|
+
return [...this.entries()];
|
|
1396
|
+
}
|
|
1397
|
+
*[Symbol.iterator]() {
|
|
1398
|
+
yield* this.entries();
|
|
1399
|
+
}
|
|
1400
|
+
clone() {
|
|
1401
|
+
return new _IndexArray(this);
|
|
1402
|
+
}
|
|
1403
|
+
merge(other, conflictResolver) {
|
|
1404
|
+
for (const [id, value] of other.entries()) {
|
|
1405
|
+
if (this.has(id) && conflictResolver) {
|
|
1406
|
+
this.set(id, conflictResolver(this.get(id), value, id));
|
|
1407
|
+
} else {
|
|
1408
|
+
this.set(id, value);
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
return this;
|
|
1412
|
+
}
|
|
1413
|
+
some(fn) {
|
|
1414
|
+
for (const [id, el] of this.entries()) {
|
|
1415
|
+
if (fn(el, id)) return true;
|
|
1416
|
+
}
|
|
1417
|
+
return false;
|
|
1418
|
+
}
|
|
1419
|
+
every(fn) {
|
|
1420
|
+
for (const [id, el] of this.entries()) {
|
|
1421
|
+
if (!fn(el, id)) return false;
|
|
1422
|
+
}
|
|
1423
|
+
return true;
|
|
1424
|
+
}
|
|
1425
|
+
filter(fn) {
|
|
1426
|
+
let result = new _IndexArray();
|
|
1427
|
+
for (const [id, el] of this.entries()) {
|
|
1428
|
+
if (fn(el, id)) result.set(id, el);
|
|
1429
|
+
}
|
|
1430
|
+
return result;
|
|
1431
|
+
}
|
|
1432
|
+
reduce(fn, init) {
|
|
1433
|
+
let iterator = this.entries();
|
|
1434
|
+
let first = iterator.next();
|
|
1435
|
+
if (first.done) {
|
|
1436
|
+
if (arguments.length < 2) {
|
|
1437
|
+
throw new TypeError("Reduce of empty IndexArray with no initial value!");
|
|
1438
|
+
}
|
|
1439
|
+
return init;
|
|
1440
|
+
}
|
|
1441
|
+
let acc;
|
|
1442
|
+
let start;
|
|
1443
|
+
if (arguments.length < 2) {
|
|
1444
|
+
acc = first.value[1];
|
|
1445
|
+
start = iterator.next();
|
|
1446
|
+
} else {
|
|
1447
|
+
acc = init;
|
|
1448
|
+
start = first;
|
|
1449
|
+
}
|
|
1450
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
1451
|
+
const [id, el] = current.value;
|
|
1452
|
+
acc = fn(acc, el, id);
|
|
1453
|
+
}
|
|
1454
|
+
return acc;
|
|
1455
|
+
}
|
|
1456
|
+
mapToArray(fn) {
|
|
1457
|
+
let result = [];
|
|
1458
|
+
for (const [id, el] of this.entries()) {
|
|
1459
|
+
result.push(fn(el, id));
|
|
1460
|
+
}
|
|
1461
|
+
return result;
|
|
1462
|
+
}
|
|
1463
|
+
map(fn) {
|
|
1464
|
+
let result = new _IndexArray();
|
|
1465
|
+
for (const [id, el] of this.entries()) {
|
|
1466
|
+
result.set(id, fn(el, id));
|
|
1467
|
+
}
|
|
1468
|
+
return result;
|
|
1469
|
+
}
|
|
1470
|
+
equals(other, eq) {
|
|
1471
|
+
if (this.size !== other.size) return false;
|
|
1472
|
+
eq ?? (eq = (a, b) => a === b);
|
|
1473
|
+
const posLen = Math.max(this.posLen, other.posLen);
|
|
1474
|
+
for (let i = 0; i < posLen; ++i) {
|
|
1475
|
+
const hasA = this.hasPos[i];
|
|
1476
|
+
const hasB = other.hasPos[i];
|
|
1477
|
+
if (hasA !== hasB) return false;
|
|
1478
|
+
if (hasA && !eq(this.posEl[i], other.posEl[i])) return false;
|
|
1479
|
+
}
|
|
1480
|
+
return true;
|
|
1481
|
+
}
|
|
1482
|
+
toString() {
|
|
1483
|
+
if (this.size === 0) return `IndexArray[ ]`;
|
|
1484
|
+
const entries = this.entriesArray().map(([id, el]) => `${id}: ${el}`).join(", ");
|
|
1485
|
+
return `IndexArray[ ${entries} ]`;
|
|
1486
|
+
}
|
|
1487
|
+
};
|
|
1488
|
+
|
|
1296
1489
|
// src/core/signed-index-array.ts
|
|
1297
1490
|
var SignedIndexArray = class _SignedIndexArray {
|
|
1298
1491
|
constructor(entries) {
|
|
@@ -1326,38 +1519,47 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1326
1519
|
static toNegIndex(id) {
|
|
1327
1520
|
return -id - 1;
|
|
1328
1521
|
}
|
|
1522
|
+
static validateIndex(id) {
|
|
1523
|
+
if (!isInteger(id)) throw new Error(`Invalid index ${id} - must be an integer!`);
|
|
1524
|
+
return id;
|
|
1525
|
+
}
|
|
1329
1526
|
get size() {
|
|
1330
1527
|
return this.elCount;
|
|
1331
1528
|
}
|
|
1529
|
+
get posLen() {
|
|
1530
|
+
return this.hasPos.length;
|
|
1531
|
+
}
|
|
1532
|
+
get negLen() {
|
|
1533
|
+
return this.hasNeg.length;
|
|
1534
|
+
}
|
|
1332
1535
|
has(id) {
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
} else if (id >= 0) {
|
|
1536
|
+
_SignedIndexArray.validateIndex(id);
|
|
1537
|
+
if (id >= 0) {
|
|
1336
1538
|
return this.hasPos[id] === true;
|
|
1337
1539
|
} else {
|
|
1338
1540
|
return this.hasNeg[_SignedIndexArray.toNegIndex(id)] === true;
|
|
1339
1541
|
}
|
|
1340
1542
|
}
|
|
1341
1543
|
set(id, el) {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
} else if (id >= 0) {
|
|
1544
|
+
_SignedIndexArray.validateIndex(id);
|
|
1545
|
+
if (id >= 0) {
|
|
1345
1546
|
if (this.hasPos[id] !== true) this.elCount++;
|
|
1346
1547
|
this.posEl[id] = el;
|
|
1347
1548
|
this.hasPos[id] = true;
|
|
1348
1549
|
} else {
|
|
1349
|
-
|
|
1350
|
-
this.
|
|
1351
|
-
this.
|
|
1550
|
+
let negId = _SignedIndexArray.toNegIndex(id);
|
|
1551
|
+
if (this.hasNeg[negId] !== true) this.elCount++;
|
|
1552
|
+
this.negEl[negId] = el;
|
|
1553
|
+
this.hasNeg[negId] = true;
|
|
1352
1554
|
}
|
|
1353
1555
|
}
|
|
1354
1556
|
get(id) {
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
} else if (id >= 0) {
|
|
1557
|
+
_SignedIndexArray.validateIndex(id);
|
|
1558
|
+
if (id >= 0) {
|
|
1358
1559
|
return this.hasPos[id] ? this.posEl[id] : void 0;
|
|
1359
1560
|
} else {
|
|
1360
|
-
|
|
1561
|
+
let negId = _SignedIndexArray.toNegIndex(id);
|
|
1562
|
+
return this.hasNeg[negId] ? this.negEl[negId] : void 0;
|
|
1361
1563
|
}
|
|
1362
1564
|
}
|
|
1363
1565
|
getOrDefault(id, defaultValue) {
|
|
@@ -1372,7 +1574,7 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1372
1574
|
return this.get(id);
|
|
1373
1575
|
}
|
|
1374
1576
|
delete(id) {
|
|
1375
|
-
|
|
1577
|
+
_SignedIndexArray.validateIndex(id);
|
|
1376
1578
|
const isPos = id >= 0;
|
|
1377
1579
|
const arr = isPos ? this.posEl : this.negEl;
|
|
1378
1580
|
const has = isPos ? this.hasPos : this.hasNeg;
|
|
@@ -1395,39 +1597,33 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1395
1597
|
callbackfn.call(thisArg, el, id, this);
|
|
1396
1598
|
}
|
|
1397
1599
|
}
|
|
1398
|
-
indices() {
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
if (self.hasPos[id]) yield id;
|
|
1405
|
-
}
|
|
1600
|
+
*indices() {
|
|
1601
|
+
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
1602
|
+
if (this.hasNeg[id]) yield _SignedIndexArray.toNegIndex(id);
|
|
1603
|
+
}
|
|
1604
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
1605
|
+
if (this.hasPos[id]) yield id;
|
|
1406
1606
|
}
|
|
1407
|
-
return gen(this);
|
|
1408
1607
|
}
|
|
1409
1608
|
indicesArray() {
|
|
1410
1609
|
return [...this.indices()];
|
|
1411
1610
|
}
|
|
1412
|
-
values() {
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
if (self.hasPos[id]) yield self.posEl[id];
|
|
1419
|
-
}
|
|
1611
|
+
*values() {
|
|
1612
|
+
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
1613
|
+
if (this.hasNeg[id]) yield this.negEl[id];
|
|
1614
|
+
}
|
|
1615
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
1616
|
+
if (this.hasPos[id]) yield this.posEl[id];
|
|
1420
1617
|
}
|
|
1421
|
-
return gen(this);
|
|
1422
1618
|
}
|
|
1423
1619
|
valuesArray() {
|
|
1424
1620
|
return [...this.values()];
|
|
1425
1621
|
}
|
|
1426
1622
|
*entries() {
|
|
1427
|
-
for (let id = this.
|
|
1623
|
+
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
1428
1624
|
if (this.hasNeg[id]) yield [_SignedIndexArray.toNegIndex(id), this.negEl[id]];
|
|
1429
1625
|
}
|
|
1430
|
-
for (let id = 0; id < this.
|
|
1626
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
1431
1627
|
if (this.hasPos[id]) yield [id, this.posEl[id]];
|
|
1432
1628
|
}
|
|
1433
1629
|
}
|
|
@@ -1507,7 +1703,27 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1507
1703
|
}
|
|
1508
1704
|
return result;
|
|
1509
1705
|
}
|
|
1706
|
+
equals(other, eq) {
|
|
1707
|
+
if (this.size !== other.size) return false;
|
|
1708
|
+
eq ?? (eq = (a, b) => a === b);
|
|
1709
|
+
const posLen = Math.max(this.posLen, other.posLen);
|
|
1710
|
+
for (let i = 0; i < posLen; ++i) {
|
|
1711
|
+
const hasA = this.hasPos[i];
|
|
1712
|
+
const hasB = other.hasPos[i];
|
|
1713
|
+
if (hasA !== hasB) return false;
|
|
1714
|
+
if (hasA && !eq(this.posEl[i], other.posEl[i])) return false;
|
|
1715
|
+
}
|
|
1716
|
+
const negLen = Math.max(this.negLen, other.negLen);
|
|
1717
|
+
for (let i = 0; i < negLen; ++i) {
|
|
1718
|
+
const hasA = this.hasNeg[i];
|
|
1719
|
+
const hasB = other.hasNeg[i];
|
|
1720
|
+
if (hasA !== hasB) return false;
|
|
1721
|
+
if (hasA && !eq(this.negEl[i], other.negEl[i])) return false;
|
|
1722
|
+
}
|
|
1723
|
+
return true;
|
|
1724
|
+
}
|
|
1510
1725
|
toString() {
|
|
1726
|
+
if (this.size === 0) return `SignedIndexArray[ ]`;
|
|
1511
1727
|
const entries = this.entriesArray().map(([id, el]) => `${id}: ${el}`).join(", ");
|
|
1512
1728
|
return `SignedIndexArray[ ${entries} ]`;
|
|
1513
1729
|
}
|
|
@@ -2010,19 +2226,62 @@ var Map3 = class _Map3 {
|
|
|
2010
2226
|
return `Map3(${this.size}) { ${entries.join(", ")} }`;
|
|
2011
2227
|
}
|
|
2012
2228
|
};
|
|
2229
|
+
|
|
2230
|
+
// src/core/multi-container.ts
|
|
2231
|
+
var MultiContainer = class {
|
|
2232
|
+
constructor(base) {
|
|
2233
|
+
this.base = base;
|
|
2234
|
+
}
|
|
2235
|
+
add(...keysAndValue) {
|
|
2236
|
+
const keys = keysAndValue.slice(0, -1);
|
|
2237
|
+
const value = keysAndValue[keysAndValue.length - 1];
|
|
2238
|
+
const arr = this.base.get(...keys);
|
|
2239
|
+
this.base.set(...[...keys, arr ? [...arr, value] : [value]]);
|
|
2240
|
+
return value;
|
|
2241
|
+
}
|
|
2242
|
+
remove(...keysAndValue) {
|
|
2243
|
+
const keys = keysAndValue.slice(0, -1);
|
|
2244
|
+
const value = keysAndValue[keysAndValue.length - 1];
|
|
2245
|
+
const arr = this.base.get(...keys);
|
|
2246
|
+
if (!arr) return false;
|
|
2247
|
+
const i = arr.indexOf(value);
|
|
2248
|
+
if (i === -1) return false;
|
|
2249
|
+
arr.splice(i, 1);
|
|
2250
|
+
if (arr.length === 0) this.base.delete(...keys);
|
|
2251
|
+
return true;
|
|
2252
|
+
}
|
|
2253
|
+
getAll(...keys) {
|
|
2254
|
+
return this.base.get(...keys) ?? [];
|
|
2255
|
+
}
|
|
2256
|
+
*iterAll(...keys) {
|
|
2257
|
+
const arr = this.getAll(...keys);
|
|
2258
|
+
for (const v of arr) {
|
|
2259
|
+
yield v;
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
clear() {
|
|
2263
|
+
this.base.clear?.();
|
|
2264
|
+
}
|
|
2265
|
+
};
|
|
2266
|
+
function asMulti(base) {
|
|
2267
|
+
return new MultiContainer(base);
|
|
2268
|
+
}
|
|
2013
2269
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2014
2270
|
0 && (module.exports = {
|
|
2015
2271
|
Assert,
|
|
2016
2272
|
Cookies,
|
|
2017
2273
|
Device,
|
|
2274
|
+
IndexArray,
|
|
2018
2275
|
LRUCache,
|
|
2019
2276
|
Map1,
|
|
2020
2277
|
Map2,
|
|
2021
2278
|
Map3,
|
|
2279
|
+
MultiContainer,
|
|
2022
2280
|
SignedIndexArray,
|
|
2023
2281
|
SmallIntCache,
|
|
2024
2282
|
Stack,
|
|
2025
2283
|
Utils,
|
|
2026
|
-
Vec2
|
|
2284
|
+
Vec2,
|
|
2285
|
+
asMulti
|
|
2027
2286
|
});
|
|
2028
2287
|
//# sourceMappingURL=index.js.map
|