@tspro/ts-utils-lib 1.21.0 → 2.1.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 +17 -0
- package/README.md +70 -1
- package/dist/index.d.mts +278 -876
- package/dist/index.d.ts +278 -876
- package/dist/index.es5.iife.js +1 -0
- package/dist/index.es5.polyfilled.iife.js +1 -0
- package/dist/index.js +1034 -2214
- package/dist/index.mjs +999 -2152
- package/package.json +9 -6
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* TsUtilsLib v2.1.0 (esm)
|
|
3
|
+
* (c) 2023–2025 PahkaSoft
|
|
4
|
+
* Licensed under the MIT License
|
|
5
|
+
*/
|
|
2
6
|
var __defProp = Object.defineProperty;
|
|
3
7
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
8
|
var __export = (target, all) => {
|
|
@@ -10,44 +14,137 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
10
14
|
// src/assert/index.ts
|
|
11
15
|
var assert_exports = {};
|
|
12
16
|
__export(assert_exports, {
|
|
13
|
-
array_elem: () => array_elem,
|
|
14
|
-
array_id: () => array_id,
|
|
15
17
|
assert: () => assert,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
even: () => even,
|
|
18
|
+
doesNotThrow: () => doesNotThrow2,
|
|
19
|
+
doesThrow: () => doesThrow2,
|
|
19
20
|
fail: () => fail,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
isArray: () => isArray2,
|
|
22
|
+
isArrayOrUndefined: () => isArrayOrUndefined2,
|
|
23
|
+
isBigInt: () => isBigInt2,
|
|
24
|
+
isBoolean: () => isBoolean2,
|
|
25
|
+
isBooleanOrUndefined: () => isBooleanOrUndefined2,
|
|
26
|
+
isDeepEqual: () => isDeepEqual2,
|
|
27
|
+
isDefined: () => isDefined2,
|
|
28
|
+
isEmptyArray: () => isEmptyArray2,
|
|
29
|
+
isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined2,
|
|
30
|
+
isEmptyObject: () => isEmptyObject2,
|
|
31
|
+
isEmptyString: () => isEmptyString2,
|
|
32
|
+
isEmptyStringOrUndefined: () => isEmptyStringOrUndefined2,
|
|
33
|
+
isEnumValue: () => isEnumValue2,
|
|
34
|
+
isEnumValueOrUndefined: () => isEnumValueOrUndefined2,
|
|
35
|
+
isEven: () => isEven2,
|
|
36
|
+
isFalse: () => isFalse2,
|
|
37
|
+
isFalseOrUndefined: () => isFalseOrUndefined2,
|
|
38
|
+
isFinite: () => isFinite3,
|
|
39
|
+
isFloat: () => isFloat2,
|
|
40
|
+
isFunction: () => isFunction2,
|
|
41
|
+
isFunctionOrUndefined: () => isFunctionOrUndefined2,
|
|
42
|
+
isIncluded: () => isIncluded2,
|
|
43
|
+
isIndex: () => isIndex2,
|
|
44
|
+
isInfinity: () => isInfinity2,
|
|
45
|
+
isInteger: () => isInteger2,
|
|
46
|
+
isIntegerBetween: () => isIntegerBetween2,
|
|
47
|
+
isIntegerBetweenExclusive: () => isIntegerBetweenExclusive2,
|
|
48
|
+
isIntegerEq: () => isIntegerEq2,
|
|
49
|
+
isIntegerGt: () => isIntegerGt2,
|
|
50
|
+
isIntegerGte: () => isIntegerGte2,
|
|
51
|
+
isIntegerLt: () => isIntegerLt2,
|
|
52
|
+
isIntegerLte: () => isIntegerLte2,
|
|
53
|
+
isIntegerOrUndefined: () => isIntegerOrUndefined2,
|
|
54
|
+
isMultipleOf: () => isMultipleOf2,
|
|
55
|
+
isNaNValue: () => isNaNValue2,
|
|
56
|
+
isNeg: () => isNeg2,
|
|
57
|
+
isNegInfinity: () => isNegInfinity2,
|
|
58
|
+
isNegZero: () => isNegZero2,
|
|
59
|
+
isNonEmptyArray: () => isNonEmptyArray2,
|
|
60
|
+
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined2,
|
|
61
|
+
isNonEmptyString: () => isNonEmptyString2,
|
|
62
|
+
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined2,
|
|
63
|
+
isNonNeg: () => isNonNeg2,
|
|
64
|
+
isNonNull: () => isNonNull2,
|
|
65
|
+
isNonPos: () => isNonPos2,
|
|
66
|
+
isNull: () => isNull2,
|
|
67
|
+
isNullish: () => isNullish2,
|
|
68
|
+
isNumber: () => isNumber2,
|
|
69
|
+
isNumberBetween: () => isNumberBetween2,
|
|
70
|
+
isNumberBetweenExclusive: () => isNumberBetweenExclusive2,
|
|
71
|
+
isNumberOrUndefined: () => isNumberOrUndefined2,
|
|
72
|
+
isNumericString: () => isNumericString2,
|
|
73
|
+
isObject: () => isObject2,
|
|
74
|
+
isObjectOrUndefined: () => isObjectOrUndefined2,
|
|
75
|
+
isOdd: () => isOdd2,
|
|
76
|
+
isPlainObject: () => isPlainObject2,
|
|
77
|
+
isPos: () => isPos2,
|
|
78
|
+
isPosInfinity: () => isPosInfinity2,
|
|
79
|
+
isPosZero: () => isPosZero2,
|
|
80
|
+
isPowerOfTwo: () => isPowerOfTwo2,
|
|
81
|
+
isSafeInteger: () => isSafeInteger2,
|
|
82
|
+
isStrictEqual: () => isStrictEqual2,
|
|
83
|
+
isString: () => isString2,
|
|
84
|
+
isStringOrUndefined: () => isStringOrUndefined2,
|
|
85
|
+
isTrue: () => isTrue2,
|
|
86
|
+
isTrueOrUndefined: () => isTrueOrUndefined2,
|
|
87
|
+
isTypedObject: () => isTypedObject2,
|
|
88
|
+
isUndefined: () => isUndefined2,
|
|
89
|
+
isZero: () => isZero2,
|
|
90
|
+
require: () => require2,
|
|
91
|
+
requireDefined: () => requireDefined,
|
|
92
|
+
requireElement: () => requireElement,
|
|
93
|
+
setErrorClass: () => setErrorClass
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// src/utils/str/index.ts
|
|
97
|
+
var str_exports = {};
|
|
98
|
+
__export(str_exports, {
|
|
99
|
+
charCount: () => charCount,
|
|
100
|
+
chunkString: () => chunkString,
|
|
101
|
+
insertAt: () => insertAt,
|
|
102
|
+
isString: () => isString,
|
|
103
|
+
makeSentenceFromPascal: () => makeSentenceFromPascal,
|
|
104
|
+
removeAt: () => removeAt,
|
|
105
|
+
repeatString: () => repeatString,
|
|
106
|
+
replaceAt: () => replaceAt,
|
|
107
|
+
stringify: () => stringify,
|
|
108
|
+
toCharArray: () => toCharArray
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// src/utils/obj/index.ts
|
|
112
|
+
var obj_exports = {};
|
|
113
|
+
__export(obj_exports, {
|
|
114
|
+
deepEqual: () => deepEqual,
|
|
115
|
+
getCtorName: () => getCtorName,
|
|
116
|
+
hasProperties: () => hasProperties,
|
|
117
|
+
isObject: () => isObject
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// src/guard/index.ts
|
|
121
|
+
var guard_exports = {};
|
|
122
|
+
__export(guard_exports, {
|
|
123
|
+
doesNotThrow: () => doesNotThrow,
|
|
124
|
+
doesThrow: () => doesThrow,
|
|
31
125
|
isArray: () => isArray,
|
|
32
|
-
isArrayIndex: () => isArrayIndex,
|
|
33
126
|
isArrayOrUndefined: () => isArrayOrUndefined,
|
|
127
|
+
isBigInt: () => isBigInt,
|
|
34
128
|
isBoolean: () => isBoolean,
|
|
35
129
|
isBooleanOrUndefined: () => isBooleanOrUndefined,
|
|
36
130
|
isDeepEqual: () => isDeepEqual,
|
|
131
|
+
isDefined: () => isDefined,
|
|
37
132
|
isEmptyArray: () => isEmptyArray,
|
|
38
133
|
isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined,
|
|
134
|
+
isEmptyObject: () => isEmptyObject,
|
|
39
135
|
isEmptyString: () => isEmptyString,
|
|
40
136
|
isEmptyStringOrUndefined: () => isEmptyStringOrUndefined,
|
|
41
137
|
isEnumValue: () => isEnumValue,
|
|
42
138
|
isEnumValueOrUndefined: () => isEnumValueOrUndefined,
|
|
43
|
-
|
|
44
|
-
isEvenNumber: () => isEvenNumber,
|
|
139
|
+
isEven: () => isEven,
|
|
45
140
|
isFalse: () => isFalse,
|
|
46
141
|
isFalseOrUndefined: () => isFalseOrUndefined,
|
|
47
142
|
isFinite: () => isFinite2,
|
|
143
|
+
isFloat: () => isFloat,
|
|
48
144
|
isFunction: () => isFunction,
|
|
49
145
|
isFunctionOrUndefined: () => isFunctionOrUndefined,
|
|
50
146
|
isIncluded: () => isIncluded,
|
|
147
|
+
isIndex: () => isIndex,
|
|
51
148
|
isInfinity: () => isInfinity,
|
|
52
149
|
isInteger: () => isInteger,
|
|
53
150
|
isIntegerBetween: () => isIntegerBetween,
|
|
@@ -58,448 +155,934 @@ __export(assert_exports, {
|
|
|
58
155
|
isIntegerLt: () => isIntegerLt,
|
|
59
156
|
isIntegerLte: () => isIntegerLte,
|
|
60
157
|
isIntegerOrUndefined: () => isIntegerOrUndefined,
|
|
158
|
+
isMultipleOf: () => isMultipleOf,
|
|
61
159
|
isNaNValue: () => isNaNValue,
|
|
160
|
+
isNeg: () => isNeg,
|
|
62
161
|
isNegInfinity: () => isNegInfinity,
|
|
162
|
+
isNegZero: () => isNegZero,
|
|
63
163
|
isNonEmptyArray: () => isNonEmptyArray,
|
|
64
164
|
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined,
|
|
65
165
|
isNonEmptyString: () => isNonEmptyString,
|
|
66
166
|
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined,
|
|
67
|
-
|
|
167
|
+
isNonNeg: () => isNonNeg,
|
|
168
|
+
isNonNull: () => isNonNull,
|
|
169
|
+
isNonPos: () => isNonPos,
|
|
68
170
|
isNull: () => isNull,
|
|
69
171
|
isNullish: () => isNullish,
|
|
70
172
|
isNumber: () => isNumber,
|
|
71
173
|
isNumberBetween: () => isNumberBetween,
|
|
72
174
|
isNumberBetweenExclusive: () => isNumberBetweenExclusive,
|
|
73
175
|
isNumberOrUndefined: () => isNumberOrUndefined,
|
|
176
|
+
isNumericString: () => isNumericString,
|
|
74
177
|
isObject: () => isObject,
|
|
75
178
|
isObjectOrUndefined: () => isObjectOrUndefined,
|
|
76
|
-
|
|
179
|
+
isOdd: () => isOdd,
|
|
180
|
+
isPlainObject: () => isPlainObject,
|
|
181
|
+
isPos: () => isPos,
|
|
77
182
|
isPosInfinity: () => isPosInfinity,
|
|
183
|
+
isPosZero: () => isPosZero,
|
|
184
|
+
isPowerOfTwo: () => isPowerOfTwo,
|
|
185
|
+
isSafeInteger: () => isSafeInteger,
|
|
186
|
+
isStrictEqual: () => isStrictEqual,
|
|
78
187
|
isString: () => isString,
|
|
79
188
|
isStringOrUndefined: () => isStringOrUndefined,
|
|
80
|
-
isThrowing: () => isThrowing,
|
|
81
189
|
isTrue: () => isTrue,
|
|
82
190
|
isTrueOrUndefined: () => isTrueOrUndefined,
|
|
83
191
|
isTypedObject: () => isTypedObject,
|
|
84
192
|
isUndefined: () => isUndefined,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
requireDefined: () => requireDefined,
|
|
88
|
-
setErrorClass: () => setErrorClass
|
|
193
|
+
isZero: () => isZero,
|
|
194
|
+
tryOr: () => tryOr
|
|
89
195
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
196
|
+
|
|
197
|
+
// src/utils/enum/index.ts
|
|
198
|
+
var enum_exports = {};
|
|
199
|
+
__export(enum_exports, {
|
|
200
|
+
forEachEnum: () => forEachEnum,
|
|
201
|
+
getEnumEntries: () => getEnumEntries,
|
|
202
|
+
getEnumKey: () => getEnumKey,
|
|
203
|
+
getEnumKeys: () => getEnumKeys,
|
|
204
|
+
getEnumValues: () => getEnumValues
|
|
205
|
+
});
|
|
206
|
+
function getEnumKeys(e) {
|
|
207
|
+
return Object.keys(e).filter((k) => isNaN(Number(k)));
|
|
93
208
|
}
|
|
94
|
-
function
|
|
95
|
-
|
|
96
|
-
throw new errorConstructor("Assertion Failed!" + (msg === "" ? "" : " " + msg));
|
|
209
|
+
function getEnumValues(e) {
|
|
210
|
+
return getEnumKeys(e).map((k) => e[k]);
|
|
97
211
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
212
|
+
function getEnumEntries(e) {
|
|
213
|
+
return getEnumKeys(e).map((k) => [k, e[k]]);
|
|
100
214
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
103
|
-
_fail(`Invalid enum value ${enumVal}.`);
|
|
215
|
+
function getEnumKey(e, value) {
|
|
216
|
+
return getEnumKeys(e).find((k) => e[k] === value);
|
|
104
217
|
}
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
_fail(`Expected ${value} to be integer.`, msg);
|
|
108
|
-
return value;
|
|
218
|
+
function forEachEnum(e, callback) {
|
|
219
|
+
for (const [k, v] of getEnumEntries(e)) callback(k, v);
|
|
109
220
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return
|
|
221
|
+
|
|
222
|
+
// src/guard/index.ts
|
|
223
|
+
function isStrictEqual(val1, val2) {
|
|
224
|
+
return val1 === val2;
|
|
114
225
|
}
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
_fail(`Expected ${value} to be integer equal to ${compareTo}.`, msg);
|
|
118
|
-
return value;
|
|
226
|
+
function isDeepEqual(val1, val2) {
|
|
227
|
+
return deepEqual(val1, val2);
|
|
119
228
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
_fail(`Expected ${value} to be integer less than ${compareTo}.`, msg);
|
|
123
|
-
return value;
|
|
229
|
+
function isUndefined(val) {
|
|
230
|
+
return val === void 0;
|
|
124
231
|
}
|
|
125
|
-
function
|
|
126
|
-
|
|
127
|
-
_fail(`Expected ${value} to be integer less than or equal to ${compareTo}.`, msg);
|
|
128
|
-
return value;
|
|
232
|
+
function isNull(val) {
|
|
233
|
+
return val === null;
|
|
129
234
|
}
|
|
130
|
-
function
|
|
131
|
-
|
|
132
|
-
_fail(`Expected ${value} to be integer greater than ${compareTo}.`, msg);
|
|
133
|
-
return value;
|
|
235
|
+
function isNullish(val) {
|
|
236
|
+
return val === void 0 || val === null;
|
|
134
237
|
}
|
|
135
|
-
function
|
|
136
|
-
|
|
137
|
-
_fail(`Expected ${value} to be integer greater than or equal to ${compareTo}.`, msg);
|
|
138
|
-
return value;
|
|
238
|
+
function isDefined(val) {
|
|
239
|
+
return val !== void 0;
|
|
139
240
|
}
|
|
140
|
-
function
|
|
141
|
-
|
|
142
|
-
_fail(`Expected integer between ${min} <= ${value} <= ${max}.`, msg);
|
|
143
|
-
return value;
|
|
241
|
+
function isNonNull(val) {
|
|
242
|
+
return val !== null;
|
|
144
243
|
}
|
|
145
|
-
function
|
|
146
|
-
|
|
147
|
-
_fail(`Expected integer between ${min} < ${value} < ${max}.`, msg);
|
|
148
|
-
return value;
|
|
244
|
+
function isObject(val) {
|
|
245
|
+
return typeof val === "object" && val !== null && !isArray(val);
|
|
149
246
|
}
|
|
150
|
-
function
|
|
151
|
-
|
|
152
|
-
_fail(`Expected ${value} to be odd number.`, msg);
|
|
153
|
-
return value;
|
|
247
|
+
function isEmptyObject(val) {
|
|
248
|
+
return isObject(val) && Object.keys(val).length === 0;
|
|
154
249
|
}
|
|
155
|
-
function
|
|
156
|
-
|
|
157
|
-
_fail(`Expected ${value} to be even number.`, msg);
|
|
158
|
-
return value;
|
|
250
|
+
function isObjectOrUndefined(val) {
|
|
251
|
+
return val === void 0 || isObject(val);
|
|
159
252
|
}
|
|
160
|
-
function
|
|
161
|
-
if (!
|
|
162
|
-
|
|
163
|
-
return
|
|
253
|
+
function isPlainObject(val) {
|
|
254
|
+
if (!isObject(val)) return false;
|
|
255
|
+
const proto = Object.getPrototypeOf(val);
|
|
256
|
+
return proto === Object.prototype || proto === null;
|
|
164
257
|
}
|
|
165
|
-
function
|
|
166
|
-
|
|
167
|
-
_fail(`Expected ${value} to be finite number.`, msg);
|
|
168
|
-
return value;
|
|
258
|
+
function isTypedObject(val, keys) {
|
|
259
|
+
return isObject(val) && keys.every((k) => k in val);
|
|
169
260
|
}
|
|
170
|
-
function
|
|
171
|
-
|
|
172
|
-
_fail(`Expected ${index} to be array index in bounds [0..${array.length - 1}].`, msg);
|
|
173
|
-
return index;
|
|
261
|
+
function isSet(val) {
|
|
262
|
+
return val instanceof Set;
|
|
174
263
|
}
|
|
175
|
-
function
|
|
176
|
-
return
|
|
264
|
+
function isArray(arr) {
|
|
265
|
+
return !!arr && Object.prototype.toString.call(arr) === "[object Array]";
|
|
177
266
|
}
|
|
178
|
-
function
|
|
179
|
-
|
|
180
|
-
_fail(msg);
|
|
181
|
-
}
|
|
267
|
+
function isArrayOrUndefined(arr) {
|
|
268
|
+
return arr === void 0 || isArray(arr);
|
|
182
269
|
}
|
|
183
|
-
function
|
|
184
|
-
|
|
185
|
-
_fail(`Expected ${value} not to be nullish`, msg);
|
|
186
|
-
}
|
|
187
|
-
return value;
|
|
270
|
+
function isEmptyArray(arr) {
|
|
271
|
+
return isArray(arr) && arr.length === 0;
|
|
188
272
|
}
|
|
189
|
-
function
|
|
190
|
-
|
|
191
|
-
_fail(`Expected ${value} not to be undefined`, msg);
|
|
192
|
-
}
|
|
193
|
-
return value;
|
|
273
|
+
function isNonEmptyArray(arr) {
|
|
274
|
+
return isArray(arr) && arr.length > 0;
|
|
194
275
|
}
|
|
195
|
-
function
|
|
196
|
-
|
|
276
|
+
function isEmptyArrayOrUndefined(arr) {
|
|
277
|
+
return isArray(arr) && arr.length === 0 || arr === void 0;
|
|
197
278
|
}
|
|
198
|
-
function
|
|
199
|
-
|
|
200
|
-
_fail(`Expected ${value1} to equal with ${value2}`, msg);
|
|
201
|
-
return true;
|
|
279
|
+
function isNonEmptyArrayOrUndefined(arr) {
|
|
280
|
+
return isArray(arr) && arr.length > 0 || arr === void 0;
|
|
202
281
|
}
|
|
203
|
-
function
|
|
204
|
-
|
|
205
|
-
_fail(`Expected ${value1} to deep equal with ${value2}`, msg);
|
|
206
|
-
return true;
|
|
282
|
+
function isString(val) {
|
|
283
|
+
return typeof val === "string";
|
|
207
284
|
}
|
|
208
|
-
function
|
|
209
|
-
|
|
210
|
-
_fail(`Expected ${value} to be undefined`, msg);
|
|
211
|
-
return true;
|
|
285
|
+
function isEmptyString(val) {
|
|
286
|
+
return typeof val === "string" && val.length === 0;
|
|
212
287
|
}
|
|
213
|
-
function
|
|
214
|
-
|
|
215
|
-
_fail(`Expected ${value} to be null`, msg);
|
|
216
|
-
return true;
|
|
288
|
+
function isNonEmptyString(val) {
|
|
289
|
+
return typeof val === "string" && val.length > 0;
|
|
217
290
|
}
|
|
218
|
-
function
|
|
219
|
-
|
|
220
|
-
_fail(`Expected ${value} to be null or undefined`, msg);
|
|
221
|
-
return true;
|
|
291
|
+
function isStringOrUndefined(val) {
|
|
292
|
+
return val === void 0 || typeof val === "string";
|
|
222
293
|
}
|
|
223
|
-
function
|
|
224
|
-
|
|
225
|
-
_fail(`Expected ${value} to be object`, msg);
|
|
226
|
-
return true;
|
|
294
|
+
function isEmptyStringOrUndefined(val) {
|
|
295
|
+
return typeof val === "string" && val.length === 0 || val === void 0;
|
|
227
296
|
}
|
|
228
|
-
function
|
|
229
|
-
|
|
230
|
-
_fail(`Expected ${value} to be object or undefined`, msg);
|
|
231
|
-
return true;
|
|
297
|
+
function isNonEmptyStringOrUndefined(val) {
|
|
298
|
+
return typeof val === "string" && val.length > 0 || val === void 0;
|
|
232
299
|
}
|
|
233
|
-
function
|
|
234
|
-
|
|
235
|
-
_fail(`Expected ${obj} to be object with keys [${keys.map((key) => `'${String(key)}'`).join(", ")}]`, msg);
|
|
236
|
-
return true;
|
|
300
|
+
function isBoolean(val) {
|
|
301
|
+
return typeof val === "boolean";
|
|
237
302
|
}
|
|
238
|
-
function
|
|
239
|
-
|
|
240
|
-
_fail(`Expected ${value} to be array`, msg);
|
|
241
|
-
return true;
|
|
303
|
+
function isBooleanOrUndefined(val) {
|
|
304
|
+
return val === void 0 || typeof val === "boolean";
|
|
242
305
|
}
|
|
243
|
-
function
|
|
244
|
-
|
|
245
|
-
_fail(`Expected ${value} to be array or undefined`, msg);
|
|
246
|
-
return true;
|
|
306
|
+
function isTrue(val) {
|
|
307
|
+
return val === true;
|
|
247
308
|
}
|
|
248
|
-
function
|
|
249
|
-
|
|
250
|
-
_fail(`Expected ${value} to be empty array`, msg);
|
|
251
|
-
return true;
|
|
309
|
+
function isTrueOrUndefined(val) {
|
|
310
|
+
return val === true || val === void 0;
|
|
252
311
|
}
|
|
253
|
-
function
|
|
254
|
-
|
|
255
|
-
_fail(`Expected ${value} to be non-empty array`, msg);
|
|
256
|
-
return true;
|
|
312
|
+
function isFalse(val) {
|
|
313
|
+
return val === false;
|
|
257
314
|
}
|
|
258
|
-
function
|
|
259
|
-
|
|
260
|
-
_fail(`Expected ${value} to be empty array or undefined`, msg);
|
|
261
|
-
return true;
|
|
315
|
+
function isFalseOrUndefined(val) {
|
|
316
|
+
return val === false || val === void 0;
|
|
262
317
|
}
|
|
263
|
-
function
|
|
264
|
-
|
|
265
|
-
_fail(`Expected ${value} to be non-empty array or undefined`, msg);
|
|
266
|
-
return true;
|
|
318
|
+
function isFunction(val) {
|
|
319
|
+
return typeof val === "function";
|
|
267
320
|
}
|
|
268
|
-
function
|
|
269
|
-
|
|
270
|
-
_fail(`Expected ${value} to be string`, msg);
|
|
271
|
-
return true;
|
|
321
|
+
function isFunctionOrUndefined(val) {
|
|
322
|
+
return val === void 0 || typeof val === "function";
|
|
272
323
|
}
|
|
273
|
-
function
|
|
274
|
-
|
|
275
|
-
_fail(`Expected ${value} to be empty string`, msg);
|
|
276
|
-
return true;
|
|
324
|
+
function isEnumValue(val, enumObj) {
|
|
325
|
+
return getEnumValues(enumObj).some((v) => v === val);
|
|
277
326
|
}
|
|
278
|
-
function
|
|
279
|
-
|
|
280
|
-
_fail(`Expected ${value} to be non-empty string`, msg);
|
|
281
|
-
return true;
|
|
327
|
+
function isEnumValueOrUndefined(val, enumObj) {
|
|
328
|
+
return val === void 0 || getEnumValues(enumObj).some((v) => v === val);
|
|
282
329
|
}
|
|
283
|
-
function
|
|
284
|
-
if (
|
|
285
|
-
|
|
286
|
-
return
|
|
330
|
+
function isNumericString(val) {
|
|
331
|
+
if (typeof val !== "string" || val.trim() === "") return false;
|
|
332
|
+
const n = +val;
|
|
333
|
+
return Number.isFinite(n);
|
|
287
334
|
}
|
|
288
|
-
function
|
|
289
|
-
|
|
290
|
-
_fail(`Expected ${value} to be empty string or undefined`, msg);
|
|
291
|
-
return true;
|
|
335
|
+
function isBigInt(val) {
|
|
336
|
+
return typeof val === "bigint";
|
|
292
337
|
}
|
|
293
|
-
function
|
|
294
|
-
|
|
295
|
-
_fail(`Expected ${value} to be non-empty string or undefined`, msg);
|
|
296
|
-
return true;
|
|
338
|
+
function isNumber(val) {
|
|
339
|
+
return typeof val === "number";
|
|
297
340
|
}
|
|
298
|
-
function
|
|
299
|
-
|
|
300
|
-
_fail(`Expected ${value} to be boolean`, msg);
|
|
301
|
-
return true;
|
|
341
|
+
function isNumberOrUndefined(val) {
|
|
342
|
+
return typeof val === "number" || val === void 0;
|
|
302
343
|
}
|
|
303
|
-
function
|
|
304
|
-
|
|
305
|
-
_fail(`Expected ${value} to be boolean or undefined`, msg);
|
|
306
|
-
return true;
|
|
344
|
+
function isFinite2(val) {
|
|
345
|
+
return typeof val === "number" && Number.isFinite(val);
|
|
307
346
|
}
|
|
308
|
-
function
|
|
309
|
-
|
|
310
|
-
_fail(`Expected ${value} to be true`, msg);
|
|
311
|
-
return true;
|
|
347
|
+
function isFloat(val) {
|
|
348
|
+
return isFinite2(val) && !isInteger(val);
|
|
312
349
|
}
|
|
313
|
-
function
|
|
314
|
-
|
|
315
|
-
_fail(`Expected ${value} to be true or undefined`, msg);
|
|
316
|
-
return true;
|
|
350
|
+
function isInteger(val) {
|
|
351
|
+
return typeof val === "number" && isFinite2(val) && val === Math.trunc(val);
|
|
317
352
|
}
|
|
318
|
-
function
|
|
319
|
-
|
|
320
|
-
_fail(`Expected ${value} to be false`, msg);
|
|
321
|
-
return true;
|
|
353
|
+
function isSafeInteger(val) {
|
|
354
|
+
return isInteger(val) && Number.isSafeInteger(val);
|
|
322
355
|
}
|
|
323
|
-
function
|
|
324
|
-
|
|
325
|
-
_fail(`Expected ${value} to be false or undefined`, msg);
|
|
326
|
-
return true;
|
|
356
|
+
function isIntegerOrUndefined(val) {
|
|
357
|
+
return typeof val === "number" && isFinite2(val) && val === Math.trunc(val) || val === void 0;
|
|
327
358
|
}
|
|
328
|
-
function
|
|
329
|
-
|
|
330
|
-
_fail(`Expected ${value} to be function`, msg);
|
|
331
|
-
return true;
|
|
359
|
+
function isIntegerEq(val, ref) {
|
|
360
|
+
return isInteger(val) && val === ref;
|
|
332
361
|
}
|
|
333
|
-
function
|
|
334
|
-
|
|
335
|
-
_fail(`Expected ${value} to be function or undefined`, msg);
|
|
336
|
-
return true;
|
|
362
|
+
function isIntegerGt(val, ref) {
|
|
363
|
+
return isInteger(val) && isNumber(ref) && val > ref;
|
|
337
364
|
}
|
|
338
|
-
function
|
|
339
|
-
|
|
340
|
-
_fail(`Expected ${enumValue} to be enum value`, msg);
|
|
341
|
-
return true;
|
|
365
|
+
function isIntegerGte(val, ref) {
|
|
366
|
+
return isInteger(val) && isNumber(ref) && val >= ref;
|
|
342
367
|
}
|
|
343
|
-
function
|
|
344
|
-
|
|
345
|
-
_fail(`Expected ${enumValue} to be enum value or undefined`, msg);
|
|
346
|
-
return true;
|
|
368
|
+
function isIntegerLt(val, ref) {
|
|
369
|
+
return isInteger(val) && isNumber(ref) && val < ref;
|
|
347
370
|
}
|
|
348
|
-
function
|
|
349
|
-
|
|
350
|
-
_fail(`Expected ${value} to be number`, msg);
|
|
351
|
-
return true;
|
|
371
|
+
function isIntegerLte(val, ref) {
|
|
372
|
+
return isInteger(val) && isNumber(ref) && val <= ref;
|
|
352
373
|
}
|
|
353
|
-
function
|
|
354
|
-
|
|
355
|
-
_fail(`Expected ${value} to be number or undefined`, msg);
|
|
356
|
-
return true;
|
|
374
|
+
function isIntegerBetween(val, min, max) {
|
|
375
|
+
return isInteger(val) && isNumber(min) && isNumber(max) && val >= min && val <= max;
|
|
357
376
|
}
|
|
358
|
-
function
|
|
359
|
-
|
|
360
|
-
_fail(`Expected ${value} to be finite`, msg);
|
|
361
|
-
return true;
|
|
377
|
+
function isIntegerBetweenExclusive(val, min, max) {
|
|
378
|
+
return isInteger(val) && isNumber(min) && isNumber(max) && val > min && val < max;
|
|
362
379
|
}
|
|
363
|
-
function
|
|
364
|
-
|
|
365
|
-
_fail(`Expected ${value} to be integer`, msg);
|
|
366
|
-
return true;
|
|
380
|
+
function isNumberBetween(val, min, max) {
|
|
381
|
+
return isNumber(val) && isNumber(min) && isNumber(max) && val >= min && val <= max;
|
|
367
382
|
}
|
|
368
|
-
function
|
|
369
|
-
|
|
370
|
-
_fail(`Expected ${value} to be integer or undefined`, msg);
|
|
371
|
-
return true;
|
|
383
|
+
function isNumberBetweenExclusive(val, min, max) {
|
|
384
|
+
return isNumber(val) && isNumber(min) && isNumber(max) && val > min && val < max;
|
|
372
385
|
}
|
|
373
|
-
function
|
|
374
|
-
|
|
375
|
-
_fail(`Expected ${value} to be integer equal to ${compareTo}`, msg);
|
|
376
|
-
return true;
|
|
386
|
+
function isNaNValue(val) {
|
|
387
|
+
return typeof val === "number" && Number.isNaN(val);
|
|
377
388
|
}
|
|
378
|
-
function
|
|
379
|
-
|
|
380
|
-
_fail(`Expected ${value} to be integer > ${compareTo}`, msg);
|
|
381
|
-
return true;
|
|
389
|
+
function isInfinity(val) {
|
|
390
|
+
return val === Infinity || val === -Infinity;
|
|
382
391
|
}
|
|
383
|
-
function
|
|
384
|
-
|
|
385
|
-
_fail(`Expected ${value} to be integer >= ${compareTo}`, msg);
|
|
386
|
-
return true;
|
|
392
|
+
function isPosInfinity(val) {
|
|
393
|
+
return val === Infinity;
|
|
387
394
|
}
|
|
388
|
-
function
|
|
389
|
-
|
|
390
|
-
_fail(`Expected ${value} to be integer < ${compareTo}`, msg);
|
|
391
|
-
return true;
|
|
395
|
+
function isNegInfinity(val) {
|
|
396
|
+
return val === -Infinity;
|
|
392
397
|
}
|
|
393
|
-
function
|
|
394
|
-
|
|
395
|
-
_fail(`Expected ${value} to be integer <= ${compareTo}`, msg);
|
|
396
|
-
return true;
|
|
398
|
+
function isPos(val) {
|
|
399
|
+
return typeof val === "number" && val > 0;
|
|
397
400
|
}
|
|
398
|
-
function
|
|
399
|
-
|
|
400
|
-
_fail(`Expected integer ${min} <= ${value} <= ${max}.`, msg);
|
|
401
|
-
return true;
|
|
401
|
+
function isNeg(val) {
|
|
402
|
+
return typeof val === "number" && val < 0;
|
|
402
403
|
}
|
|
403
|
-
function
|
|
404
|
-
|
|
405
|
-
_fail(`Expected integer ${min} < ${value} < ${max}.`, msg);
|
|
406
|
-
return true;
|
|
404
|
+
function isNonPos(val) {
|
|
405
|
+
return typeof val === "number" && val <= 0;
|
|
407
406
|
}
|
|
408
|
-
function
|
|
409
|
-
|
|
410
|
-
_fail(`Expected number ${min} <= ${value} <= ${max}.`, msg);
|
|
411
|
-
return true;
|
|
407
|
+
function isNonNeg(val) {
|
|
408
|
+
return typeof val === "number" && val >= 0;
|
|
412
409
|
}
|
|
413
|
-
function
|
|
414
|
-
|
|
415
|
-
_fail(`Expected number ${min} < ${value} < ${max}.`, msg);
|
|
416
|
-
return true;
|
|
410
|
+
function isZero(val) {
|
|
411
|
+
return typeof val === "number" && val === 0;
|
|
417
412
|
}
|
|
418
|
-
function
|
|
419
|
-
|
|
420
|
-
_fail(`Expected ${value} to be NaN.`, msg);
|
|
421
|
-
return true;
|
|
413
|
+
function isPosZero(val) {
|
|
414
|
+
return typeof val === "number" && val === 0 && 1 / val === Infinity;
|
|
422
415
|
}
|
|
423
|
-
function
|
|
424
|
-
|
|
425
|
-
_fail(`Expected ${value} to be +-Infinity.`, msg);
|
|
426
|
-
return true;
|
|
416
|
+
function isNegZero(val) {
|
|
417
|
+
return typeof val === "number" && val === 0 && 1 / val === -Infinity;
|
|
427
418
|
}
|
|
428
|
-
function
|
|
429
|
-
|
|
430
|
-
_fail(`Expected ${value} to be +Infinity.`, msg);
|
|
431
|
-
return true;
|
|
419
|
+
function isOdd(val) {
|
|
420
|
+
return isInteger(val) && Math.abs(val) % 2 === 1;
|
|
432
421
|
}
|
|
433
|
-
function
|
|
434
|
-
|
|
435
|
-
_fail(`Expected ${value} to be -Infinity.`, msg);
|
|
436
|
-
return true;
|
|
422
|
+
function isEven(val) {
|
|
423
|
+
return isInteger(val) && val % 2 === 0;
|
|
437
424
|
}
|
|
438
|
-
function
|
|
439
|
-
|
|
440
|
-
_fail(`Expected ${value} to odd number.`, msg);
|
|
441
|
-
return true;
|
|
425
|
+
function isMultipleOf(val, base) {
|
|
426
|
+
return typeof val === "number" && typeof base === "number" && val % base === 0;
|
|
442
427
|
}
|
|
443
|
-
function
|
|
444
|
-
|
|
445
|
-
_fail(`Expected ${value} to even number.`, msg);
|
|
446
|
-
return true;
|
|
428
|
+
function isPowerOfTwo(val) {
|
|
429
|
+
return isInteger(val) && val > 0 && (val & val - 1) === 0;
|
|
447
430
|
}
|
|
448
|
-
function isIncluded(
|
|
449
|
-
if (
|
|
450
|
-
|
|
451
|
-
|
|
431
|
+
function isIncluded(val, container) {
|
|
432
|
+
if (isArray(container)) {
|
|
433
|
+
return container.includes(val);
|
|
434
|
+
}
|
|
435
|
+
if (isSet(container)) {
|
|
436
|
+
return container.has(val);
|
|
437
|
+
}
|
|
438
|
+
return false;
|
|
452
439
|
}
|
|
453
|
-
function
|
|
454
|
-
|
|
455
|
-
_fail(`Expected ${index} to be index for array [${array.map((v) => String(v)).join(", ")}]`, msg);
|
|
456
|
-
return true;
|
|
440
|
+
function isIndex(index, array) {
|
|
441
|
+
return isArray(array) ? isIntegerBetween(index, 0, array.length - 1) : isIntegerGte(index, 0);
|
|
457
442
|
}
|
|
458
|
-
function
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
443
|
+
function doesThrow(throwTestFn) {
|
|
444
|
+
try {
|
|
445
|
+
throwTestFn();
|
|
446
|
+
return false;
|
|
447
|
+
} catch (err) {
|
|
448
|
+
return true;
|
|
449
|
+
}
|
|
462
450
|
}
|
|
463
|
-
function
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
451
|
+
function doesNotThrow(throwTestFn) {
|
|
452
|
+
try {
|
|
453
|
+
throwTestFn();
|
|
454
|
+
return true;
|
|
455
|
+
} catch (err) {
|
|
456
|
+
return false;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
function tryOr(tryFn, orVal) {
|
|
460
|
+
try {
|
|
461
|
+
return tryFn();
|
|
462
|
+
} catch (err) {
|
|
463
|
+
return isFunction(orVal) ? orVal() : orVal;
|
|
464
|
+
}
|
|
467
465
|
}
|
|
468
466
|
|
|
469
|
-
// src/
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
accept: () => accept,
|
|
473
|
-
decline: () => decline,
|
|
474
|
-
erase: () => erase,
|
|
475
|
-
eraseAll: () => eraseAll,
|
|
476
|
-
isConsentPending: () => isConsentPending,
|
|
477
|
-
read: () => read,
|
|
478
|
-
readBool: () => readBool,
|
|
479
|
-
readInt: () => readInt,
|
|
480
|
-
save: () => save,
|
|
481
|
-
setExpireDays: () => setExpireDays
|
|
482
|
-
});
|
|
483
|
-
var ConsentCookieName = "ConsentCookie";
|
|
484
|
-
var _consent;
|
|
485
|
-
var _expires;
|
|
486
|
-
var str = _read(ConsentCookieName);
|
|
487
|
-
_consent = str === "accept" /* Accept */ || str === "decline" /* Decline */ ? str : void 0;
|
|
488
|
-
function _getList() {
|
|
489
|
-
let s = document.cookie;
|
|
490
|
-
return s.split(";").map((c) => c.trim());
|
|
467
|
+
// src/utils/obj/index.ts
|
|
468
|
+
function hasProperties(obj, props) {
|
|
469
|
+
return isObject(obj) && props.every((p) => p in obj);
|
|
491
470
|
}
|
|
492
|
-
function
|
|
493
|
-
|
|
494
|
-
if (
|
|
495
|
-
|
|
471
|
+
function deepEqual(a, b) {
|
|
472
|
+
if (a === b) return true;
|
|
473
|
+
if (a === null || b === null) return false;
|
|
474
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
475
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
476
|
+
if (a.length !== b.length) return false;
|
|
477
|
+
return a.every((val, i) => deepEqual(val, b[i]));
|
|
496
478
|
}
|
|
497
|
-
|
|
498
|
-
|
|
479
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
480
|
+
const keysA = Object.keys(a);
|
|
481
|
+
const keysB = Object.keys(b);
|
|
482
|
+
if (keysA.length !== keysB.length) return false;
|
|
483
|
+
for (const key of keysA) {
|
|
484
|
+
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
485
|
+
if (!deepEqual(a[key], b[key])) return false;
|
|
486
|
+
}
|
|
487
|
+
return true;
|
|
499
488
|
}
|
|
500
|
-
function
|
|
501
|
-
|
|
502
|
-
|
|
489
|
+
function getCtorName(obj) {
|
|
490
|
+
if (obj === null) return "null";
|
|
491
|
+
if (isArray(obj)) return "Array";
|
|
492
|
+
if (typeof obj !== "object") return typeof obj;
|
|
493
|
+
const tag = Object.prototype.toString.call(obj).slice(8, -1);
|
|
494
|
+
return tag || "Object";
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// src/utils/str/index.ts
|
|
498
|
+
function toCharArray(str2) {
|
|
499
|
+
return str2.split("");
|
|
500
|
+
}
|
|
501
|
+
function repeatString(repeatString2, repeatCount) {
|
|
502
|
+
if (!isInteger(repeatCount) || repeatCount < 0) {
|
|
503
|
+
throw new Error("repeatStr: Invalid repeatCount = " + repeatCount);
|
|
504
|
+
}
|
|
505
|
+
return new Array(repeatCount + 1).join(repeatString2);
|
|
506
|
+
}
|
|
507
|
+
function chunkString(str2, chunkSize) {
|
|
508
|
+
if (!isInteger(chunkSize) || chunkSize < 1) {
|
|
509
|
+
throw new Error("chunckString: Invalid chuckSize = " + chunkSize);
|
|
510
|
+
}
|
|
511
|
+
let result = [];
|
|
512
|
+
for (let i = 0; i < str2.length; i += chunkSize) {
|
|
513
|
+
result.push(str2.slice(i, i + chunkSize));
|
|
514
|
+
}
|
|
515
|
+
return result;
|
|
516
|
+
}
|
|
517
|
+
function replaceAt(str2, pos, removeCount, insert) {
|
|
518
|
+
if (!isInteger(removeCount) || removeCount < 0) {
|
|
519
|
+
throw new Error("replaceAt: Invalid removeCount = " + removeCount);
|
|
520
|
+
} else if (!isInteger(pos) || pos < 0 || pos + removeCount > str2.length) {
|
|
521
|
+
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " + str2.length);
|
|
522
|
+
} else {
|
|
523
|
+
return str2.substring(0, pos) + insert + str2.substring(pos + removeCount);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
function insertAt(str2, pos, insertStr) {
|
|
527
|
+
return replaceAt(str2, pos, 0, insertStr);
|
|
528
|
+
}
|
|
529
|
+
function removeAt(str2, pos, removeCount) {
|
|
530
|
+
return replaceAt(str2, pos, removeCount, "");
|
|
531
|
+
}
|
|
532
|
+
function charCount(str2, ch) {
|
|
533
|
+
if (ch.length !== 1 || str2.length === 0) return 0;
|
|
534
|
+
let count = 0;
|
|
535
|
+
for (let i = 0; i < str2.length; i++) {
|
|
536
|
+
if (str2[i] === ch) count++;
|
|
537
|
+
}
|
|
538
|
+
return count;
|
|
539
|
+
}
|
|
540
|
+
function makeSentenceFromPascal(PascalString) {
|
|
541
|
+
if (PascalString === "") {
|
|
542
|
+
return "";
|
|
543
|
+
}
|
|
544
|
+
let word = PascalString.charAt(0);
|
|
545
|
+
let sentence = "";
|
|
546
|
+
const addWord = () => {
|
|
547
|
+
if (word !== "") {
|
|
548
|
+
if (sentence === "") {
|
|
549
|
+
sentence += word.charAt(0).toUpperCase() + word.substring(1);
|
|
550
|
+
} else {
|
|
551
|
+
sentence += " " + word;
|
|
552
|
+
}
|
|
553
|
+
word = "";
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
const isLetterAndCapital = (c) => {
|
|
557
|
+
return c.toUpperCase() !== c.toLowerCase() && c === c.toUpperCase();
|
|
558
|
+
};
|
|
559
|
+
for (let i = 1; i < PascalString.length; i++) {
|
|
560
|
+
let c = PascalString.charAt(i);
|
|
561
|
+
if (isLetterAndCapital(c)) {
|
|
562
|
+
addWord();
|
|
563
|
+
}
|
|
564
|
+
word += c.toLowerCase();
|
|
565
|
+
}
|
|
566
|
+
addWord();
|
|
567
|
+
return sentence;
|
|
568
|
+
}
|
|
569
|
+
function stringify(value, maxDepth = 5, seen = /* @__PURE__ */ new WeakSet()) {
|
|
570
|
+
if (value === null) return "null";
|
|
571
|
+
if (value === void 0) return "undefined";
|
|
572
|
+
const t = typeof value;
|
|
573
|
+
switch (t) {
|
|
574
|
+
case "boolean":
|
|
575
|
+
return value ? "true" : "false";
|
|
576
|
+
case "number":
|
|
577
|
+
if (isNaNValue(value)) return "NaN";
|
|
578
|
+
if (!isFinite2(value))
|
|
579
|
+
return value < 0 ? "-Infinity" : "Infinity";
|
|
580
|
+
return value.toString();
|
|
581
|
+
case "bigint":
|
|
582
|
+
return `${value}n`;
|
|
583
|
+
case "string":
|
|
584
|
+
return `"${value}"`;
|
|
585
|
+
case "symbol":
|
|
586
|
+
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
587
|
+
case "function":
|
|
588
|
+
return `[Function${value.name ? ` ${value.name}` : ""}]`;
|
|
589
|
+
}
|
|
590
|
+
if (seen.has(value))
|
|
591
|
+
return "[Circular]";
|
|
592
|
+
if (maxDepth <= 0)
|
|
593
|
+
return "[Depth limit]";
|
|
594
|
+
maxDepth--;
|
|
595
|
+
seen.add(value);
|
|
596
|
+
const strfy = (v) => stringify(v, maxDepth, seen);
|
|
597
|
+
if (isArray(value)) {
|
|
598
|
+
const inner = value.map((v) => strfy(v)).join(", ");
|
|
599
|
+
return inner.length === 0 ? "[ ]" : `[ ${inner} ]`;
|
|
600
|
+
}
|
|
601
|
+
if (ArrayBuffer.isView(value)) {
|
|
602
|
+
if (value instanceof DataView)
|
|
603
|
+
return `DataView(${value.byteLength})`;
|
|
604
|
+
const inner = Array.from(value).map((v) => strfy(v)).join(", ");
|
|
605
|
+
return `${value.constructor.name}[ ${inner} ]`;
|
|
606
|
+
}
|
|
607
|
+
if (value instanceof ArrayBuffer)
|
|
608
|
+
return `ArrayBuffer(${value.byteLength})`;
|
|
609
|
+
if (value instanceof Map) {
|
|
610
|
+
const entries = Array.from(value.entries()).map(([k, v]) => `${strfy(k)} => ${strfy(v)}`).join(", ");
|
|
611
|
+
return entries.length === 0 ? `Map(${value.size}){ }` : `Map(${value.size}){ ${entries} }`;
|
|
612
|
+
}
|
|
613
|
+
if (value instanceof Set) {
|
|
614
|
+
const entries = Array.from(value.values()).map((v) => strfy(v)).join(", ");
|
|
615
|
+
return entries.length === 0 ? `Set(${value.size}){ }` : `Set(${value.size}){ ${entries} }`;
|
|
616
|
+
}
|
|
617
|
+
if (value instanceof WeakMap)
|
|
618
|
+
return "WeakMap{ ? }";
|
|
619
|
+
if (value instanceof WeakSet)
|
|
620
|
+
return "WeakSet{ ? }";
|
|
621
|
+
if (value instanceof Date)
|
|
622
|
+
return `Date("${value.toISOString()}")`;
|
|
623
|
+
if (value instanceof RegExp)
|
|
624
|
+
return value.toString();
|
|
625
|
+
if (value instanceof Error)
|
|
626
|
+
return `${value.name}("${value.message}")`;
|
|
627
|
+
if (value instanceof Promise)
|
|
628
|
+
return "Promise{ ? }";
|
|
629
|
+
if (value instanceof URL)
|
|
630
|
+
return `URL("${value.href}")`;
|
|
631
|
+
if (value instanceof URLSearchParams)
|
|
632
|
+
return `URLSearchParams("${value.toString()}")`;
|
|
633
|
+
if (value === Math) return "Math";
|
|
634
|
+
if (value === JSON) return "JSON";
|
|
635
|
+
if (value === Reflect) return "Reflect";
|
|
636
|
+
if (value === Intl) return "Intl";
|
|
637
|
+
const hasCustomToString = typeof value?.toString === "function" && value.toString !== Object.prototype.toString;
|
|
638
|
+
if (hasCustomToString) {
|
|
639
|
+
try {
|
|
640
|
+
const str2 = value.toString();
|
|
641
|
+
if (!/^\[object .+\]$/.test(str2)) return str2;
|
|
642
|
+
} catch {
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
if (t === "object") {
|
|
646
|
+
const ctorName = getCtorName(value);
|
|
647
|
+
const entries = Object.entries(value).map(
|
|
648
|
+
([key, val]) => `${strfy(key)}: ${strfy(val)}`
|
|
649
|
+
);
|
|
650
|
+
if (entries.length === 0) return `${ctorName}{ }`;
|
|
651
|
+
return `${ctorName}{ ${entries.join(", ")} }`;
|
|
652
|
+
}
|
|
653
|
+
return String(value);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// src/assert/index.ts
|
|
657
|
+
var fmt = stringify;
|
|
658
|
+
var errorConstructor = Error;
|
|
659
|
+
function setErrorClass(errorClass) {
|
|
660
|
+
errorConstructor = errorClass ?? Error;
|
|
661
|
+
}
|
|
662
|
+
function _fail(...msgs) {
|
|
663
|
+
let msg = msgs.join(", ");
|
|
664
|
+
throw new errorConstructor("Assertion Failed!" + (msg === "" ? "" : " " + msg));
|
|
665
|
+
}
|
|
666
|
+
function assert(condition, msg) {
|
|
667
|
+
if (!condition) {
|
|
668
|
+
_fail(msg);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
function require2(val, msg) {
|
|
672
|
+
if (val == null) {
|
|
673
|
+
_fail(`Expected ${fmt(val)} not to be nullish`, msg);
|
|
674
|
+
}
|
|
675
|
+
return val;
|
|
676
|
+
}
|
|
677
|
+
function requireDefined(val, msg) {
|
|
678
|
+
if (val === void 0) {
|
|
679
|
+
_fail(`Expected ${fmt(val)} not to be undefined`, msg);
|
|
680
|
+
}
|
|
681
|
+
return val;
|
|
682
|
+
}
|
|
683
|
+
function requireElement(index, array, msg) {
|
|
684
|
+
if (!guard_exports.isIndex(index, array))
|
|
685
|
+
_fail(`Expected ${index} to be index for array ${fmt(array)}`, msg);
|
|
686
|
+
return array[index];
|
|
687
|
+
}
|
|
688
|
+
function fail(msg) {
|
|
689
|
+
_fail(msg);
|
|
690
|
+
}
|
|
691
|
+
function isStrictEqual2(val1, val2, msg) {
|
|
692
|
+
if (!guard_exports.isStrictEqual(val1, val2))
|
|
693
|
+
_fail(`Expected ${fmt(val1)} to ne strict equal to ${val2}`, msg);
|
|
694
|
+
return val1;
|
|
695
|
+
}
|
|
696
|
+
function isDeepEqual2(val1, val2, msg) {
|
|
697
|
+
if (!guard_exports.isDeepEqual(val1, val2))
|
|
698
|
+
_fail(`Expected ${fmt(val1)} to deep equal with ${fmt(val2)}`, msg);
|
|
699
|
+
return val1;
|
|
700
|
+
}
|
|
701
|
+
function isUndefined2(val, msg) {
|
|
702
|
+
if (!guard_exports.isUndefined(val))
|
|
703
|
+
_fail(`Expected ${fmt(val)} to be undefined`, msg);
|
|
704
|
+
return val;
|
|
705
|
+
}
|
|
706
|
+
function isNull2(val, msg) {
|
|
707
|
+
if (!guard_exports.isNull(val))
|
|
708
|
+
_fail(`Expected ${fmt(val)} to be null`, msg);
|
|
709
|
+
return val;
|
|
710
|
+
}
|
|
711
|
+
function isNullish2(val, msg) {
|
|
712
|
+
if (!guard_exports.isNullish(val))
|
|
713
|
+
_fail(`Expected ${fmt(val)} to be null or undefined`, msg);
|
|
714
|
+
return val;
|
|
715
|
+
}
|
|
716
|
+
function isDefined2(val, msg) {
|
|
717
|
+
if (!guard_exports.isDefined(val)) {
|
|
718
|
+
_fail(`Expected ${fmt(val)} to be defined`, msg);
|
|
719
|
+
}
|
|
720
|
+
return val;
|
|
721
|
+
}
|
|
722
|
+
function isNonNull2(val, msg) {
|
|
723
|
+
if (!guard_exports.isNonNull(val)) {
|
|
724
|
+
_fail(`Expected ${fmt(val)} to be defined`, msg);
|
|
725
|
+
}
|
|
726
|
+
return val;
|
|
727
|
+
}
|
|
728
|
+
function isObject2(val, msg) {
|
|
729
|
+
if (!guard_exports.isObject(val))
|
|
730
|
+
_fail(`Expected ${fmt(val)} to be object`, msg);
|
|
731
|
+
return val;
|
|
732
|
+
}
|
|
733
|
+
function isEmptyObject2(val, msg) {
|
|
734
|
+
if (!guard_exports.isEmptyObject(val))
|
|
735
|
+
_fail(`Expected ${fmt(val)} to be empty object`, msg);
|
|
736
|
+
return val;
|
|
737
|
+
}
|
|
738
|
+
function isPlainObject2(val, msg) {
|
|
739
|
+
if (!guard_exports.isPlainObject(val))
|
|
740
|
+
_fail(`Expected ${fmt(val)} to be plain object`, msg);
|
|
741
|
+
return val;
|
|
742
|
+
}
|
|
743
|
+
function isObjectOrUndefined2(val, msg) {
|
|
744
|
+
if (!guard_exports.isObjectOrUndefined(val))
|
|
745
|
+
_fail(`Expected ${fmt(val)} to be object or undefined`, msg);
|
|
746
|
+
return val;
|
|
747
|
+
}
|
|
748
|
+
function isTypedObject2(val, keys, msg) {
|
|
749
|
+
if (!guard_exports.isTypedObject(val, keys))
|
|
750
|
+
_fail(`Expected ${fmt(val)} to have keys ${fmt(keys)}`, msg);
|
|
751
|
+
return val;
|
|
752
|
+
}
|
|
753
|
+
function isArray2(val, msg) {
|
|
754
|
+
if (!guard_exports.isArray(val))
|
|
755
|
+
_fail(`Expected ${fmt(val)} to be array`, msg);
|
|
756
|
+
return val;
|
|
757
|
+
}
|
|
758
|
+
function isArrayOrUndefined2(val, msg) {
|
|
759
|
+
if (!guard_exports.isArrayOrUndefined(val))
|
|
760
|
+
_fail(`Expected ${fmt(val)} to be array or undefined`, msg);
|
|
761
|
+
return true;
|
|
762
|
+
}
|
|
763
|
+
function isEmptyArray2(val, msg) {
|
|
764
|
+
if (!guard_exports.isEmptyArray(val))
|
|
765
|
+
_fail(`Expected ${fmt(val)} to be empty array`, msg);
|
|
766
|
+
}
|
|
767
|
+
function isNonEmptyArray2(val, msg) {
|
|
768
|
+
if (!guard_exports.isNonEmptyArray(val))
|
|
769
|
+
_fail(`Expected ${fmt(val)} to be non-empty array`, msg);
|
|
770
|
+
}
|
|
771
|
+
function isEmptyArrayOrUndefined2(val, msg) {
|
|
772
|
+
if (!guard_exports.isEmptyArrayOrUndefined(val))
|
|
773
|
+
_fail(`Expected ${fmt(val)} to be empty array or undefined`, msg);
|
|
774
|
+
}
|
|
775
|
+
function isNonEmptyArrayOrUndefined2(val, msg) {
|
|
776
|
+
if (!guard_exports.isNonEmptyArrayOrUndefined(val))
|
|
777
|
+
_fail(`Expected ${fmt(val)} to be non-empty array or undefined`, msg);
|
|
778
|
+
}
|
|
779
|
+
function isString2(val, msg) {
|
|
780
|
+
if (!guard_exports.isString(val))
|
|
781
|
+
_fail(`Expected ${fmt(val)} to be string`, msg);
|
|
782
|
+
return val;
|
|
783
|
+
}
|
|
784
|
+
function isEmptyString2(val, msg) {
|
|
785
|
+
if (!guard_exports.isEmptyString(val))
|
|
786
|
+
_fail(`Expected ${fmt(val)} to be empty string`, msg);
|
|
787
|
+
return val;
|
|
788
|
+
}
|
|
789
|
+
function isNonEmptyString2(val, msg) {
|
|
790
|
+
if (!guard_exports.isNonEmptyString(val))
|
|
791
|
+
_fail(`Expected ${fmt(val)} to be non-empty string`, msg);
|
|
792
|
+
return val;
|
|
793
|
+
}
|
|
794
|
+
function isStringOrUndefined2(val, msg) {
|
|
795
|
+
if (!guard_exports.isStringOrUndefined(val))
|
|
796
|
+
_fail(`Expected ${fmt(val)} to be string or undefined`, msg);
|
|
797
|
+
return val;
|
|
798
|
+
}
|
|
799
|
+
function isEmptyStringOrUndefined2(val, msg) {
|
|
800
|
+
if (!guard_exports.isEmptyStringOrUndefined(val))
|
|
801
|
+
_fail(`Expected ${fmt(val)} to be empty string or undefined`, msg);
|
|
802
|
+
return val;
|
|
803
|
+
}
|
|
804
|
+
function isNonEmptyStringOrUndefined2(val, msg) {
|
|
805
|
+
if (!guard_exports.isNonEmptyStringOrUndefined(val))
|
|
806
|
+
_fail(`Expected ${fmt(val)} to be non-empty string or undefined`, msg);
|
|
807
|
+
return val;
|
|
808
|
+
}
|
|
809
|
+
function isBoolean2(val, msg) {
|
|
810
|
+
if (!guard_exports.isBoolean(val))
|
|
811
|
+
_fail(`Expected ${fmt(val)} to be boolean`, msg);
|
|
812
|
+
return val;
|
|
813
|
+
}
|
|
814
|
+
function isBooleanOrUndefined2(val, msg) {
|
|
815
|
+
if (!guard_exports.isBooleanOrUndefined(val))
|
|
816
|
+
_fail(`Expected ${fmt(val)} to be boolean or undefined`, msg);
|
|
817
|
+
return val;
|
|
818
|
+
}
|
|
819
|
+
function isTrue2(val, msg) {
|
|
820
|
+
if (!guard_exports.isTrue(val))
|
|
821
|
+
_fail(`Expected ${fmt(val)} to be true`, msg);
|
|
822
|
+
return val;
|
|
823
|
+
}
|
|
824
|
+
function isTrueOrUndefined2(val, msg) {
|
|
825
|
+
if (!guard_exports.isTrueOrUndefined(val))
|
|
826
|
+
_fail(`Expected ${fmt(val)} to be true or undefined`, msg);
|
|
827
|
+
return val;
|
|
828
|
+
}
|
|
829
|
+
function isFalse2(val, msg) {
|
|
830
|
+
if (!guard_exports.isFalse(val))
|
|
831
|
+
_fail(`Expected ${fmt(val)} to be false`, msg);
|
|
832
|
+
return val;
|
|
833
|
+
}
|
|
834
|
+
function isFalseOrUndefined2(val, msg) {
|
|
835
|
+
if (!guard_exports.isFalseOrUndefined(val))
|
|
836
|
+
_fail(`Expected ${fmt(val)} to be false or undefined`, msg);
|
|
837
|
+
return val;
|
|
838
|
+
}
|
|
839
|
+
function isFunction2(val, msg) {
|
|
840
|
+
if (!guard_exports.isFunction(val))
|
|
841
|
+
_fail(`Expected ${fmt(val)} to be function`, msg);
|
|
842
|
+
return val;
|
|
843
|
+
}
|
|
844
|
+
function isFunctionOrUndefined2(val, msg) {
|
|
845
|
+
if (!guard_exports.isFunctionOrUndefined(val))
|
|
846
|
+
_fail(`Expected ${fmt(val)} to be function or undefined`, msg);
|
|
847
|
+
return val;
|
|
848
|
+
}
|
|
849
|
+
function isEnumValue2(val, enumObject, msg) {
|
|
850
|
+
if (!guard_exports.isEnumValue(val, enumObject))
|
|
851
|
+
_fail(`Expected ${fmt(val)} to be enum val`, msg);
|
|
852
|
+
return val;
|
|
853
|
+
}
|
|
854
|
+
function isEnumValueOrUndefined2(val, enumObject, msg) {
|
|
855
|
+
if (!guard_exports.isEnumValueOrUndefined(val, enumObject))
|
|
856
|
+
_fail(`Expected ${fmt(val)} to be enum val or undefined`, msg);
|
|
857
|
+
return val;
|
|
858
|
+
}
|
|
859
|
+
function isNumericString2(val, msg) {
|
|
860
|
+
if (!guard_exports.isNumericString(val))
|
|
861
|
+
_fail(`Expected ${fmt(val)} to be numeric string`, msg);
|
|
862
|
+
return val;
|
|
863
|
+
}
|
|
864
|
+
function isBigInt2(val, msg) {
|
|
865
|
+
if (!guard_exports.isBigInt(val))
|
|
866
|
+
_fail(`Expected ${fmt(val)} to be BigInt`, msg);
|
|
867
|
+
return val;
|
|
868
|
+
}
|
|
869
|
+
function isNumber2(val, msg) {
|
|
870
|
+
if (!guard_exports.isNumber(val))
|
|
871
|
+
_fail(`Expected ${fmt(val)} to be number`, msg);
|
|
872
|
+
return val;
|
|
873
|
+
}
|
|
874
|
+
function isNumberOrUndefined2(val, msg) {
|
|
875
|
+
if (!guard_exports.isNumberOrUndefined(val))
|
|
876
|
+
_fail(`Expected ${fmt(val)} to be number or undefined`, msg);
|
|
877
|
+
return val;
|
|
878
|
+
}
|
|
879
|
+
function isFinite3(val, msg) {
|
|
880
|
+
if (!guard_exports.isFinite(val))
|
|
881
|
+
_fail(`Expected ${fmt(val)} to be finite`, msg);
|
|
882
|
+
return val;
|
|
883
|
+
}
|
|
884
|
+
function isFloat2(val, msg) {
|
|
885
|
+
if (!guard_exports.isFloat(val))
|
|
886
|
+
_fail(`Expected ${fmt(val)} to be float`, msg);
|
|
887
|
+
return val;
|
|
888
|
+
}
|
|
889
|
+
function isInteger2(val, msg) {
|
|
890
|
+
if (!guard_exports.isInteger(val))
|
|
891
|
+
_fail(`Expected ${fmt(val)} to be integer`, msg);
|
|
892
|
+
return val;
|
|
893
|
+
}
|
|
894
|
+
function isSafeInteger2(val, msg) {
|
|
895
|
+
if (!guard_exports.isSafeInteger(val))
|
|
896
|
+
_fail(`Expected ${fmt(val)} to be safe integer`, msg);
|
|
897
|
+
return val;
|
|
898
|
+
}
|
|
899
|
+
function isIntegerOrUndefined2(val, msg) {
|
|
900
|
+
if (!guard_exports.isIntegerOrUndefined(val))
|
|
901
|
+
_fail(`Expected ${fmt(val)} to be integer or undefined`, msg);
|
|
902
|
+
return val;
|
|
903
|
+
}
|
|
904
|
+
function isIntegerEq2(val, ref, msg) {
|
|
905
|
+
if (!guard_exports.isIntegerEq(val, ref))
|
|
906
|
+
_fail(`Expected ${fmt(val)} to be integer equal to ${fmt(ref)}`, msg);
|
|
907
|
+
return val;
|
|
908
|
+
}
|
|
909
|
+
function isIntegerGt2(val, ref, msg) {
|
|
910
|
+
if (!guard_exports.isIntegerGt(val, ref))
|
|
911
|
+
_fail(`Expected ${fmt(val)} to be integer > ${fmt(ref)}`, msg);
|
|
912
|
+
return val;
|
|
913
|
+
}
|
|
914
|
+
function isIntegerGte2(val, ref, msg) {
|
|
915
|
+
if (!guard_exports.isIntegerGte(val, ref))
|
|
916
|
+
_fail(`Expected ${fmt(val)} to be integer >= ${fmt(ref)}`, msg);
|
|
917
|
+
return val;
|
|
918
|
+
}
|
|
919
|
+
function isIntegerLt2(val, ref, msg) {
|
|
920
|
+
if (!guard_exports.isIntegerLt(val, ref))
|
|
921
|
+
_fail(`Expected ${fmt(val)} to be integer < ${fmt(ref)}`, msg);
|
|
922
|
+
return val;
|
|
923
|
+
}
|
|
924
|
+
function isIntegerLte2(val, ref, msg) {
|
|
925
|
+
if (!guard_exports.isIntegerLte(val, ref))
|
|
926
|
+
_fail(`Expected ${fmt(val)} to be integer <= ${fmt(ref)}`, msg);
|
|
927
|
+
return val;
|
|
928
|
+
}
|
|
929
|
+
function isIntegerBetween2(val, min, max, msg) {
|
|
930
|
+
if (!guard_exports.isIntegerBetween(val, min, max))
|
|
931
|
+
_fail(`Expected integer ${fmt(min)} <= ${fmt(val)} <= ${fmt(max)}`, msg);
|
|
932
|
+
return val;
|
|
933
|
+
}
|
|
934
|
+
function isIntegerBetweenExclusive2(val, min, max, msg) {
|
|
935
|
+
if (!guard_exports.isIntegerBetweenExclusive(val, min, max))
|
|
936
|
+
_fail(`Expected integer ${fmt(min)} < ${fmt(val)} < ${fmt(max)}`, msg);
|
|
937
|
+
return val;
|
|
938
|
+
}
|
|
939
|
+
function isNumberBetween2(val, min, max, msg) {
|
|
940
|
+
if (!guard_exports.isNumberBetween(val, min, max))
|
|
941
|
+
_fail(`Expected number ${fmt(min)} <= ${fmt(val)} <= ${fmt(max)}`, msg);
|
|
942
|
+
return val;
|
|
943
|
+
}
|
|
944
|
+
function isNumberBetweenExclusive2(val, min, max, msg) {
|
|
945
|
+
if (!guard_exports.isNumberBetweenExclusive(val, min, max))
|
|
946
|
+
_fail(`Expected number ${fmt(min)} < ${fmt(val)} < ${fmt(max)}`, msg);
|
|
947
|
+
return val;
|
|
948
|
+
}
|
|
949
|
+
function isNaNValue2(val, msg) {
|
|
950
|
+
if (!guard_exports.isNaNValue(val))
|
|
951
|
+
_fail(`Expected ${fmt(val)} to be NaN`, msg);
|
|
952
|
+
return NaN;
|
|
953
|
+
}
|
|
954
|
+
function isInfinity2(val, msg) {
|
|
955
|
+
if (!guard_exports.isInfinity(val))
|
|
956
|
+
_fail(`Expected ${fmt(val)} to be +-Infinity`, msg);
|
|
957
|
+
return val;
|
|
958
|
+
}
|
|
959
|
+
function isPosInfinity2(val, msg) {
|
|
960
|
+
if (!guard_exports.isPosInfinity(val))
|
|
961
|
+
_fail(`Expected ${fmt(val)} to be +Infinity`, msg);
|
|
962
|
+
return val;
|
|
963
|
+
}
|
|
964
|
+
function isNegInfinity2(val, msg) {
|
|
965
|
+
if (!guard_exports.isNegInfinity(val))
|
|
966
|
+
_fail(`Expected ${fmt(val)} to be -Infinity`, msg);
|
|
967
|
+
return val;
|
|
968
|
+
}
|
|
969
|
+
function isPos2(val, msg) {
|
|
970
|
+
if (!guard_exports.isPos(val))
|
|
971
|
+
_fail(`Expected ${fmt(val)} to be positive (> 0)`, msg);
|
|
972
|
+
return val;
|
|
973
|
+
}
|
|
974
|
+
function isNeg2(val, msg) {
|
|
975
|
+
if (!guard_exports.isNeg(val))
|
|
976
|
+
_fail(`Expected ${fmt(val)} to be negative (< 0)`, msg);
|
|
977
|
+
return val;
|
|
978
|
+
}
|
|
979
|
+
function isNonPos2(val, msg) {
|
|
980
|
+
if (!guard_exports.isNonPos(val))
|
|
981
|
+
_fail(`Expected ${fmt(val)} to be non-positive (<= 0)`, msg);
|
|
982
|
+
return val;
|
|
983
|
+
}
|
|
984
|
+
function isNonNeg2(val, msg) {
|
|
985
|
+
if (!guard_exports.isNonNeg(val))
|
|
986
|
+
_fail(`Expected ${fmt(val)} to be non-negative (>= 0)`, msg);
|
|
987
|
+
return val;
|
|
988
|
+
}
|
|
989
|
+
function isZero2(val, msg) {
|
|
990
|
+
if (!guard_exports.isZero(val))
|
|
991
|
+
_fail(`Expected ${fmt(val)} to be 0`, msg);
|
|
992
|
+
return val;
|
|
993
|
+
}
|
|
994
|
+
function isPosZero2(val, msg) {
|
|
995
|
+
if (!guard_exports.isPosZero(val))
|
|
996
|
+
_fail(`Expected ${fmt(val)} to be +0`, msg);
|
|
997
|
+
return val;
|
|
998
|
+
}
|
|
999
|
+
function isNegZero2(val, msg) {
|
|
1000
|
+
if (!guard_exports.isNegZero(val))
|
|
1001
|
+
_fail(`Expected ${fmt(val)} to be -0`, msg);
|
|
1002
|
+
return val;
|
|
1003
|
+
}
|
|
1004
|
+
function isOdd2(val, msg) {
|
|
1005
|
+
if (!guard_exports.isOdd(val))
|
|
1006
|
+
_fail(`Expected ${fmt(val)} to odd`, msg);
|
|
1007
|
+
return val;
|
|
1008
|
+
}
|
|
1009
|
+
function isEven2(val, msg) {
|
|
1010
|
+
if (!guard_exports.isEven(val))
|
|
1011
|
+
_fail(`Expected ${fmt(val)} to even`, msg);
|
|
1012
|
+
return val;
|
|
1013
|
+
}
|
|
1014
|
+
function isMultipleOf2(val, base, msg) {
|
|
1015
|
+
if (!guard_exports.isMultipleOf(val, base))
|
|
1016
|
+
_fail(`Expected ${fmt(val)} to be divisble bu ${fmt(base)}`, msg);
|
|
1017
|
+
return val;
|
|
1018
|
+
}
|
|
1019
|
+
function isPowerOfTwo2(val, msg) {
|
|
1020
|
+
if (!guard_exports.isPowerOfTwo(val))
|
|
1021
|
+
_fail(`Expected ${fmt(val)} to be power of two`, msg);
|
|
1022
|
+
return val;
|
|
1023
|
+
}
|
|
1024
|
+
function isIncluded2(val, arr, msg) {
|
|
1025
|
+
if (!guard_exports.isIncluded(val, arr))
|
|
1026
|
+
_fail(`Expected ${fmt(val)} to be included in ${fmt(arr)}`, msg);
|
|
1027
|
+
return val;
|
|
1028
|
+
}
|
|
1029
|
+
function isIndex2(...args) {
|
|
1030
|
+
const index = args.shift();
|
|
1031
|
+
const msg = guard_exports.isString(args[args.length - 1]) ? args.pop() : void 0;
|
|
1032
|
+
const arr = guard_exports.isArray(args[0]) ? args.shift() : void 0;
|
|
1033
|
+
if (!guard_exports.isIndex(index, arr)) {
|
|
1034
|
+
if (arr === void 0)
|
|
1035
|
+
_fail(`Expected ${index} to be index`, msg);
|
|
1036
|
+
else
|
|
1037
|
+
_fail(`Expected ${index} to be index for ${fmt(arr)}`, msg);
|
|
1038
|
+
}
|
|
1039
|
+
return index;
|
|
1040
|
+
}
|
|
1041
|
+
function doesThrow2(throwTestFn, msg) {
|
|
1042
|
+
if (!guard_exports.doesThrow(throwTestFn))
|
|
1043
|
+
_fail(`Expected to throw`, msg);
|
|
1044
|
+
return true;
|
|
1045
|
+
}
|
|
1046
|
+
function doesNotThrow2(throwTestFn, msg) {
|
|
1047
|
+
if (!guard_exports.doesNotThrow(throwTestFn))
|
|
1048
|
+
_fail(`Expected to throw`, msg);
|
|
1049
|
+
return true;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
// src/web/cookies.ts
|
|
1053
|
+
var cookies_exports = {};
|
|
1054
|
+
__export(cookies_exports, {
|
|
1055
|
+
accept: () => accept,
|
|
1056
|
+
decline: () => decline,
|
|
1057
|
+
erase: () => erase,
|
|
1058
|
+
eraseAll: () => eraseAll,
|
|
1059
|
+
isConsentPending: () => isConsentPending,
|
|
1060
|
+
read: () => read,
|
|
1061
|
+
readBool: () => readBool,
|
|
1062
|
+
readInt: () => readInt,
|
|
1063
|
+
save: () => save,
|
|
1064
|
+
setExpireDays: () => setExpireDays
|
|
1065
|
+
});
|
|
1066
|
+
var ConsentCookieName = "ConsentCookie";
|
|
1067
|
+
var _consent;
|
|
1068
|
+
var _expires;
|
|
1069
|
+
var str = _read(ConsentCookieName);
|
|
1070
|
+
_consent = str === "accept" /* Accept */ || str === "decline" /* Decline */ ? str : void 0;
|
|
1071
|
+
function _getList() {
|
|
1072
|
+
let s = document.cookie;
|
|
1073
|
+
return s.split(";").map((c) => c.trim());
|
|
1074
|
+
}
|
|
1075
|
+
function _save(name, value) {
|
|
1076
|
+
let cookie = name + "=" + value.toString() + ";sameSite=Lax;";
|
|
1077
|
+
if (_expires) {
|
|
1078
|
+
cookie += "expires=" + _expires.toUTCString() + ";";
|
|
1079
|
+
}
|
|
1080
|
+
document.cookie = cookie;
|
|
1081
|
+
return value;
|
|
1082
|
+
}
|
|
1083
|
+
function _read(name, defaultValue) {
|
|
1084
|
+
let str2 = _getList().find((c) => c.startsWith(name + "="));
|
|
1085
|
+
return str2 === void 0 ? defaultValue : str2.substring(name.length + 1);
|
|
503
1086
|
}
|
|
504
1087
|
function _erase(name) {
|
|
505
1088
|
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
|
|
@@ -673,319 +1256,12 @@ function toPx(input) {
|
|
|
673
1256
|
}
|
|
674
1257
|
}
|
|
675
1258
|
|
|
676
|
-
// src/guard/index.ts
|
|
677
|
-
var guard_exports = {};
|
|
678
|
-
__export(guard_exports, {
|
|
679
|
-
isArray: () => isArray2,
|
|
680
|
-
isArrayIndex: () => isArrayIndex2,
|
|
681
|
-
isArrayOrUndefined: () => isArrayOrUndefined2,
|
|
682
|
-
isBoolean: () => isBoolean2,
|
|
683
|
-
isBooleanOrUndefined: () => isBooleanOrUndefined2,
|
|
684
|
-
isDeepEqual: () => isDeepEqual2,
|
|
685
|
-
isEmptyArray: () => isEmptyArray2,
|
|
686
|
-
isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined2,
|
|
687
|
-
isEmptyString: () => isEmptyString2,
|
|
688
|
-
isEmptyStringOrUndefined: () => isEmptyStringOrUndefined2,
|
|
689
|
-
isEnumValue: () => isEnumValue3,
|
|
690
|
-
isEnumValueOrUndefined: () => isEnumValueOrUndefined2,
|
|
691
|
-
isEqual: () => isEqual2,
|
|
692
|
-
isEvenNumber: () => isEvenNumber2,
|
|
693
|
-
isFalse: () => isFalse2,
|
|
694
|
-
isFalseOrUndefined: () => isFalseOrUndefined2,
|
|
695
|
-
isFinite: () => isFinite3,
|
|
696
|
-
isFunction: () => isFunction2,
|
|
697
|
-
isFunctionOrUndefined: () => isFunctionOrUndefined2,
|
|
698
|
-
isIncluded: () => isIncluded2,
|
|
699
|
-
isInfinity: () => isInfinity2,
|
|
700
|
-
isInteger: () => isInteger2,
|
|
701
|
-
isIntegerBetween: () => isIntegerBetween2,
|
|
702
|
-
isIntegerBetweenExclusive: () => isIntegerBetweenExclusive2,
|
|
703
|
-
isIntegerEq: () => isIntegerEq2,
|
|
704
|
-
isIntegerGt: () => isIntegerGt2,
|
|
705
|
-
isIntegerGte: () => isIntegerGte2,
|
|
706
|
-
isIntegerLt: () => isIntegerLt2,
|
|
707
|
-
isIntegerLte: () => isIntegerLte2,
|
|
708
|
-
isIntegerOrUndefined: () => isIntegerOrUndefined2,
|
|
709
|
-
isNaNValue: () => isNaNValue2,
|
|
710
|
-
isNegInfinity: () => isNegInfinity2,
|
|
711
|
-
isNonEmptyArray: () => isNonEmptyArray2,
|
|
712
|
-
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined2,
|
|
713
|
-
isNonEmptyString: () => isNonEmptyString2,
|
|
714
|
-
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined2,
|
|
715
|
-
isNotThrowing: () => isNotThrowing2,
|
|
716
|
-
isNull: () => isNull2,
|
|
717
|
-
isNullish: () => isNullish2,
|
|
718
|
-
isNumber: () => isNumber2,
|
|
719
|
-
isNumberBetween: () => isNumberBetween2,
|
|
720
|
-
isNumberBetweenExclusive: () => isNumberBetweenExclusive2,
|
|
721
|
-
isNumberOrUndefined: () => isNumberOrUndefined2,
|
|
722
|
-
isObject: () => isObject2,
|
|
723
|
-
isObjectOrUndefined: () => isObjectOrUndefined2,
|
|
724
|
-
isOddNumber: () => isOddNumber2,
|
|
725
|
-
isPosInfinity: () => isPosInfinity2,
|
|
726
|
-
isString: () => isString2,
|
|
727
|
-
isStringOrUndefined: () => isStringOrUndefined2,
|
|
728
|
-
isThrowing: () => isThrowing2,
|
|
729
|
-
isTrue: () => isTrue2,
|
|
730
|
-
isTrueOrUndefined: () => isTrueOrUndefined2,
|
|
731
|
-
isTypedObject: () => isTypedObject2,
|
|
732
|
-
isUndefined: () => isUndefined2,
|
|
733
|
-
tryOr: () => tryOr
|
|
734
|
-
});
|
|
735
|
-
|
|
736
|
-
// src/utils/obj/index.ts
|
|
737
|
-
var obj_exports = {};
|
|
738
|
-
__export(obj_exports, {
|
|
739
|
-
deepEqual: () => deepEqual,
|
|
740
|
-
hasProperties: () => hasProperties,
|
|
741
|
-
isObject: () => isObject2
|
|
742
|
-
});
|
|
743
|
-
function hasProperties(obj, props) {
|
|
744
|
-
return isObject2(obj) && props.every((p) => p in obj);
|
|
745
|
-
}
|
|
746
|
-
function deepEqual(a, b) {
|
|
747
|
-
if (a === b) return true;
|
|
748
|
-
if (a === null || b === null) return false;
|
|
749
|
-
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
750
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
751
|
-
if (a.length !== b.length) return false;
|
|
752
|
-
return a.every((val, i) => deepEqual(val, b[i]));
|
|
753
|
-
}
|
|
754
|
-
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
755
|
-
const keysA = Object.keys(a);
|
|
756
|
-
const keysB = Object.keys(b);
|
|
757
|
-
if (keysA.length !== keysB.length) return false;
|
|
758
|
-
for (const key of keysA) {
|
|
759
|
-
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
760
|
-
if (!deepEqual(a[key], b[key])) return false;
|
|
761
|
-
}
|
|
762
|
-
return true;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
// src/utils/enum/index.ts
|
|
766
|
-
var enum_exports = {};
|
|
767
|
-
__export(enum_exports, {
|
|
768
|
-
assertEnumValue: () => assertEnumValue,
|
|
769
|
-
forEachEnum: () => forEachEnum,
|
|
770
|
-
getEnumEntries: () => getEnumEntries,
|
|
771
|
-
getEnumKey: () => getEnumKey,
|
|
772
|
-
getEnumKeys: () => getEnumKeys,
|
|
773
|
-
getEnumValues: () => getEnumValues,
|
|
774
|
-
isEnumValue: () => isEnumValue2
|
|
775
|
-
});
|
|
776
|
-
function getEnumKeys(e) {
|
|
777
|
-
return Object.keys(e).filter((k) => isNaN(Number(k)));
|
|
778
|
-
}
|
|
779
|
-
function getEnumValues(e) {
|
|
780
|
-
return getEnumKeys(e).map((k) => e[k]);
|
|
781
|
-
}
|
|
782
|
-
function getEnumEntries(e) {
|
|
783
|
-
return getEnumKeys(e).map((k) => [k, e[k]]);
|
|
784
|
-
}
|
|
785
|
-
function getEnumKey(e, value) {
|
|
786
|
-
return getEnumKeys(e).find((k) => e[k] === value);
|
|
787
|
-
}
|
|
788
|
-
function forEachEnum(e, callback) {
|
|
789
|
-
for (const [k, v] of getEnumEntries(e)) callback(k, v);
|
|
790
|
-
}
|
|
791
|
-
function isEnumValue2(e, value) {
|
|
792
|
-
return getEnumValues(e).includes(value);
|
|
793
|
-
}
|
|
794
|
-
function assertEnumValue(e, value) {
|
|
795
|
-
if (!isEnumValue2(e, value)) {
|
|
796
|
-
throw new TypeError(`Invalid enum value: ${String(value)}`);
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
// src/guard/index.ts
|
|
801
|
-
function isEqual2(value1, value2) {
|
|
802
|
-
return value1 === value2;
|
|
803
|
-
}
|
|
804
|
-
function isDeepEqual2(value1, value2) {
|
|
805
|
-
return deepEqual(value1, value2);
|
|
806
|
-
}
|
|
807
|
-
function isUndefined2(value) {
|
|
808
|
-
return value === void 0;
|
|
809
|
-
}
|
|
810
|
-
function isNull2(value) {
|
|
811
|
-
return value === null;
|
|
812
|
-
}
|
|
813
|
-
function isNullish2(value) {
|
|
814
|
-
return value === void 0 || value === null;
|
|
815
|
-
}
|
|
816
|
-
function isObject2(value) {
|
|
817
|
-
return typeof value === "object" && value !== null && !isArray2(value);
|
|
818
|
-
}
|
|
819
|
-
function isObjectOrUndefined2(value) {
|
|
820
|
-
return value === void 0 || isObject2(value);
|
|
821
|
-
}
|
|
822
|
-
function isTypedObject2(obj, keys) {
|
|
823
|
-
return isObject2(obj) && keys.every((k) => k in obj);
|
|
824
|
-
}
|
|
825
|
-
function isArray2(a) {
|
|
826
|
-
return !!a && Object.prototype.toString.call(a) === "[object Array]";
|
|
827
|
-
}
|
|
828
|
-
function isArrayOrUndefined2(value) {
|
|
829
|
-
return value === void 0 || isArray2(value);
|
|
830
|
-
}
|
|
831
|
-
function isEmptyArray2(a) {
|
|
832
|
-
return isArray2(a) && a.length === 0;
|
|
833
|
-
}
|
|
834
|
-
function isNonEmptyArray2(a) {
|
|
835
|
-
return isArray2(a) && a.length > 0;
|
|
836
|
-
}
|
|
837
|
-
function isEmptyArrayOrUndefined2(a) {
|
|
838
|
-
return isArray2(a) && a.length === 0 || a === void 0;
|
|
839
|
-
}
|
|
840
|
-
function isNonEmptyArrayOrUndefined2(a) {
|
|
841
|
-
return isArray2(a) && a.length > 0 || a === void 0;
|
|
842
|
-
}
|
|
843
|
-
function isString2(value) {
|
|
844
|
-
return typeof value === "string";
|
|
845
|
-
}
|
|
846
|
-
function isEmptyString2(value) {
|
|
847
|
-
return typeof value === "string" && value.length === 0;
|
|
848
|
-
}
|
|
849
|
-
function isNonEmptyString2(value) {
|
|
850
|
-
return typeof value === "string" && value.length > 0;
|
|
851
|
-
}
|
|
852
|
-
function isStringOrUndefined2(value) {
|
|
853
|
-
return value === void 0 || typeof value === "string";
|
|
854
|
-
}
|
|
855
|
-
function isEmptyStringOrUndefined2(value) {
|
|
856
|
-
return typeof value === "string" && value.length === 0 || value === void 0;
|
|
857
|
-
}
|
|
858
|
-
function isNonEmptyStringOrUndefined2(value) {
|
|
859
|
-
return typeof value === "string" && value.length > 0 || value === void 0;
|
|
860
|
-
}
|
|
861
|
-
function isBoolean2(value) {
|
|
862
|
-
return typeof value === "boolean";
|
|
863
|
-
}
|
|
864
|
-
function isBooleanOrUndefined2(value) {
|
|
865
|
-
return value === void 0 || typeof value === "boolean";
|
|
866
|
-
}
|
|
867
|
-
function isTrue2(value) {
|
|
868
|
-
return value === true;
|
|
869
|
-
}
|
|
870
|
-
function isTrueOrUndefined2(value) {
|
|
871
|
-
return value === true || value === void 0;
|
|
872
|
-
}
|
|
873
|
-
function isFalse2(value) {
|
|
874
|
-
return value === false;
|
|
875
|
-
}
|
|
876
|
-
function isFalseOrUndefined2(value) {
|
|
877
|
-
return value === false || value === void 0;
|
|
878
|
-
}
|
|
879
|
-
function isFunction2(value) {
|
|
880
|
-
return typeof value === "function";
|
|
881
|
-
}
|
|
882
|
-
function isFunctionOrUndefined2(value) {
|
|
883
|
-
return value === void 0 || typeof value === "function";
|
|
884
|
-
}
|
|
885
|
-
function isEnumValue3(value, enumObj, name = "value") {
|
|
886
|
-
return getEnumValues(enumObj).some((v) => v === value);
|
|
887
|
-
}
|
|
888
|
-
function isEnumValueOrUndefined2(value, enumObj, name = "value") {
|
|
889
|
-
return value === void 0 || getEnumValues(enumObj).some((v) => v === value);
|
|
890
|
-
}
|
|
891
|
-
function isNumber2(value) {
|
|
892
|
-
return typeof value === "number";
|
|
893
|
-
}
|
|
894
|
-
function isNumberOrUndefined2(value) {
|
|
895
|
-
return typeof value === "number" || value === void 0;
|
|
896
|
-
}
|
|
897
|
-
function isFinite3(value) {
|
|
898
|
-
return typeof value === "number" && Number.isFinite(value);
|
|
899
|
-
}
|
|
900
|
-
function isInteger2(n) {
|
|
901
|
-
return typeof n === "number" && isFinite3(n) && n === Math.trunc(n);
|
|
902
|
-
}
|
|
903
|
-
function isIntegerOrUndefined2(n) {
|
|
904
|
-
return typeof n === "number" && isFinite3(n) && n === Math.trunc(n) || n === void 0;
|
|
905
|
-
}
|
|
906
|
-
function isIntegerEq2(value, compareTo) {
|
|
907
|
-
return isInteger2(value) && value === compareTo;
|
|
908
|
-
}
|
|
909
|
-
function isIntegerGt2(value, compareTo) {
|
|
910
|
-
return isInteger2(value) && isNumber2(compareTo) && value > compareTo;
|
|
911
|
-
}
|
|
912
|
-
function isIntegerGte2(value, compareTo) {
|
|
913
|
-
return isInteger2(value) && isNumber2(compareTo) && value >= compareTo;
|
|
914
|
-
}
|
|
915
|
-
function isIntegerLt2(value, compareTo) {
|
|
916
|
-
return isInteger2(value) && isNumber2(compareTo) && value < compareTo;
|
|
917
|
-
}
|
|
918
|
-
function isIntegerLte2(value, compareTo) {
|
|
919
|
-
return isInteger2(value) && isNumber2(compareTo) && value <= compareTo;
|
|
920
|
-
}
|
|
921
|
-
function isIntegerBetween2(value, min, max) {
|
|
922
|
-
return isInteger2(value) && isNumber2(min) && isNumber2(max) && value >= min && value <= max;
|
|
923
|
-
}
|
|
924
|
-
function isIntegerBetweenExclusive2(value, min, max) {
|
|
925
|
-
return isInteger2(value) && isNumber2(min) && isNumber2(max) && value > min && value < max;
|
|
926
|
-
}
|
|
927
|
-
function isNumberBetween2(value, min, max) {
|
|
928
|
-
return isNumber2(value) && isNumber2(min) && isNumber2(max) && value >= min && value <= max;
|
|
929
|
-
}
|
|
930
|
-
function isNumberBetweenExclusive2(value, min, max) {
|
|
931
|
-
return isNumber2(value) && isNumber2(min) && isNumber2(max) && value > min && value < max;
|
|
932
|
-
}
|
|
933
|
-
function isNaNValue2(value) {
|
|
934
|
-
return typeof value === "number" && Number.isNaN(value);
|
|
935
|
-
}
|
|
936
|
-
function isInfinity2(value) {
|
|
937
|
-
return typeof value === "number" && Math.abs(value) === Infinity;
|
|
938
|
-
}
|
|
939
|
-
function isPosInfinity2(value) {
|
|
940
|
-
return typeof value === "number" && value === Infinity;
|
|
941
|
-
}
|
|
942
|
-
function isNegInfinity2(value) {
|
|
943
|
-
return typeof value === "number" && value === -Infinity;
|
|
944
|
-
}
|
|
945
|
-
function isOddNumber2(value) {
|
|
946
|
-
return isInteger2(value) && value % 2 === 1;
|
|
947
|
-
}
|
|
948
|
-
function isEvenNumber2(value) {
|
|
949
|
-
return isInteger2(value) && value % 2 === 0;
|
|
950
|
-
}
|
|
951
|
-
function isIncluded2(value, array) {
|
|
952
|
-
return array.includes(value);
|
|
953
|
-
}
|
|
954
|
-
function isArrayIndex2(index, array) {
|
|
955
|
-
return isInteger2(index) && isArray2(array) && index >= 0 && index < array.length;
|
|
956
|
-
}
|
|
957
|
-
function isThrowing2(throwTestFn) {
|
|
958
|
-
try {
|
|
959
|
-
throwTestFn();
|
|
960
|
-
return false;
|
|
961
|
-
} catch (err) {
|
|
962
|
-
return true;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
function isNotThrowing2(throwTestFn) {
|
|
966
|
-
try {
|
|
967
|
-
throwTestFn();
|
|
968
|
-
return true;
|
|
969
|
-
} catch (err) {
|
|
970
|
-
return false;
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
function tryOr(tryFn, orVal) {
|
|
974
|
-
try {
|
|
975
|
-
return tryFn();
|
|
976
|
-
} catch (err) {
|
|
977
|
-
return isFunction2(orVal) ? orVal() : orVal;
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
|
|
981
1259
|
// src/utils/index.ts
|
|
982
1260
|
var utils_exports = {};
|
|
983
1261
|
__export(utils_exports, {
|
|
984
1262
|
Arr: () => arr_exports,
|
|
985
1263
|
Dom: () => dom_exports,
|
|
986
1264
|
Enum: () => enum_exports,
|
|
987
|
-
Is: () => Is,
|
|
988
|
-
Map: () => map_exports,
|
|
989
1265
|
Math: () => math_exports,
|
|
990
1266
|
Obj: () => obj_exports,
|
|
991
1267
|
Str: () => str_exports
|
|
@@ -1000,33 +1276,29 @@ __export(arr_exports, {
|
|
|
1000
1276
|
fillArray: () => fillArray,
|
|
1001
1277
|
getRangeArray: () => getRangeArray,
|
|
1002
1278
|
getSequenceArray: () => getSequenceArray,
|
|
1003
|
-
isArray: () =>
|
|
1279
|
+
isArray: () => isArray,
|
|
1004
1280
|
mapRangeArray: () => mapRangeArray,
|
|
1005
1281
|
mapSequenceArray: () => mapSequenceArray,
|
|
1006
1282
|
removeDuplicates: () => removeDuplicates,
|
|
1007
|
-
removeDuplicatesCmp: () => removeDuplicatesCmp,
|
|
1008
1283
|
toArray: () => toArray
|
|
1009
1284
|
});
|
|
1010
1285
|
function toArray(a) {
|
|
1011
|
-
return
|
|
1286
|
+
return isArray(a) ? a : [a];
|
|
1012
1287
|
}
|
|
1013
1288
|
function duplicate(a) {
|
|
1014
|
-
return a
|
|
1289
|
+
return a?.slice() ?? [];
|
|
1015
1290
|
}
|
|
1016
1291
|
function removeDuplicates(arr, compareFn) {
|
|
1017
1292
|
return compareFn !== void 0 ? arr.filter((a, id, self) => id === self.findIndex((b) => compareFn(a, b))) : arr.filter((a, id, self) => id === self.indexOf(a));
|
|
1018
1293
|
}
|
|
1019
|
-
function removeDuplicatesCmp(arr, compareFn) {
|
|
1020
|
-
return arr.filter((a, id, self) => id === self.findIndex((b) => compareFn(a, b)));
|
|
1021
|
-
}
|
|
1022
1294
|
function fillArray(fillValue, fillCount) {
|
|
1023
|
-
if (!
|
|
1295
|
+
if (!isInteger(fillCount) || fillCount < 0) {
|
|
1024
1296
|
throw new Error("fillArray: Invalid fillCount = " + fillCount);
|
|
1025
1297
|
}
|
|
1026
1298
|
return new Array(fillCount).fill(fillValue);
|
|
1027
1299
|
}
|
|
1028
1300
|
function mapSequenceArray(len, fn) {
|
|
1029
|
-
if (!
|
|
1301
|
+
if (!isInteger(len) || len < 0) {
|
|
1030
1302
|
throw new Error("mapSequenceArray: Invalid len = " + len);
|
|
1031
1303
|
}
|
|
1032
1304
|
let arr = new Array(len);
|
|
@@ -1039,10 +1311,10 @@ function getSequenceArray(len) {
|
|
|
1039
1311
|
return mapSequenceArray(len, (i) => i);
|
|
1040
1312
|
}
|
|
1041
1313
|
function mapRangeArray(start, end, fn) {
|
|
1042
|
-
if (!
|
|
1314
|
+
if (!isInteger(start)) {
|
|
1043
1315
|
throw new Error("mapRangeArray: Invalid start = " + end);
|
|
1044
1316
|
}
|
|
1045
|
-
if (!
|
|
1317
|
+
if (!isInteger(end)) {
|
|
1046
1318
|
throw new Error("mapRangeArray: Invalid end = " + end);
|
|
1047
1319
|
}
|
|
1048
1320
|
let len = Math.abs(end - start) + 1;
|
|
@@ -1059,7 +1331,7 @@ function arrayContains(arg, item) {
|
|
|
1059
1331
|
return arg.indexOf(item) >= 0;
|
|
1060
1332
|
}
|
|
1061
1333
|
function chunckArray(arr, chunckSize) {
|
|
1062
|
-
if (!
|
|
1334
|
+
if (!isInteger(chunckSize) || chunckSize < 1) {
|
|
1063
1335
|
throw new Error("chunckArray: Invalid chunckSize = " + chunckSize);
|
|
1064
1336
|
}
|
|
1065
1337
|
let result = [];
|
|
@@ -1259,15 +1531,6 @@ function getCanvasTextWidth(text, font) {
|
|
|
1259
1531
|
return ctx.measureText(text).width;
|
|
1260
1532
|
}
|
|
1261
1533
|
|
|
1262
|
-
// src/utils/map/index.ts
|
|
1263
|
-
var map_exports = {};
|
|
1264
|
-
__export(map_exports, {
|
|
1265
|
-
getMapKeys: () => getMapKeys
|
|
1266
|
-
});
|
|
1267
|
-
function getMapKeys(map) {
|
|
1268
|
-
return [...map.keys()];
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
1534
|
// src/utils/math/index.ts
|
|
1272
1535
|
var math_exports = {};
|
|
1273
1536
|
__export(math_exports, {
|
|
@@ -1277,8 +1540,8 @@ __export(math_exports, {
|
|
|
1277
1540
|
cmp: () => cmp,
|
|
1278
1541
|
interpolateCoord: () => interpolateCoord,
|
|
1279
1542
|
interpolateY: () => interpolateY,
|
|
1280
|
-
isInteger: () =>
|
|
1281
|
-
isNumber: () =>
|
|
1543
|
+
isInteger: () => isInteger,
|
|
1544
|
+
isNumber: () => isNumber,
|
|
1282
1545
|
linearToDecibels: () => linearToDecibels,
|
|
1283
1546
|
mod: () => mod,
|
|
1284
1547
|
romanize: () => romanize,
|
|
@@ -1298,7 +1561,7 @@ function mod(m, n) {
|
|
|
1298
1561
|
return (m % n + n) % n;
|
|
1299
1562
|
}
|
|
1300
1563
|
function romanize(n) {
|
|
1301
|
-
if (!
|
|
1564
|
+
if (!isInteger(n) || n < 0) {
|
|
1302
1565
|
throw new Error("romanize: Invalid n = " + n);
|
|
1303
1566
|
}
|
|
1304
1567
|
var digits = String(+n).split("");
|
|
@@ -1339,7 +1602,7 @@ function romanize(n) {
|
|
|
1339
1602
|
return Array(+digits.join("") + 1).join("M") + roman;
|
|
1340
1603
|
}
|
|
1341
1604
|
function toOrdinalNumber(n) {
|
|
1342
|
-
if (!
|
|
1605
|
+
if (!isInteger(n)) {
|
|
1343
1606
|
throw new Error("toOrdinalNumber: Invalid n = " + n);
|
|
1344
1607
|
}
|
|
1345
1608
|
const nStr = n.toString();
|
|
@@ -1392,21 +1655,6 @@ function cmp(a, b) {
|
|
|
1392
1655
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
1393
1656
|
}
|
|
1394
1657
|
|
|
1395
|
-
// src/utils/str/index.ts
|
|
1396
|
-
var str_exports = {};
|
|
1397
|
-
__export(str_exports, {
|
|
1398
|
-
charCount: () => charCount,
|
|
1399
|
-
chunkString: () => chunkString,
|
|
1400
|
-
insertAt: () => insertAt,
|
|
1401
|
-
isString: () => isString2,
|
|
1402
|
-
makeSentenceFromPascal: () => makeSentenceFromPascal,
|
|
1403
|
-
removeAt: () => removeAt,
|
|
1404
|
-
repeatString: () => repeatString,
|
|
1405
|
-
replaceAt: () => replaceAt,
|
|
1406
|
-
stringify: () => stringify,
|
|
1407
|
-
toCharArray: () => toCharArray
|
|
1408
|
-
});
|
|
1409
|
-
|
|
1410
1658
|
// src/core/base.ts
|
|
1411
1659
|
var DefaultEqualityFn = (a, b) => a === b;
|
|
1412
1660
|
var BaseContainer = class {
|
|
@@ -1437,7 +1685,7 @@ var Stack = class extends BaseContainer {
|
|
|
1437
1685
|
return this.data.pop();
|
|
1438
1686
|
}
|
|
1439
1687
|
popOr(defaultValueOrCreator) {
|
|
1440
|
-
return this.isEmpty() ?
|
|
1688
|
+
return this.isEmpty() ? isFunction(defaultValueOrCreator) ? defaultValueOrCreator() : defaultValueOrCreator : this.data.pop();
|
|
1441
1689
|
}
|
|
1442
1690
|
top() {
|
|
1443
1691
|
return this.data[this.assertId(this.length - 1)];
|
|
@@ -1446,7 +1694,7 @@ var Stack = class extends BaseContainer {
|
|
|
1446
1694
|
return this.data[this.length - 1];
|
|
1447
1695
|
}
|
|
1448
1696
|
topOr(defaultValueOrCreator) {
|
|
1449
|
-
return this.isEmpty() ?
|
|
1697
|
+
return this.isEmpty() ? isFunction(defaultValueOrCreator) ? defaultValueOrCreator() : defaultValueOrCreator : this.data[this.length - 1];
|
|
1450
1698
|
}
|
|
1451
1699
|
peek(depth = 0) {
|
|
1452
1700
|
return this.data[this.assertId(this.data.length - 1 - depth)];
|
|
@@ -1457,7 +1705,7 @@ var Stack = class extends BaseContainer {
|
|
|
1457
1705
|
peekOr(depth = 0, defaultValueOrCreator) {
|
|
1458
1706
|
const id = this.data.length - 1 - depth;
|
|
1459
1707
|
const value = id < 0 ? void 0 : this.data[id];
|
|
1460
|
-
return value === void 0 ?
|
|
1708
|
+
return value === void 0 ? isFunction(defaultValueOrCreator) ? defaultValueOrCreator() : defaultValueOrCreator : value;
|
|
1461
1709
|
}
|
|
1462
1710
|
*values() {
|
|
1463
1711
|
for (let id = this.data.length - 1; id >= 0; id--)
|
|
@@ -1566,7 +1814,7 @@ var Vec = class _Vec extends BaseContainer {
|
|
|
1566
1814
|
if (a.coords.length !== b.coords.length) {
|
|
1567
1815
|
throw new TypeError("Coordinate length mismatch!");
|
|
1568
1816
|
}
|
|
1569
|
-
if (!
|
|
1817
|
+
if (!isFinite2(t)) {
|
|
1570
1818
|
throw new TypeError("Lerp t is not finite!");
|
|
1571
1819
|
}
|
|
1572
1820
|
return a.add(b.sub(a).mul(t));
|
|
@@ -2117,6 +2365,9 @@ var AnchoredRect = class _AnchoredRect {
|
|
|
2117
2365
|
toRect() {
|
|
2118
2366
|
return new Rect(this.left, this.right, this.width, this.height);
|
|
2119
2367
|
}
|
|
2368
|
+
toString() {
|
|
2369
|
+
return `Rect(left=${this.left}, anchorX=${this.anchorX}, right=${this.right}, top=${this.top}, anchorY=${this.anchorY}, bottom=${this.bottom})`;
|
|
2370
|
+
}
|
|
2120
2371
|
};
|
|
2121
2372
|
|
|
2122
2373
|
// src/core/LRU-cache.ts
|
|
@@ -2260,7 +2511,7 @@ var IndexArray = class _IndexArray extends BaseContainer {
|
|
|
2260
2511
|
}
|
|
2261
2512
|
}
|
|
2262
2513
|
static validateIndex(id) {
|
|
2263
|
-
if (!
|
|
2514
|
+
if (!isIntegerGte(id, 0)) throw new Error(`Invalid index ${id} - must be an integer >= 0!`);
|
|
2264
2515
|
return id;
|
|
2265
2516
|
}
|
|
2266
2517
|
get posLen() {
|
|
@@ -2299,7 +2550,7 @@ var IndexArray = class _IndexArray extends BaseContainer {
|
|
|
2299
2550
|
}
|
|
2300
2551
|
getOrCreate(id, creatorOrValue) {
|
|
2301
2552
|
if (!this.has(id)) {
|
|
2302
|
-
const value =
|
|
2553
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2303
2554
|
this.set(id, value);
|
|
2304
2555
|
return value;
|
|
2305
2556
|
}
|
|
@@ -2436,15 +2687,15 @@ var IndexArray = class _IndexArray extends BaseContainer {
|
|
|
2436
2687
|
}
|
|
2437
2688
|
return result;
|
|
2438
2689
|
}
|
|
2439
|
-
equals(other,
|
|
2690
|
+
equals(other, eq) {
|
|
2440
2691
|
if (this.size !== other.size) return false;
|
|
2441
|
-
|
|
2692
|
+
eq ?? (eq = (a, b) => a === b);
|
|
2442
2693
|
const posLen = Math.max(this.posLen, other.posLen);
|
|
2443
2694
|
for (let i = 0; i < posLen; ++i) {
|
|
2444
2695
|
const hasA = this.hasPos[i];
|
|
2445
2696
|
const hasB = other.hasPos[i];
|
|
2446
2697
|
if (hasA !== hasB) return false;
|
|
2447
|
-
if (hasA && !
|
|
2698
|
+
if (hasA && !eq(this.posVal[i], other.posVal[i])) return false;
|
|
2448
2699
|
}
|
|
2449
2700
|
return true;
|
|
2450
2701
|
}
|
|
@@ -2497,7 +2748,7 @@ var SignedIndexArray = class _SignedIndexArray extends BaseContainer {
|
|
|
2497
2748
|
return -id - 1;
|
|
2498
2749
|
}
|
|
2499
2750
|
static validateIndex(id) {
|
|
2500
|
-
if (!
|
|
2751
|
+
if (!isInteger(id)) throw new Error(`Invalid index ${id} - must be an integer!`);
|
|
2501
2752
|
return id;
|
|
2502
2753
|
}
|
|
2503
2754
|
get size() {
|
|
@@ -2547,7 +2798,7 @@ var SignedIndexArray = class _SignedIndexArray extends BaseContainer {
|
|
|
2547
2798
|
}
|
|
2548
2799
|
getOrCreate(id, creatorOrValue) {
|
|
2549
2800
|
if (!this.has(id)) {
|
|
2550
|
-
const value =
|
|
2801
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2551
2802
|
this.set(id, value);
|
|
2552
2803
|
return value;
|
|
2553
2804
|
}
|
|
@@ -2555,10 +2806,10 @@ var SignedIndexArray = class _SignedIndexArray extends BaseContainer {
|
|
|
2555
2806
|
}
|
|
2556
2807
|
delete(id) {
|
|
2557
2808
|
_SignedIndexArray.validateIndex(id);
|
|
2558
|
-
const
|
|
2559
|
-
const arr =
|
|
2560
|
-
const has =
|
|
2561
|
-
const idx =
|
|
2809
|
+
const isPos3 = id >= 0;
|
|
2810
|
+
const arr = isPos3 ? this.posVal : this.negVal;
|
|
2811
|
+
const has = isPos3 ? this.hasPos : this.hasNeg;
|
|
2812
|
+
const idx = isPos3 ? id : _SignedIndexArray.toNegIndex(id);
|
|
2562
2813
|
if (!has[idx]) return false;
|
|
2563
2814
|
arr[idx] = void 0;
|
|
2564
2815
|
has[idx] = false;
|
|
@@ -2698,22 +2949,22 @@ var SignedIndexArray = class _SignedIndexArray extends BaseContainer {
|
|
|
2698
2949
|
}
|
|
2699
2950
|
return result;
|
|
2700
2951
|
}
|
|
2701
|
-
equals(other,
|
|
2952
|
+
equals(other, eq) {
|
|
2702
2953
|
if (this.size !== other.size) return false;
|
|
2703
|
-
|
|
2954
|
+
eq ?? (eq = (a, b) => a === b);
|
|
2704
2955
|
const posLen = Math.max(this.posLen, other.posLen);
|
|
2705
2956
|
for (let i = 0; i < posLen; ++i) {
|
|
2706
2957
|
const hasA = this.hasPos[i];
|
|
2707
2958
|
const hasB = other.hasPos[i];
|
|
2708
2959
|
if (hasA !== hasB) return false;
|
|
2709
|
-
if (hasA && !
|
|
2960
|
+
if (hasA && !eq(this.posVal[i], other.posVal[i])) return false;
|
|
2710
2961
|
}
|
|
2711
2962
|
const negLen = Math.max(this.negLen, other.negLen);
|
|
2712
2963
|
for (let i = 0; i < negLen; ++i) {
|
|
2713
2964
|
const hasA = this.hasNeg[i];
|
|
2714
2965
|
const hasB = other.hasNeg[i];
|
|
2715
2966
|
if (hasA !== hasB) return false;
|
|
2716
|
-
if (hasA && !
|
|
2967
|
+
if (hasA && !eq(this.negVal[i], other.negVal[i])) return false;
|
|
2717
2968
|
}
|
|
2718
2969
|
return true;
|
|
2719
2970
|
}
|
|
@@ -2782,7 +3033,7 @@ var DefaultArray = class _DefaultArray extends BaseContainer {
|
|
|
2782
3033
|
}
|
|
2783
3034
|
getOrCreate(id, creatorOrValue) {
|
|
2784
3035
|
if (!this.has(id)) {
|
|
2785
|
-
const value =
|
|
3036
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2786
3037
|
this.set(id, value);
|
|
2787
3038
|
return value;
|
|
2788
3039
|
}
|
|
@@ -2917,11 +3168,11 @@ var DefaultArray = class _DefaultArray extends BaseContainer {
|
|
|
2917
3168
|
}
|
|
2918
3169
|
return result;
|
|
2919
3170
|
}
|
|
2920
|
-
equals(other,
|
|
3171
|
+
equals(other, eq) {
|
|
2921
3172
|
if (this.size !== other.size) return false;
|
|
2922
|
-
|
|
3173
|
+
eq ?? (eq = (a, b) => a === b);
|
|
2923
3174
|
for (let id = 0; id < this.data.length; ++id) {
|
|
2924
|
-
if (!
|
|
3175
|
+
if (!eq(this.data[id], other.data[id])) return false;
|
|
2925
3176
|
}
|
|
2926
3177
|
return true;
|
|
2927
3178
|
}
|
|
@@ -2940,12 +3191,12 @@ var UniMap = class _UniMap extends BaseContainer {
|
|
|
2940
3191
|
__publicField(this, "map");
|
|
2941
3192
|
__publicField(this, "keyEquals");
|
|
2942
3193
|
const maybeEquals = args.at(-1);
|
|
2943
|
-
this.keyEquals =
|
|
3194
|
+
this.keyEquals = isFunction(maybeEquals) ? args.pop() : DefaultEqualityFn;
|
|
2944
3195
|
const entries = args[0];
|
|
2945
3196
|
this.map = new Map(entries);
|
|
2946
3197
|
}
|
|
2947
3198
|
static createDeep(arg) {
|
|
2948
|
-
return arg ? new _UniMap(arg,
|
|
3199
|
+
return arg ? new _UniMap(arg, isDeepEqual) : new _UniMap(isDeepEqual);
|
|
2949
3200
|
}
|
|
2950
3201
|
has(key) {
|
|
2951
3202
|
if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
|
|
@@ -2989,7 +3240,7 @@ var UniMap = class _UniMap extends BaseContainer {
|
|
|
2989
3240
|
}
|
|
2990
3241
|
getOrCreate(key, creatorOrValue) {
|
|
2991
3242
|
if (!this.has(key)) {
|
|
2992
|
-
const value =
|
|
3243
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2993
3244
|
return this.set(key, value);
|
|
2994
3245
|
}
|
|
2995
3246
|
return this.get(key);
|
|
@@ -3080,7 +3331,7 @@ var UniMap = class _UniMap extends BaseContainer {
|
|
|
3080
3331
|
let first = iterator.next();
|
|
3081
3332
|
if (first.done) {
|
|
3082
3333
|
if (arguments.length < 2) {
|
|
3083
|
-
throw new TypeError("Reduce of empty
|
|
3334
|
+
throw new TypeError("Reduce of empty UniMap with no initial value!");
|
|
3084
3335
|
}
|
|
3085
3336
|
return init;
|
|
3086
3337
|
}
|
|
@@ -3157,7 +3408,7 @@ var BiMap = class _BiMap extends BaseContainer {
|
|
|
3157
3408
|
}
|
|
3158
3409
|
getOrCreate(key1, key2, creatorOrValue) {
|
|
3159
3410
|
if (!this.has(key1, key2)) {
|
|
3160
|
-
const value =
|
|
3411
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
3161
3412
|
this.set(key1, key2, value);
|
|
3162
3413
|
return value;
|
|
3163
3414
|
}
|
|
@@ -3267,7 +3518,7 @@ var BiMap = class _BiMap extends BaseContainer {
|
|
|
3267
3518
|
let first = iterator.next();
|
|
3268
3519
|
if (first.done) {
|
|
3269
3520
|
if (arguments.length < 2) {
|
|
3270
|
-
throw new TypeError("Reduce of empty
|
|
3521
|
+
throw new TypeError("Reduce of empty BiMap with no initial value!");
|
|
3271
3522
|
}
|
|
3272
3523
|
return init;
|
|
3273
3524
|
}
|
|
@@ -3362,7 +3613,7 @@ var TriMap = class _TriMap extends BaseContainer {
|
|
|
3362
3613
|
}
|
|
3363
3614
|
getOrCreate(key1, key2, key3, creatorOrValue) {
|
|
3364
3615
|
if (!this.has(key1, key2, key3)) {
|
|
3365
|
-
const value =
|
|
3616
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
3366
3617
|
this.set(key1, key2, key3, value);
|
|
3367
3618
|
return value;
|
|
3368
3619
|
}
|
|
@@ -3490,7 +3741,7 @@ var TriMap = class _TriMap extends BaseContainer {
|
|
|
3490
3741
|
let first = iterator.next();
|
|
3491
3742
|
if (first.done) {
|
|
3492
3743
|
if (arguments.length < 2) {
|
|
3493
|
-
throw new TypeError("Reduce of empty
|
|
3744
|
+
throw new TypeError("Reduce of empty TriMap with no initial value!");
|
|
3494
3745
|
}
|
|
3495
3746
|
return init;
|
|
3496
3747
|
}
|
|
@@ -3561,12 +3812,12 @@ var ValueSet = class _ValueSet extends BaseContainer {
|
|
|
3561
3812
|
__publicField(this, "data");
|
|
3562
3813
|
__publicField(this, "equals");
|
|
3563
3814
|
const maybeEquals = args.at(-1);
|
|
3564
|
-
this.equals =
|
|
3815
|
+
this.equals = isFunction(maybeEquals) ? args.pop() : DefaultEqualityFn;
|
|
3565
3816
|
const entries = args[0];
|
|
3566
3817
|
this.data = new Set(entries);
|
|
3567
3818
|
}
|
|
3568
3819
|
static createDeep(arg) {
|
|
3569
|
-
return arg ? new _ValueSet(arg,
|
|
3820
|
+
return arg ? new _ValueSet(arg, isDeepEqual) : new _ValueSet(isDeepEqual);
|
|
3570
3821
|
}
|
|
3571
3822
|
has(value) {
|
|
3572
3823
|
if (this.equals === DefaultEqualityFn)
|
|
@@ -3594,7 +3845,7 @@ var ValueSet = class _ValueSet extends BaseContainer {
|
|
|
3594
3845
|
}
|
|
3595
3846
|
getOrCreate(key, creatorOrValue) {
|
|
3596
3847
|
if (!this.has(key)) {
|
|
3597
|
-
const value =
|
|
3848
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
3598
3849
|
this.set(key, value);
|
|
3599
3850
|
return value;
|
|
3600
3851
|
}
|
|
@@ -3821,7 +4072,7 @@ var LinkedList = class _LinkedList extends BaseContainer {
|
|
|
3821
4072
|
__publicField(this, "_size", 0);
|
|
3822
4073
|
__publicField(this, "equals");
|
|
3823
4074
|
const maybeEquals = args.at(-1);
|
|
3824
|
-
this.equals =
|
|
4075
|
+
this.equals = isFunction(maybeEquals) ? args.pop() : DefaultEqualityFn;
|
|
3825
4076
|
const entries = args[0];
|
|
3826
4077
|
if (entries) {
|
|
3827
4078
|
for (const v of entries) {
|
|
@@ -3831,9 +4082,9 @@ var LinkedList = class _LinkedList extends BaseContainer {
|
|
|
3831
4082
|
}
|
|
3832
4083
|
static createDeep(entries) {
|
|
3833
4084
|
if (entries) {
|
|
3834
|
-
return new _LinkedList(entries,
|
|
4085
|
+
return new _LinkedList(entries, isDeepEqual);
|
|
3835
4086
|
} else {
|
|
3836
|
-
return new _LinkedList(
|
|
4087
|
+
return new _LinkedList(isDeepEqual);
|
|
3837
4088
|
}
|
|
3838
4089
|
}
|
|
3839
4090
|
get length() {
|
|
@@ -4014,1415 +4265,11 @@ var LinkedList = class _LinkedList extends BaseContainer {
|
|
|
4014
4265
|
}
|
|
4015
4266
|
};
|
|
4016
4267
|
|
|
4017
|
-
// src/
|
|
4018
|
-
function
|
|
4019
|
-
return
|
|
4020
|
-
}
|
|
4021
|
-
function repeatString(repeatString2, repeatCount) {
|
|
4022
|
-
if (!isInteger2(repeatCount) || repeatCount < 0) {
|
|
4023
|
-
throw new Error("repeatStr: Invalid repeatCount = " + repeatCount);
|
|
4024
|
-
}
|
|
4025
|
-
return new Array(repeatCount + 1).join(repeatString2);
|
|
4026
|
-
}
|
|
4027
|
-
function chunkString(str2, chunkSize) {
|
|
4028
|
-
if (!isInteger2(chunkSize) || chunkSize < 1) {
|
|
4029
|
-
throw new Error("chunckString: Invalid chuckSize = " + chunkSize);
|
|
4030
|
-
}
|
|
4031
|
-
let result = [];
|
|
4032
|
-
for (let i = 0; i < str2.length; i += chunkSize) {
|
|
4033
|
-
result.push(str2.slice(i, i + chunkSize));
|
|
4034
|
-
}
|
|
4035
|
-
return result;
|
|
4036
|
-
}
|
|
4037
|
-
function replaceAt(str2, pos, removeCount, insert) {
|
|
4038
|
-
if (!isInteger2(removeCount) || removeCount < 0) {
|
|
4039
|
-
throw new Error("replaceAt: Invalid removeCount = " + removeCount);
|
|
4040
|
-
} else if (!isInteger2(pos) || pos < 0 || pos + removeCount > str2.length) {
|
|
4041
|
-
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " + str2.length);
|
|
4042
|
-
} else {
|
|
4043
|
-
return str2.substring(0, pos) + insert + str2.substring(pos + removeCount);
|
|
4044
|
-
}
|
|
4268
|
+
// src/index.ts
|
|
4269
|
+
function getLibInfo() {
|
|
4270
|
+
return "TsUtilsLib v2.1.0 (esm)";
|
|
4045
4271
|
}
|
|
4046
|
-
function insertAt(str2, pos, insertStr) {
|
|
4047
|
-
return replaceAt(str2, pos, 0, insertStr);
|
|
4048
|
-
}
|
|
4049
|
-
function removeAt(str2, pos, removeCount) {
|
|
4050
|
-
return replaceAt(str2, pos, removeCount, "");
|
|
4051
|
-
}
|
|
4052
|
-
function charCount(str2, ch) {
|
|
4053
|
-
if (ch.length !== 1 || str2.length === 0) return 0;
|
|
4054
|
-
let count = 0;
|
|
4055
|
-
for (let i = 0; i < str2.length; i++) {
|
|
4056
|
-
if (str2[i] === ch) count++;
|
|
4057
|
-
}
|
|
4058
|
-
return count;
|
|
4059
|
-
}
|
|
4060
|
-
function makeSentenceFromPascal(PascalString) {
|
|
4061
|
-
if (PascalString === "") {
|
|
4062
|
-
return "";
|
|
4063
|
-
}
|
|
4064
|
-
let word = PascalString.charAt(0);
|
|
4065
|
-
let sentence = "";
|
|
4066
|
-
const addWord = () => {
|
|
4067
|
-
if (word !== "") {
|
|
4068
|
-
if (sentence === "") {
|
|
4069
|
-
sentence += word.charAt(0).toUpperCase() + word.substring(1);
|
|
4070
|
-
} else {
|
|
4071
|
-
sentence += " " + word;
|
|
4072
|
-
}
|
|
4073
|
-
word = "";
|
|
4074
|
-
}
|
|
4075
|
-
};
|
|
4076
|
-
const isLetterAndCapital = (c) => {
|
|
4077
|
-
return c.toUpperCase() !== c.toLowerCase() && c === c.toUpperCase();
|
|
4078
|
-
};
|
|
4079
|
-
for (let i = 1; i < PascalString.length; i++) {
|
|
4080
|
-
let c = PascalString.charAt(i);
|
|
4081
|
-
if (isLetterAndCapital(c)) {
|
|
4082
|
-
addWord();
|
|
4083
|
-
}
|
|
4084
|
-
word += c.toLowerCase();
|
|
4085
|
-
}
|
|
4086
|
-
addWord();
|
|
4087
|
-
return sentence;
|
|
4088
|
-
}
|
|
4089
|
-
function stringify(value, maxDepth = 5, seen = /* @__PURE__ */ new WeakSet()) {
|
|
4090
|
-
if (value === null) return "null";
|
|
4091
|
-
if (value === void 0) return "undefined";
|
|
4092
|
-
const t = typeof value;
|
|
4093
|
-
switch (t) {
|
|
4094
|
-
case "boolean":
|
|
4095
|
-
return value ? "true" : "false";
|
|
4096
|
-
case "number":
|
|
4097
|
-
if (isNaNValue2(value)) return "NaN";
|
|
4098
|
-
if (!isFinite3(value))
|
|
4099
|
-
return value < 0 ? "-Infinity" : "Infinity";
|
|
4100
|
-
return value.toString();
|
|
4101
|
-
case "bigint":
|
|
4102
|
-
return `${value}n`;
|
|
4103
|
-
case "string":
|
|
4104
|
-
return `"${value}"`;
|
|
4105
|
-
case "symbol":
|
|
4106
|
-
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
4107
|
-
case "function":
|
|
4108
|
-
return `[Function${value.name ? ` ${value.name}` : ""}]`;
|
|
4109
|
-
}
|
|
4110
|
-
if (seen.has(value))
|
|
4111
|
-
return "[Circular]";
|
|
4112
|
-
if (maxDepth <= 0)
|
|
4113
|
-
return "[Depth limit]";
|
|
4114
|
-
maxDepth--;
|
|
4115
|
-
seen.add(value);
|
|
4116
|
-
const strfy = (v) => stringify(v, maxDepth, seen);
|
|
4117
|
-
if (isArray2(value)) {
|
|
4118
|
-
const inner = value.map((v) => strfy(v)).join(", ");
|
|
4119
|
-
return inner.length === 0 ? "[ ]" : `[ ${inner} ]`;
|
|
4120
|
-
}
|
|
4121
|
-
if (ArrayBuffer.isView(value)) {
|
|
4122
|
-
if (value instanceof DataView)
|
|
4123
|
-
return `DataView(${value.byteLength})`;
|
|
4124
|
-
const inner = Array.from(value).map((v) => strfy(v)).join(", ");
|
|
4125
|
-
return `${value.constructor.name}[ ${inner} ]`;
|
|
4126
|
-
}
|
|
4127
|
-
if (value instanceof ArrayBuffer)
|
|
4128
|
-
return `ArrayBuffer(${value.byteLength})`;
|
|
4129
|
-
if (value instanceof Map) {
|
|
4130
|
-
const entries = Array.from(value.entries()).map(([k, v]) => `${strfy(k)} => ${strfy(v)}`).join(", ");
|
|
4131
|
-
return entries.length === 0 ? `Map(${value.size}){ }` : `Map(${value.size}){ ${entries} }`;
|
|
4132
|
-
}
|
|
4133
|
-
if (value instanceof Set) {
|
|
4134
|
-
const entries = Array.from(value.values()).map((v) => strfy(v)).join(", ");
|
|
4135
|
-
return entries.length === 0 ? `Set(${value.size}){ }` : `Set(${value.size}){ ${entries} }`;
|
|
4136
|
-
}
|
|
4137
|
-
if (value instanceof WeakMap)
|
|
4138
|
-
return "WeakMap{ ? }";
|
|
4139
|
-
if (value instanceof WeakSet)
|
|
4140
|
-
return "WeakSet{ ? }";
|
|
4141
|
-
if (typeof BaseContainer !== "undefined" && value instanceof BaseContainer)
|
|
4142
|
-
return value.toString();
|
|
4143
|
-
if (value instanceof Date)
|
|
4144
|
-
return `Date("${value.toISOString()}")`;
|
|
4145
|
-
if (value instanceof RegExp)
|
|
4146
|
-
return value.toString();
|
|
4147
|
-
if (value instanceof Error)
|
|
4148
|
-
return `${value.name}("${value.message}")`;
|
|
4149
|
-
if (value instanceof Promise)
|
|
4150
|
-
return "Promise{ ? }";
|
|
4151
|
-
if (value instanceof URL)
|
|
4152
|
-
return `URL("${value.href}")`;
|
|
4153
|
-
if (value instanceof URLSearchParams)
|
|
4154
|
-
return `URLSearchParams("${value.toString()}")`;
|
|
4155
|
-
if (value === Math) return "Math";
|
|
4156
|
-
if (value === JSON) return "JSON";
|
|
4157
|
-
if (value === Reflect) return "Reflect";
|
|
4158
|
-
if (value === Intl) return "Intl";
|
|
4159
|
-
if (t === "object") {
|
|
4160
|
-
const ctorName = value.constructor?.name ?? "Object";
|
|
4161
|
-
const entries = Object.entries(value).map(
|
|
4162
|
-
([key, val]) => `${strfy(key)}: ${strfy(val)}`
|
|
4163
|
-
);
|
|
4164
|
-
if (entries.length === 0) return `${ctorName}{ }`;
|
|
4165
|
-
return `${ctorName}{ ${entries.join(", ")} }`;
|
|
4166
|
-
}
|
|
4167
|
-
return String(value);
|
|
4168
|
-
}
|
|
4169
|
-
|
|
4170
|
-
// src/utils/index.ts
|
|
4171
|
-
var Is = guard_exports;
|
|
4172
|
-
|
|
4173
|
-
// src/deprecated/vec2.ts
|
|
4174
|
-
var Vec2 = class _Vec2 {
|
|
4175
|
-
constructor(x, y) {
|
|
4176
|
-
__publicField(this, "x");
|
|
4177
|
-
__publicField(this, "y");
|
|
4178
|
-
this.x = x ?? 0;
|
|
4179
|
-
this.y = y ?? 0;
|
|
4180
|
-
}
|
|
4181
|
-
length() {
|
|
4182
|
-
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
4183
|
-
}
|
|
4184
|
-
add(a) {
|
|
4185
|
-
return new _Vec2(this.x + a.x, this.y + a.y);
|
|
4186
|
-
}
|
|
4187
|
-
sub(a) {
|
|
4188
|
-
return new _Vec2(this.x - a.x, this.y - a.y);
|
|
4189
|
-
}
|
|
4190
|
-
mul(a) {
|
|
4191
|
-
return new _Vec2(this.x * a, this.y * a);
|
|
4192
|
-
}
|
|
4193
|
-
div(a) {
|
|
4194
|
-
return new _Vec2(this.x / a, this.y / a);
|
|
4195
|
-
}
|
|
4196
|
-
};
|
|
4197
|
-
|
|
4198
|
-
// src/deprecated/small-int-cache.ts
|
|
4199
|
-
var SmallIntCache = class {
|
|
4200
|
-
// for keys < 0
|
|
4201
|
-
constructor() {
|
|
4202
|
-
__publicField(this, "pos");
|
|
4203
|
-
// for keys >= 0
|
|
4204
|
-
__publicField(this, "neg");
|
|
4205
|
-
this.pos = [];
|
|
4206
|
-
this.neg = [];
|
|
4207
|
-
}
|
|
4208
|
-
set(key, value) {
|
|
4209
|
-
if (!guard_exports.isInteger(key)) {
|
|
4210
|
-
throw new Error("Key must be an integer");
|
|
4211
|
-
} else if (key >= 0) {
|
|
4212
|
-
this.pos[key] = value;
|
|
4213
|
-
} else {
|
|
4214
|
-
this.neg[-key - 1] = value;
|
|
4215
|
-
}
|
|
4216
|
-
}
|
|
4217
|
-
get(key) {
|
|
4218
|
-
if (!guard_exports.isInteger(key)) {
|
|
4219
|
-
throw new Error("Key must be an integer");
|
|
4220
|
-
} else if (key >= 0) {
|
|
4221
|
-
return this.pos[key];
|
|
4222
|
-
} else {
|
|
4223
|
-
return this.neg[-key - 1];
|
|
4224
|
-
}
|
|
4225
|
-
}
|
|
4226
|
-
has(key) {
|
|
4227
|
-
if (!guard_exports.isInteger(key)) {
|
|
4228
|
-
return false;
|
|
4229
|
-
} else if (key >= 0) {
|
|
4230
|
-
return key in this.pos;
|
|
4231
|
-
} else {
|
|
4232
|
-
return -key - 1 in this.neg;
|
|
4233
|
-
}
|
|
4234
|
-
}
|
|
4235
|
-
delete(key) {
|
|
4236
|
-
if (!guard_exports.isInteger(key)) {
|
|
4237
|
-
return;
|
|
4238
|
-
} else if (key >= 0) {
|
|
4239
|
-
delete this.pos[key];
|
|
4240
|
-
} else {
|
|
4241
|
-
delete this.neg[-key - 1];
|
|
4242
|
-
}
|
|
4243
|
-
}
|
|
4244
|
-
clear() {
|
|
4245
|
-
this.pos = [];
|
|
4246
|
-
this.neg = [];
|
|
4247
|
-
}
|
|
4248
|
-
};
|
|
4249
|
-
|
|
4250
|
-
// src/deprecated/map1.ts
|
|
4251
|
-
var Map1 = class _Map1 extends BaseContainer {
|
|
4252
|
-
constructor(entries) {
|
|
4253
|
-
super();
|
|
4254
|
-
__publicField(this, "map1");
|
|
4255
|
-
this.map1 = entries instanceof _Map1 ? new Map(entries.map1) : new Map(entries);
|
|
4256
|
-
}
|
|
4257
|
-
has(key1) {
|
|
4258
|
-
return this.map1.has(key1);
|
|
4259
|
-
}
|
|
4260
|
-
set(key1, value) {
|
|
4261
|
-
this.map1.set(key1, value);
|
|
4262
|
-
return value;
|
|
4263
|
-
}
|
|
4264
|
-
get(key1) {
|
|
4265
|
-
return this.map1.get(key1);
|
|
4266
|
-
}
|
|
4267
|
-
getOrDefault(key1, defaultValue) {
|
|
4268
|
-
return this.get(key1) ?? defaultValue;
|
|
4269
|
-
}
|
|
4270
|
-
getOrCreate(key1, creatorOrValue) {
|
|
4271
|
-
if (!this.has(key1)) {
|
|
4272
|
-
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
4273
|
-
this.set(key1, value);
|
|
4274
|
-
return value;
|
|
4275
|
-
}
|
|
4276
|
-
return this.get(key1);
|
|
4277
|
-
}
|
|
4278
|
-
delete(key1) {
|
|
4279
|
-
return this.map1.delete(key1);
|
|
4280
|
-
}
|
|
4281
|
-
clear() {
|
|
4282
|
-
this.map1.clear();
|
|
4283
|
-
}
|
|
4284
|
-
get size() {
|
|
4285
|
-
return this.map1.size;
|
|
4286
|
-
}
|
|
4287
|
-
isEmpty() {
|
|
4288
|
-
return this.size === 0;
|
|
4289
|
-
}
|
|
4290
|
-
forEach(callbackfn, thisArg) {
|
|
4291
|
-
this.map1.forEach((value, key1) => callbackfn.call(thisArg, value, key1, this));
|
|
4292
|
-
}
|
|
4293
|
-
*keys() {
|
|
4294
|
-
yield* this.map1.keys();
|
|
4295
|
-
}
|
|
4296
|
-
*values() {
|
|
4297
|
-
yield* this.map1.values();
|
|
4298
|
-
}
|
|
4299
|
-
*entries() {
|
|
4300
|
-
for (const [key1, value] of this.map1)
|
|
4301
|
-
yield [key1, value];
|
|
4302
|
-
}
|
|
4303
|
-
keysArray() {
|
|
4304
|
-
return [...this.keys()];
|
|
4305
|
-
}
|
|
4306
|
-
valuesArray() {
|
|
4307
|
-
return [...this.values()];
|
|
4308
|
-
}
|
|
4309
|
-
entriesArray() {
|
|
4310
|
-
return [...this.entries()];
|
|
4311
|
-
}
|
|
4312
|
-
*kvKeys() {
|
|
4313
|
-
for (const key of this.keys()) {
|
|
4314
|
-
yield [key];
|
|
4315
|
-
}
|
|
4316
|
-
}
|
|
4317
|
-
*kvValues() {
|
|
4318
|
-
for (const el of this.values()) {
|
|
4319
|
-
yield el;
|
|
4320
|
-
}
|
|
4321
|
-
}
|
|
4322
|
-
*kvEntries() {
|
|
4323
|
-
for (const [key, el] of this.entries()) {
|
|
4324
|
-
yield [[key], el];
|
|
4325
|
-
}
|
|
4326
|
-
}
|
|
4327
|
-
*[Symbol.iterator]() {
|
|
4328
|
-
yield* this.entries();
|
|
4329
|
-
}
|
|
4330
|
-
clone() {
|
|
4331
|
-
return new _Map1(this);
|
|
4332
|
-
}
|
|
4333
|
-
merge(other, conflictResolver) {
|
|
4334
|
-
for (const [key1, value] of other.entries()) {
|
|
4335
|
-
if (this.has(key1) && conflictResolver) {
|
|
4336
|
-
this.set(key1, conflictResolver(this.get(key1), value, key1));
|
|
4337
|
-
} else {
|
|
4338
|
-
this.set(key1, value);
|
|
4339
|
-
}
|
|
4340
|
-
}
|
|
4341
|
-
return this;
|
|
4342
|
-
}
|
|
4343
|
-
some(fn) {
|
|
4344
|
-
for (const [key1, value] of this.map1) {
|
|
4345
|
-
if (fn(value, key1)) return true;
|
|
4346
|
-
}
|
|
4347
|
-
return false;
|
|
4348
|
-
}
|
|
4349
|
-
every(fn) {
|
|
4350
|
-
for (const [key1, value] of this.map1) {
|
|
4351
|
-
if (!fn(value, key1)) return false;
|
|
4352
|
-
}
|
|
4353
|
-
return true;
|
|
4354
|
-
}
|
|
4355
|
-
filter(predicate) {
|
|
4356
|
-
const result = new this.constructor();
|
|
4357
|
-
for (const [key1, value] of this.map1) {
|
|
4358
|
-
if (predicate(value, key1, this)) result.set(key1, value);
|
|
4359
|
-
}
|
|
4360
|
-
return result;
|
|
4361
|
-
}
|
|
4362
|
-
reduce(fn, init) {
|
|
4363
|
-
let iterator = this.entries();
|
|
4364
|
-
let first = iterator.next();
|
|
4365
|
-
if (first.done) {
|
|
4366
|
-
if (arguments.length < 2) {
|
|
4367
|
-
throw new TypeError("Reduce of empty Map1 with no initial value!");
|
|
4368
|
-
}
|
|
4369
|
-
return init;
|
|
4370
|
-
}
|
|
4371
|
-
let acc;
|
|
4372
|
-
let start;
|
|
4373
|
-
if (arguments.length < 2) {
|
|
4374
|
-
acc = first.value[1];
|
|
4375
|
-
start = iterator.next();
|
|
4376
|
-
} else {
|
|
4377
|
-
acc = init;
|
|
4378
|
-
start = first;
|
|
4379
|
-
}
|
|
4380
|
-
for (let current = start; !current.done; current = iterator.next()) {
|
|
4381
|
-
const [key1, value] = current.value;
|
|
4382
|
-
acc = fn(acc, value, key1);
|
|
4383
|
-
}
|
|
4384
|
-
return acc;
|
|
4385
|
-
}
|
|
4386
|
-
mapEntries(fn) {
|
|
4387
|
-
let result = [];
|
|
4388
|
-
for (const [key1, value] of this.map1) {
|
|
4389
|
-
result.push(fn(value, key1));
|
|
4390
|
-
}
|
|
4391
|
-
return result;
|
|
4392
|
-
}
|
|
4393
|
-
mapValues(fn) {
|
|
4394
|
-
let result = new _Map1();
|
|
4395
|
-
for (const [key1, value] of this.map1) {
|
|
4396
|
-
result.set(key1, fn(value, key1));
|
|
4397
|
-
}
|
|
4398
|
-
return result;
|
|
4399
|
-
}
|
|
4400
|
-
toMap() {
|
|
4401
|
-
return new Map(this.map1);
|
|
4402
|
-
}
|
|
4403
|
-
toString() {
|
|
4404
|
-
const entries = [...this.map1].map(([k, v]) => `${stringify(k)} => ${stringify(v)}`).join(", ");
|
|
4405
|
-
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
|
|
4406
|
-
}
|
|
4407
|
-
};
|
|
4408
4272
|
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
constructor(entries) {
|
|
4412
|
-
super();
|
|
4413
|
-
__publicField(this, "map1", /* @__PURE__ */ new Map());
|
|
4414
|
-
if (entries instanceof _Map2) {
|
|
4415
|
-
for (const [key1, inner] of entries.map1) {
|
|
4416
|
-
this.map1.set(key1, new Map(inner));
|
|
4417
|
-
}
|
|
4418
|
-
} else if (entries) {
|
|
4419
|
-
for (const [key1, key2, value] of entries) {
|
|
4420
|
-
this.set(key1, key2, value);
|
|
4421
|
-
}
|
|
4422
|
-
}
|
|
4423
|
-
}
|
|
4424
|
-
has(key1, key2) {
|
|
4425
|
-
return this.map1.get(key1)?.has(key2) ?? false;
|
|
4426
|
-
}
|
|
4427
|
-
set(key1, key2, value) {
|
|
4428
|
-
let map2 = this.map1.get(key1) ?? this.map1.set(key1, /* @__PURE__ */ new Map()).get(key1);
|
|
4429
|
-
map2.set(key2, value);
|
|
4430
|
-
return value;
|
|
4431
|
-
}
|
|
4432
|
-
get(key1, key2) {
|
|
4433
|
-
return this.map1.get(key1)?.get(key2);
|
|
4434
|
-
}
|
|
4435
|
-
getOrDefault(key1, key2, defaultValue) {
|
|
4436
|
-
return this.get(key1, key2) ?? defaultValue;
|
|
4437
|
-
}
|
|
4438
|
-
getOrCreate(key1, key2, creatorOrValue) {
|
|
4439
|
-
if (!this.has(key1, key2)) {
|
|
4440
|
-
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
4441
|
-
this.set(key1, key2, value);
|
|
4442
|
-
return value;
|
|
4443
|
-
}
|
|
4444
|
-
return this.get(key1, key2);
|
|
4445
|
-
}
|
|
4446
|
-
delete(key1, key2) {
|
|
4447
|
-
if (key2 === void 0) return this.map1.delete(key1);
|
|
4448
|
-
const map2 = this.map1.get(key1);
|
|
4449
|
-
if (!map2) return false;
|
|
4450
|
-
return map2.delete(key2);
|
|
4451
|
-
}
|
|
4452
|
-
clear() {
|
|
4453
|
-
this.map1.clear();
|
|
4454
|
-
}
|
|
4455
|
-
get size() {
|
|
4456
|
-
let count = 0;
|
|
4457
|
-
for (const map2 of this.map1.values()) {
|
|
4458
|
-
count += map2.size;
|
|
4459
|
-
}
|
|
4460
|
-
return count;
|
|
4461
|
-
}
|
|
4462
|
-
isEmpty() {
|
|
4463
|
-
return this.size === 0;
|
|
4464
|
-
}
|
|
4465
|
-
forEach(callbackfn, thisArg) {
|
|
4466
|
-
this.map1.forEach((map2, key1) => map2.forEach((value, key2) => callbackfn.call(thisArg, value, key1, key2, this)));
|
|
4467
|
-
}
|
|
4468
|
-
*keys() {
|
|
4469
|
-
for (const [key1, map2] of this.map1)
|
|
4470
|
-
for (const key2 of map2.keys())
|
|
4471
|
-
yield [key1, key2];
|
|
4472
|
-
}
|
|
4473
|
-
*values() {
|
|
4474
|
-
for (const map2 of this.map1.values())
|
|
4475
|
-
for (const value of map2.values())
|
|
4476
|
-
yield value;
|
|
4477
|
-
}
|
|
4478
|
-
*entries() {
|
|
4479
|
-
for (const [key1, map2] of this.map1)
|
|
4480
|
-
for (const [key2, value] of map2)
|
|
4481
|
-
yield [key1, key2, value];
|
|
4482
|
-
}
|
|
4483
|
-
keysArray() {
|
|
4484
|
-
return [...this.keys()];
|
|
4485
|
-
}
|
|
4486
|
-
valuesArray() {
|
|
4487
|
-
return [...this.values()];
|
|
4488
|
-
}
|
|
4489
|
-
entriesArray() {
|
|
4490
|
-
return [...this.entries()];
|
|
4491
|
-
}
|
|
4492
|
-
*kvKeys() {
|
|
4493
|
-
for (const [key1, key2] of this.keys())
|
|
4494
|
-
yield [key1, key2];
|
|
4495
|
-
}
|
|
4496
|
-
*kvValues() {
|
|
4497
|
-
for (const el of this.values())
|
|
4498
|
-
yield el;
|
|
4499
|
-
}
|
|
4500
|
-
*kvEntries() {
|
|
4501
|
-
for (const [key1, key2, el] of this.entries())
|
|
4502
|
-
yield [[key1, key2], el];
|
|
4503
|
-
}
|
|
4504
|
-
*[Symbol.iterator]() {
|
|
4505
|
-
yield* this.entries();
|
|
4506
|
-
}
|
|
4507
|
-
clone() {
|
|
4508
|
-
return new _Map2(this);
|
|
4509
|
-
}
|
|
4510
|
-
merge(other, conflictResolver) {
|
|
4511
|
-
for (const [key1, key2, value] of other.entries()) {
|
|
4512
|
-
if (this.has(key1, key2) && conflictResolver) {
|
|
4513
|
-
this.set(key1, key2, conflictResolver(this.get(key1, key2), value, key1, key2));
|
|
4514
|
-
} else {
|
|
4515
|
-
this.set(key1, key2, value);
|
|
4516
|
-
}
|
|
4517
|
-
}
|
|
4518
|
-
return this;
|
|
4519
|
-
}
|
|
4520
|
-
some(fn) {
|
|
4521
|
-
for (const [key1, map2] of this.map1) {
|
|
4522
|
-
for (const [key2, value] of map2) {
|
|
4523
|
-
if (fn(value, key1, key2)) return true;
|
|
4524
|
-
}
|
|
4525
|
-
}
|
|
4526
|
-
return false;
|
|
4527
|
-
}
|
|
4528
|
-
every(fn) {
|
|
4529
|
-
for (const [key1, map2] of this.map1) {
|
|
4530
|
-
for (const [key2, value] of map2) {
|
|
4531
|
-
if (!fn(value, key1, key2)) return false;
|
|
4532
|
-
}
|
|
4533
|
-
}
|
|
4534
|
-
return true;
|
|
4535
|
-
}
|
|
4536
|
-
filter(predicate) {
|
|
4537
|
-
const result = new this.constructor();
|
|
4538
|
-
for (const [key1, map2] of this.map1) {
|
|
4539
|
-
for (const [key2, value] of map2) {
|
|
4540
|
-
if (predicate(value, key1, key2, this)) result.set(key1, key2, value);
|
|
4541
|
-
}
|
|
4542
|
-
}
|
|
4543
|
-
return result;
|
|
4544
|
-
}
|
|
4545
|
-
reduce(fn, init) {
|
|
4546
|
-
let iterator = this.entries();
|
|
4547
|
-
let first = iterator.next();
|
|
4548
|
-
if (first.done) {
|
|
4549
|
-
if (arguments.length < 2) {
|
|
4550
|
-
throw new TypeError("Reduce of empty Map2 with no initial value!");
|
|
4551
|
-
}
|
|
4552
|
-
return init;
|
|
4553
|
-
}
|
|
4554
|
-
let acc;
|
|
4555
|
-
let start;
|
|
4556
|
-
if (arguments.length < 2) {
|
|
4557
|
-
acc = first.value[2];
|
|
4558
|
-
start = iterator.next();
|
|
4559
|
-
} else {
|
|
4560
|
-
acc = init;
|
|
4561
|
-
start = first;
|
|
4562
|
-
}
|
|
4563
|
-
for (let current = start; !current.done; current = iterator.next()) {
|
|
4564
|
-
const [key1, key2, value] = current.value;
|
|
4565
|
-
acc = fn(acc, value, key1, key2);
|
|
4566
|
-
}
|
|
4567
|
-
return acc;
|
|
4568
|
-
}
|
|
4569
|
-
mapEntries(fn) {
|
|
4570
|
-
let result = [];
|
|
4571
|
-
for (const [key1, map2] of this.map1) {
|
|
4572
|
-
for (const [key2, value] of map2) {
|
|
4573
|
-
result.push(fn(value, key1, key2));
|
|
4574
|
-
}
|
|
4575
|
-
}
|
|
4576
|
-
return result;
|
|
4577
|
-
}
|
|
4578
|
-
mapValues(fn) {
|
|
4579
|
-
let result = new _Map2();
|
|
4580
|
-
for (const [key1, map2] of this.map1) {
|
|
4581
|
-
for (const [key2, value] of map2) {
|
|
4582
|
-
result.set(key1, key2, fn(value, key1, key2));
|
|
4583
|
-
}
|
|
4584
|
-
}
|
|
4585
|
-
return result;
|
|
4586
|
-
}
|
|
4587
|
-
toMap() {
|
|
4588
|
-
let result = /* @__PURE__ */ new Map();
|
|
4589
|
-
for (const [key1, map2] of this.map1) {
|
|
4590
|
-
for (const [key2, value] of map2) {
|
|
4591
|
-
result.set([key1, key2], value);
|
|
4592
|
-
}
|
|
4593
|
-
}
|
|
4594
|
-
return result;
|
|
4595
|
-
}
|
|
4596
|
-
toString() {
|
|
4597
|
-
const entries = [];
|
|
4598
|
-
for (const [key1, map2] of this.map1) {
|
|
4599
|
-
const inner = [...map2].map(([key2, v]) => `${stringify(key2)} => ${stringify(v)}`).join(", ");
|
|
4600
|
-
entries.push(`${stringify(key1)} => { ${inner} }`);
|
|
4601
|
-
}
|
|
4602
|
-
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
|
|
4603
|
-
}
|
|
4604
|
-
};
|
|
4605
|
-
|
|
4606
|
-
// src/deprecated/map3.ts
|
|
4607
|
-
var Map3 = class _Map3 extends BaseContainer {
|
|
4608
|
-
constructor(entries) {
|
|
4609
|
-
super();
|
|
4610
|
-
__publicField(this, "map1", /* @__PURE__ */ new Map());
|
|
4611
|
-
if (entries instanceof _Map3) {
|
|
4612
|
-
for (const [key1, map2] of entries.map1) {
|
|
4613
|
-
const newMap2 = /* @__PURE__ */ new Map();
|
|
4614
|
-
for (const [key2, map3] of map2) {
|
|
4615
|
-
newMap2.set(key2, new Map(map3));
|
|
4616
|
-
}
|
|
4617
|
-
this.map1.set(key1, newMap2);
|
|
4618
|
-
}
|
|
4619
|
-
} else if (entries) {
|
|
4620
|
-
for (const [key1, key2, key3, value] of entries) {
|
|
4621
|
-
this.set(key1, key2, key3, value);
|
|
4622
|
-
}
|
|
4623
|
-
}
|
|
4624
|
-
}
|
|
4625
|
-
has(key1, key2, key3) {
|
|
4626
|
-
return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
|
|
4627
|
-
}
|
|
4628
|
-
set(key1, key2, key3, value) {
|
|
4629
|
-
let map2 = this.map1.get(key1);
|
|
4630
|
-
if (!map2) this.map1.set(key1, map2 = /* @__PURE__ */ new Map());
|
|
4631
|
-
let map3 = map2.get(key2);
|
|
4632
|
-
if (!map3) map2.set(key2, map3 = /* @__PURE__ */ new Map());
|
|
4633
|
-
map3.set(key3, value);
|
|
4634
|
-
return value;
|
|
4635
|
-
}
|
|
4636
|
-
get(key1, key2, key3) {
|
|
4637
|
-
return this.map1.get(key1)?.get(key2)?.get(key3);
|
|
4638
|
-
}
|
|
4639
|
-
getOrDefault(key1, key2, key3, defaultValue) {
|
|
4640
|
-
return this.get(key1, key2, key3) ?? defaultValue;
|
|
4641
|
-
}
|
|
4642
|
-
getOrCreate(key1, key2, key3, creatorOrValue) {
|
|
4643
|
-
if (!this.has(key1, key2, key3)) {
|
|
4644
|
-
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
4645
|
-
this.set(key1, key2, key3, value);
|
|
4646
|
-
return value;
|
|
4647
|
-
}
|
|
4648
|
-
return this.get(key1, key2, key3);
|
|
4649
|
-
}
|
|
4650
|
-
delete(key1, key2, key3) {
|
|
4651
|
-
if (key3 === void 0) {
|
|
4652
|
-
if (key2 === void 0) return this.map1.delete(key1);
|
|
4653
|
-
const map2 = this.map1.get(key1);
|
|
4654
|
-
if (!map2) return false;
|
|
4655
|
-
return map2.delete(key2);
|
|
4656
|
-
} else {
|
|
4657
|
-
if (key2 === void 0) return this.map1.delete(key1);
|
|
4658
|
-
const map3 = this.map1.get(key1)?.get(key2);
|
|
4659
|
-
if (!map3) return false;
|
|
4660
|
-
return map3.delete(key3);
|
|
4661
|
-
}
|
|
4662
|
-
}
|
|
4663
|
-
clear() {
|
|
4664
|
-
this.map1.clear();
|
|
4665
|
-
}
|
|
4666
|
-
get size() {
|
|
4667
|
-
let count = 0;
|
|
4668
|
-
for (const map2 of this.map1.values()) {
|
|
4669
|
-
for (const map3 of map2.values()) {
|
|
4670
|
-
count += map3.size;
|
|
4671
|
-
}
|
|
4672
|
-
}
|
|
4673
|
-
return count;
|
|
4674
|
-
}
|
|
4675
|
-
isEmpty() {
|
|
4676
|
-
return this.size === 0;
|
|
4677
|
-
}
|
|
4678
|
-
forEach(callbackfn, thisArg) {
|
|
4679
|
-
this.map1.forEach((map2, key1) => map2.forEach((map3, key2) => map3.forEach((value, key3) => callbackfn.call(thisArg, value, key1, key2, key3, this))));
|
|
4680
|
-
}
|
|
4681
|
-
*keys() {
|
|
4682
|
-
for (const [key1, map2] of this.map1)
|
|
4683
|
-
for (const [key2, map3] of map2)
|
|
4684
|
-
for (const key3 of map3.keys())
|
|
4685
|
-
yield [key1, key2, key3];
|
|
4686
|
-
}
|
|
4687
|
-
*values() {
|
|
4688
|
-
for (const map2 of this.map1.values())
|
|
4689
|
-
for (const map3 of map2.values())
|
|
4690
|
-
for (const value of map3.values())
|
|
4691
|
-
yield value;
|
|
4692
|
-
}
|
|
4693
|
-
*entries() {
|
|
4694
|
-
for (const [key1, map2] of this.map1)
|
|
4695
|
-
for (const [key2, map3] of map2)
|
|
4696
|
-
for (const [key3, value] of map3)
|
|
4697
|
-
yield [key1, key2, key3, value];
|
|
4698
|
-
}
|
|
4699
|
-
keysArray() {
|
|
4700
|
-
return [...this.keys()];
|
|
4701
|
-
}
|
|
4702
|
-
valuesArray() {
|
|
4703
|
-
return [...this.values()];
|
|
4704
|
-
}
|
|
4705
|
-
entriesArray() {
|
|
4706
|
-
return [...this.entries()];
|
|
4707
|
-
}
|
|
4708
|
-
*kvKeys() {
|
|
4709
|
-
for (const [key1, key2, key3] of this.keys())
|
|
4710
|
-
yield [key1, key2, key3];
|
|
4711
|
-
}
|
|
4712
|
-
*kvValues() {
|
|
4713
|
-
for (const el of this.values())
|
|
4714
|
-
yield el;
|
|
4715
|
-
}
|
|
4716
|
-
*kvEntries() {
|
|
4717
|
-
for (const [key1, key2, key3, el] of this.entries())
|
|
4718
|
-
yield [[key1, key2, key3], el];
|
|
4719
|
-
}
|
|
4720
|
-
*[Symbol.iterator]() {
|
|
4721
|
-
yield* this.entries();
|
|
4722
|
-
}
|
|
4723
|
-
clone() {
|
|
4724
|
-
return new _Map3(this);
|
|
4725
|
-
}
|
|
4726
|
-
merge(other, conflictResolver) {
|
|
4727
|
-
for (const [key1, key2, key3, value] of other.entries()) {
|
|
4728
|
-
if (this.has(key1, key2, key3) && conflictResolver) {
|
|
4729
|
-
this.set(key1, key2, key3, conflictResolver(this.get(key1, key2, key3), value, key1, key2, key3));
|
|
4730
|
-
} else {
|
|
4731
|
-
this.set(key1, key2, key3, value);
|
|
4732
|
-
}
|
|
4733
|
-
}
|
|
4734
|
-
return this;
|
|
4735
|
-
}
|
|
4736
|
-
some(fn) {
|
|
4737
|
-
for (const [key1, map2] of this.map1) {
|
|
4738
|
-
for (const [key2, map3] of map2) {
|
|
4739
|
-
for (const [key3, value] of map3) {
|
|
4740
|
-
if (fn(value, key1, key2, key3)) return true;
|
|
4741
|
-
}
|
|
4742
|
-
}
|
|
4743
|
-
}
|
|
4744
|
-
return false;
|
|
4745
|
-
}
|
|
4746
|
-
every(fn) {
|
|
4747
|
-
for (const [key1, map2] of this.map1) {
|
|
4748
|
-
for (const [key2, map3] of map2) {
|
|
4749
|
-
for (const [key3, value] of map3) {
|
|
4750
|
-
if (!fn(value, key1, key2, key3)) return false;
|
|
4751
|
-
}
|
|
4752
|
-
}
|
|
4753
|
-
}
|
|
4754
|
-
return true;
|
|
4755
|
-
}
|
|
4756
|
-
filter(predicate) {
|
|
4757
|
-
const result = new this.constructor();
|
|
4758
|
-
for (const [key1, map2] of this.map1) {
|
|
4759
|
-
for (const [key2, map3] of map2) {
|
|
4760
|
-
for (const [key3, value] of map3) {
|
|
4761
|
-
if (predicate(value, key1, key2, key3, this)) result.set(key1, key2, key3, value);
|
|
4762
|
-
}
|
|
4763
|
-
}
|
|
4764
|
-
}
|
|
4765
|
-
return result;
|
|
4766
|
-
}
|
|
4767
|
-
reduce(fn, init) {
|
|
4768
|
-
let iterator = this.entries();
|
|
4769
|
-
let first = iterator.next();
|
|
4770
|
-
if (first.done) {
|
|
4771
|
-
if (arguments.length < 2) {
|
|
4772
|
-
throw new TypeError("Reduce of empty Map3 with no initial value!");
|
|
4773
|
-
}
|
|
4774
|
-
return init;
|
|
4775
|
-
}
|
|
4776
|
-
let acc;
|
|
4777
|
-
let start;
|
|
4778
|
-
if (arguments.length < 2) {
|
|
4779
|
-
acc = first.value[3];
|
|
4780
|
-
start = iterator.next();
|
|
4781
|
-
} else {
|
|
4782
|
-
acc = init;
|
|
4783
|
-
start = first;
|
|
4784
|
-
}
|
|
4785
|
-
for (let current = start; !current.done; current = iterator.next()) {
|
|
4786
|
-
const [key1, key2, key3, value] = current.value;
|
|
4787
|
-
acc = fn(acc, value, key1, key2, key3);
|
|
4788
|
-
}
|
|
4789
|
-
return acc;
|
|
4790
|
-
}
|
|
4791
|
-
mapEntries(fn) {
|
|
4792
|
-
let result = [];
|
|
4793
|
-
for (const [key1, map2] of this.map1) {
|
|
4794
|
-
for (const [key2, map3] of map2) {
|
|
4795
|
-
for (const [key3, value] of map3) {
|
|
4796
|
-
result.push(fn(value, key1, key2, key3));
|
|
4797
|
-
}
|
|
4798
|
-
}
|
|
4799
|
-
}
|
|
4800
|
-
return result;
|
|
4801
|
-
}
|
|
4802
|
-
mapValues(fn) {
|
|
4803
|
-
let result = new _Map3();
|
|
4804
|
-
for (const [key1, map2] of this.map1) {
|
|
4805
|
-
for (const [key2, map3] of map2) {
|
|
4806
|
-
for (const [key3, value] of map3) {
|
|
4807
|
-
result.set(key1, key2, key3, fn(value, key1, key2, key3));
|
|
4808
|
-
}
|
|
4809
|
-
}
|
|
4810
|
-
}
|
|
4811
|
-
return result;
|
|
4812
|
-
}
|
|
4813
|
-
toMap() {
|
|
4814
|
-
let result = /* @__PURE__ */ new Map();
|
|
4815
|
-
for (const [key1, map2] of this.map1) {
|
|
4816
|
-
for (const [key2, map3] of map2) {
|
|
4817
|
-
for (const [key3, value] of map3) {
|
|
4818
|
-
result.set([key1, key2, key3], value);
|
|
4819
|
-
}
|
|
4820
|
-
}
|
|
4821
|
-
}
|
|
4822
|
-
return result;
|
|
4823
|
-
}
|
|
4824
|
-
toString() {
|
|
4825
|
-
const entries = [];
|
|
4826
|
-
for (const [key1, map2] of this.map1) {
|
|
4827
|
-
for (const [key2, map3] of map2) {
|
|
4828
|
-
const inner = [...map3].map(([key3, v]) => `${stringify(key3)} => ${stringify(v)}`).join(", ");
|
|
4829
|
-
entries.push(`${stringify(key1)} => ${stringify(key2)} => { ${inner} }`);
|
|
4830
|
-
}
|
|
4831
|
-
}
|
|
4832
|
-
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries.join(", ")} }`;
|
|
4833
|
-
}
|
|
4834
|
-
};
|
|
4835
|
-
|
|
4836
|
-
// src/deprecated/set.ts
|
|
4837
|
-
var SetBase = class extends BaseContainer {
|
|
4838
|
-
constructor(entries) {
|
|
4839
|
-
super();
|
|
4840
|
-
__publicField(this, "data");
|
|
4841
|
-
this.data = new Set(entries ?? []);
|
|
4842
|
-
}
|
|
4843
|
-
has(value) {
|
|
4844
|
-
return this.some((v) => this.valueEquals(v, value));
|
|
4845
|
-
}
|
|
4846
|
-
add(value) {
|
|
4847
|
-
if (!this.has(value))
|
|
4848
|
-
this.data.add(value);
|
|
4849
|
-
return value;
|
|
4850
|
-
}
|
|
4851
|
-
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
4852
|
-
set(key, value) {
|
|
4853
|
-
if (!this.valueEquals(key, value))
|
|
4854
|
-
throw new TypeError("SetBase.set() requires key === value.");
|
|
4855
|
-
this.add(value);
|
|
4856
|
-
}
|
|
4857
|
-
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
4858
|
-
get(key) {
|
|
4859
|
-
return this.has(key) ? key : void 0;
|
|
4860
|
-
}
|
|
4861
|
-
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
4862
|
-
getOrDefault(key, defaultValue) {
|
|
4863
|
-
return this.get(key) ?? defaultValue;
|
|
4864
|
-
}
|
|
4865
|
-
getOrCreate(key, creatorOrValue) {
|
|
4866
|
-
if (!this.has(key)) {
|
|
4867
|
-
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
4868
|
-
this.set(key, value);
|
|
4869
|
-
return value;
|
|
4870
|
-
}
|
|
4871
|
-
return this.get(key);
|
|
4872
|
-
}
|
|
4873
|
-
delete(value) {
|
|
4874
|
-
if (!this.has(value)) return false;
|
|
4875
|
-
for (const v of this.values()) {
|
|
4876
|
-
if (this.valueEquals(v, value)) {
|
|
4877
|
-
this.data.delete(v);
|
|
4878
|
-
return true;
|
|
4879
|
-
}
|
|
4880
|
-
}
|
|
4881
|
-
return false;
|
|
4882
|
-
}
|
|
4883
|
-
clear() {
|
|
4884
|
-
this.data.clear();
|
|
4885
|
-
}
|
|
4886
|
-
get size() {
|
|
4887
|
-
return this.data.size;
|
|
4888
|
-
}
|
|
4889
|
-
isEmpty() {
|
|
4890
|
-
return this.size === 0;
|
|
4891
|
-
}
|
|
4892
|
-
forEach(callbackfn, thisArg) {
|
|
4893
|
-
this.data.forEach((value) => callbackfn.call(thisArg, value, this));
|
|
4894
|
-
}
|
|
4895
|
-
*keys() {
|
|
4896
|
-
yield* this.data.keys();
|
|
4897
|
-
}
|
|
4898
|
-
*values() {
|
|
4899
|
-
yield* this.data.values();
|
|
4900
|
-
}
|
|
4901
|
-
*entries() {
|
|
4902
|
-
yield* this.data.entries();
|
|
4903
|
-
}
|
|
4904
|
-
*kvKeys() {
|
|
4905
|
-
for (const key of this.keys()) {
|
|
4906
|
-
yield [key];
|
|
4907
|
-
}
|
|
4908
|
-
}
|
|
4909
|
-
*kvValues() {
|
|
4910
|
-
for (const el of this.values()) {
|
|
4911
|
-
yield el;
|
|
4912
|
-
}
|
|
4913
|
-
}
|
|
4914
|
-
*kvEntries() {
|
|
4915
|
-
for (const [key, el] of this.entries()) {
|
|
4916
|
-
yield [[key], el];
|
|
4917
|
-
}
|
|
4918
|
-
}
|
|
4919
|
-
*[Symbol.iterator]() {
|
|
4920
|
-
yield* this.values();
|
|
4921
|
-
}
|
|
4922
|
-
clone() {
|
|
4923
|
-
const result = this.createEmpty();
|
|
4924
|
-
for (const v of this.values()) result.add(v);
|
|
4925
|
-
return result;
|
|
4926
|
-
}
|
|
4927
|
-
merge(other) {
|
|
4928
|
-
for (const value of other.values()) {
|
|
4929
|
-
this.add(value);
|
|
4930
|
-
}
|
|
4931
|
-
return this;
|
|
4932
|
-
}
|
|
4933
|
-
some(fn) {
|
|
4934
|
-
for (const value of this.data) {
|
|
4935
|
-
if (fn(value)) return true;
|
|
4936
|
-
}
|
|
4937
|
-
return false;
|
|
4938
|
-
}
|
|
4939
|
-
every(fn) {
|
|
4940
|
-
for (const value of this.data) {
|
|
4941
|
-
if (!fn(value)) return false;
|
|
4942
|
-
}
|
|
4943
|
-
return true;
|
|
4944
|
-
}
|
|
4945
|
-
filter(predicate) {
|
|
4946
|
-
const result = this.createEmpty();
|
|
4947
|
-
for (const value of this.data)
|
|
4948
|
-
if (predicate(value, this)) result.add(value);
|
|
4949
|
-
return result;
|
|
4950
|
-
}
|
|
4951
|
-
reduce(fn, init) {
|
|
4952
|
-
let iterator = this.values();
|
|
4953
|
-
let first = iterator.next();
|
|
4954
|
-
if (first.done) {
|
|
4955
|
-
if (arguments.length < 2) {
|
|
4956
|
-
throw new TypeError("Reduce of empty SetBase with no initial value!");
|
|
4957
|
-
}
|
|
4958
|
-
return init;
|
|
4959
|
-
}
|
|
4960
|
-
let acc;
|
|
4961
|
-
let start;
|
|
4962
|
-
if (arguments.length < 2) {
|
|
4963
|
-
acc = first.value;
|
|
4964
|
-
start = iterator.next();
|
|
4965
|
-
} else {
|
|
4966
|
-
acc = init;
|
|
4967
|
-
start = first;
|
|
4968
|
-
}
|
|
4969
|
-
for (let current = start; !current.done; current = iterator.next()) {
|
|
4970
|
-
const value = current.value;
|
|
4971
|
-
acc = fn(acc, value);
|
|
4972
|
-
}
|
|
4973
|
-
return acc;
|
|
4974
|
-
}
|
|
4975
|
-
mapValues(fn) {
|
|
4976
|
-
let result = this.createEmpty();
|
|
4977
|
-
for (const value of this.data) {
|
|
4978
|
-
result.add(fn(value));
|
|
4979
|
-
}
|
|
4980
|
-
return result;
|
|
4981
|
-
}
|
|
4982
|
-
mapToArray(fn) {
|
|
4983
|
-
let result = [];
|
|
4984
|
-
for (const value of this.values()) {
|
|
4985
|
-
result.push(fn(value));
|
|
4986
|
-
}
|
|
4987
|
-
return result;
|
|
4988
|
-
}
|
|
4989
|
-
map(fn) {
|
|
4990
|
-
let result = this.createEmpty();
|
|
4991
|
-
for (const value of this.values()) {
|
|
4992
|
-
result.add(fn(value));
|
|
4993
|
-
}
|
|
4994
|
-
return result;
|
|
4995
|
-
}
|
|
4996
|
-
toSet() {
|
|
4997
|
-
return new Set(this.data);
|
|
4998
|
-
}
|
|
4999
|
-
toArray() {
|
|
5000
|
-
return [...this.values()];
|
|
5001
|
-
}
|
|
5002
|
-
toString() {
|
|
5003
|
-
return stringify(this.data);
|
|
5004
|
-
}
|
|
5005
|
-
};
|
|
5006
|
-
var Set1 = class _Set1 extends SetBase {
|
|
5007
|
-
constructor(entries) {
|
|
5008
|
-
super(entries);
|
|
5009
|
-
}
|
|
5010
|
-
createEmpty() {
|
|
5011
|
-
return new _Set1();
|
|
5012
|
-
}
|
|
5013
|
-
valueEquals(a, b) {
|
|
5014
|
-
return a === b;
|
|
5015
|
-
}
|
|
5016
|
-
};
|
|
5017
|
-
var DeepSet = class _DeepSet extends SetBase {
|
|
5018
|
-
constructor(entries) {
|
|
5019
|
-
super(entries);
|
|
5020
|
-
}
|
|
5021
|
-
createEmpty() {
|
|
5022
|
-
return new _DeepSet();
|
|
5023
|
-
}
|
|
5024
|
-
valueEquals(a, b) {
|
|
5025
|
-
return isDeepEqual2(a, b);
|
|
5026
|
-
}
|
|
5027
|
-
};
|
|
5028
|
-
|
|
5029
|
-
// src/deprecated/div-rect.ts
|
|
5030
|
-
var DivRect = class _DivRect {
|
|
5031
|
-
constructor(...args) {
|
|
5032
|
-
__publicField(this, "left");
|
|
5033
|
-
__publicField(this, "anchorX");
|
|
5034
|
-
__publicField(this, "right");
|
|
5035
|
-
__publicField(this, "top");
|
|
5036
|
-
__publicField(this, "anchorY");
|
|
5037
|
-
__publicField(this, "bottom");
|
|
5038
|
-
if (args.length === 6) {
|
|
5039
|
-
this.left = args[0];
|
|
5040
|
-
this.anchorX = args[1];
|
|
5041
|
-
this.right = args[2];
|
|
5042
|
-
this.top = args[3];
|
|
5043
|
-
this.anchorY = args[4];
|
|
5044
|
-
this.bottom = args[5];
|
|
5045
|
-
} else if (args.length === 4) {
|
|
5046
|
-
this.left = args[0];
|
|
5047
|
-
this.right = args[1];
|
|
5048
|
-
this.anchorX = (this.left + this.right) / 2;
|
|
5049
|
-
this.top = args[2];
|
|
5050
|
-
this.bottom = args[3];
|
|
5051
|
-
this.anchorY = (this.top + this.bottom) / 2;
|
|
5052
|
-
} else if (args.length === 0) {
|
|
5053
|
-
this.left = this.anchorX = this.right = 0;
|
|
5054
|
-
this.top = this.anchorY = this.bottom = 0;
|
|
5055
|
-
} else {
|
|
5056
|
-
throw new TypeError(`Invalid DivRect args: ${args}`);
|
|
5057
|
-
}
|
|
5058
|
-
}
|
|
5059
|
-
set(...args) {
|
|
5060
|
-
if (args.length === 6) {
|
|
5061
|
-
this.left = args[0];
|
|
5062
|
-
this.anchorX = args[1];
|
|
5063
|
-
this.right = args[2];
|
|
5064
|
-
this.top = args[3];
|
|
5065
|
-
this.anchorY = args[4];
|
|
5066
|
-
this.bottom = args[5];
|
|
5067
|
-
} else if (args.length === 4) {
|
|
5068
|
-
this.left = args[0];
|
|
5069
|
-
this.right = args[1];
|
|
5070
|
-
this.anchorX = (this.left + this.right) / 2;
|
|
5071
|
-
this.top = args[2];
|
|
5072
|
-
this.bottom = args[3];
|
|
5073
|
-
this.anchorY = (this.top + this.bottom) / 2;
|
|
5074
|
-
} else if (args.length === 0) {
|
|
5075
|
-
this.left = this.anchorX = this.right = 0;
|
|
5076
|
-
this.top = this.anchorY = this.bottom = 0;
|
|
5077
|
-
} else {
|
|
5078
|
-
throw new TypeError(`Invalid DivRect args: ${args}`);
|
|
5079
|
-
}
|
|
5080
|
-
return this;
|
|
5081
|
-
}
|
|
5082
|
-
/**
|
|
5083
|
-
* Create rect from basic left, top, width and height arguments.
|
|
5084
|
-
*
|
|
5085
|
-
* @param left - Left coordinate.
|
|
5086
|
-
* @param top - Top coordinate.
|
|
5087
|
-
* @param width - Width.
|
|
5088
|
-
* @param height - Height.
|
|
5089
|
-
* @returns - DivRect.
|
|
5090
|
-
*/
|
|
5091
|
-
static create(left, top, width, height) {
|
|
5092
|
-
return new _DivRect(left, left + width, top, top + height);
|
|
5093
|
-
}
|
|
5094
|
-
/**
|
|
5095
|
-
* Create rect from anchorX, anchorY, width, height arguments.
|
|
5096
|
-
*
|
|
5097
|
-
* @param centerX - Center x-coordinate.
|
|
5098
|
-
* @param centerY - Center y-coordinate.
|
|
5099
|
-
* @param width - Width.
|
|
5100
|
-
* @param height - Height.
|
|
5101
|
-
* @returns - DivRect.
|
|
5102
|
-
*/
|
|
5103
|
-
static createCentered(centerX, centerY, width, height) {
|
|
5104
|
-
return new _DivRect(
|
|
5105
|
-
centerX - width / 2,
|
|
5106
|
-
centerX,
|
|
5107
|
-
centerX + width / 2,
|
|
5108
|
-
centerY - height / 2,
|
|
5109
|
-
centerY,
|
|
5110
|
-
centerY + height / 2
|
|
5111
|
-
);
|
|
5112
|
-
}
|
|
5113
|
-
/**
|
|
5114
|
-
* Create rect from sections.
|
|
5115
|
-
*
|
|
5116
|
-
* @param leftw - Left section width.
|
|
5117
|
-
* @param rightw - Right section width.
|
|
5118
|
-
* @param toph - Top section height.
|
|
5119
|
-
* @param bottomh - Bottomsection height.
|
|
5120
|
-
* @returns - DivRect.
|
|
5121
|
-
*/
|
|
5122
|
-
static createSections(leftw, rightw, toph, bottomh) {
|
|
5123
|
-
return new _DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
|
|
5124
|
-
}
|
|
5125
|
-
/**
|
|
5126
|
-
* @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
|
|
5127
|
-
* @private
|
|
5128
|
-
* */
|
|
5129
|
-
get centerX() {
|
|
5130
|
-
return this.anchorX;
|
|
5131
|
-
}
|
|
5132
|
-
/**
|
|
5133
|
-
* @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
|
|
5134
|
-
* @private
|
|
5135
|
-
* */
|
|
5136
|
-
set centerX(x) {
|
|
5137
|
-
this.anchorX = x;
|
|
5138
|
-
}
|
|
5139
|
-
/**
|
|
5140
|
-
* @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
|
|
5141
|
-
* @private
|
|
5142
|
-
* */
|
|
5143
|
-
get centerY() {
|
|
5144
|
-
return this.anchorY;
|
|
5145
|
-
}
|
|
5146
|
-
/**
|
|
5147
|
-
* @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
|
|
5148
|
-
* @private
|
|
5149
|
-
* */
|
|
5150
|
-
set centerY(y) {
|
|
5151
|
-
this.anchorY = y;
|
|
5152
|
-
}
|
|
5153
|
-
/**
|
|
5154
|
-
* Width getter.
|
|
5155
|
-
*/
|
|
5156
|
-
get width() {
|
|
5157
|
-
return this.right - this.left;
|
|
5158
|
-
}
|
|
5159
|
-
/**
|
|
5160
|
-
* Height getter.
|
|
5161
|
-
*/
|
|
5162
|
-
get height() {
|
|
5163
|
-
return this.bottom - this.top;
|
|
5164
|
-
}
|
|
5165
|
-
/**
|
|
5166
|
-
* Left section width getter.
|
|
5167
|
-
*/
|
|
5168
|
-
get leftw() {
|
|
5169
|
-
return this.anchorX - this.left;
|
|
5170
|
-
}
|
|
5171
|
-
/**
|
|
5172
|
-
* Right section width getter.
|
|
5173
|
-
*/
|
|
5174
|
-
get rightw() {
|
|
5175
|
-
return this.right - this.anchorX;
|
|
5176
|
-
}
|
|
5177
|
-
/**
|
|
5178
|
-
* Top section height getter.
|
|
5179
|
-
*/
|
|
5180
|
-
get toph() {
|
|
5181
|
-
return this.anchorY - this.top;
|
|
5182
|
-
}
|
|
5183
|
-
/**
|
|
5184
|
-
* Bottom section height getter.
|
|
5185
|
-
*/
|
|
5186
|
-
get bottomh() {
|
|
5187
|
-
return this.bottom - this.anchorY;
|
|
5188
|
-
}
|
|
5189
|
-
/**
|
|
5190
|
-
* Does this Rect contain given (x, y)-point?
|
|
5191
|
-
*
|
|
5192
|
-
* @param x - X-coordinate.
|
|
5193
|
-
* @param y - Y-coordinate.
|
|
5194
|
-
* @returns - True/false.
|
|
5195
|
-
*/
|
|
5196
|
-
contains(x, y) {
|
|
5197
|
-
return x >= this.left && x <= this.right && y >= this.top && y <= this.bottom;
|
|
5198
|
-
}
|
|
5199
|
-
/**
|
|
5200
|
-
* Do a and b rects overlap?
|
|
5201
|
-
*
|
|
5202
|
-
* @param a - DivRect a.
|
|
5203
|
-
* @param b - DivRect b.
|
|
5204
|
-
* @returns - True/false.
|
|
5205
|
-
*/
|
|
5206
|
-
static overlap(a, b) {
|
|
5207
|
-
return a.right > b.left && a.left < b.right && a.bottom > b.top && a.top < b.bottom;
|
|
5208
|
-
}
|
|
5209
|
-
/**
|
|
5210
|
-
* Do horizontal measures of a and b rects overlap?
|
|
5211
|
-
*
|
|
5212
|
-
* @param a - DivRect a.
|
|
5213
|
-
* @param b - DivRect b.
|
|
5214
|
-
* @returns - True/false.
|
|
5215
|
-
*/
|
|
5216
|
-
static overlapX(a, b) {
|
|
5217
|
-
return a.right > b.left && a.left < b.right;
|
|
5218
|
-
}
|
|
5219
|
-
/**
|
|
5220
|
-
* Check if given rects are equal.
|
|
5221
|
-
* @param a - DivRect a.
|
|
5222
|
-
* @param b - DivRect b.
|
|
5223
|
-
* @returns - True/false.
|
|
5224
|
-
*/
|
|
5225
|
-
static equals(a, b) {
|
|
5226
|
-
if (a == null && b == null) {
|
|
5227
|
-
return true;
|
|
5228
|
-
} else if (a == null || b == null) {
|
|
5229
|
-
return false;
|
|
5230
|
-
} else {
|
|
5231
|
-
return a === b || a.left === b.left && a.anchorX === b.anchorX && a.right === b.right && a.top === b.top && a.anchorY === b.anchorY && a.bottom === b.bottom;
|
|
5232
|
-
}
|
|
5233
|
-
}
|
|
5234
|
-
/**
|
|
5235
|
-
* Check if this rect equals with another rect.
|
|
5236
|
-
* @param other - The other rect.
|
|
5237
|
-
* @returns - True/false.
|
|
5238
|
-
*/
|
|
5239
|
-
equals(other) {
|
|
5240
|
-
return _DivRect.equals(this, other);
|
|
5241
|
-
}
|
|
5242
|
-
/**
|
|
5243
|
-
* Check if edges of given rects are equal, ignoring anchorX and anchorY.
|
|
5244
|
-
*
|
|
5245
|
-
* @param a - DivRect a.
|
|
5246
|
-
* @param b - DivRect b.
|
|
5247
|
-
* @returns - True/false.
|
|
5248
|
-
*/
|
|
5249
|
-
static equalsEdges(a, b) {
|
|
5250
|
-
if (a == null && b == null) {
|
|
5251
|
-
return true;
|
|
5252
|
-
} else if (a == null || b == null) {
|
|
5253
|
-
return false;
|
|
5254
|
-
} else {
|
|
5255
|
-
return a === b || a.left === b.left && a.right === b.right && a.top === b.top && a.bottom === b.bottom;
|
|
5256
|
-
}
|
|
5257
|
-
}
|
|
5258
|
-
/**
|
|
5259
|
-
* Check if edges of this Rect equals with given Rect, ignoring anchorX and anchorY.
|
|
5260
|
-
*
|
|
5261
|
-
* @param other - The other DivRect.
|
|
5262
|
-
* @returns - True/false.
|
|
5263
|
-
*/
|
|
5264
|
-
equalsEdges(other) {
|
|
5265
|
-
return _DivRect.equalsEdges(this, other);
|
|
5266
|
-
}
|
|
5267
|
-
/**
|
|
5268
|
-
* @deprecated - Use {@link equalsEdges()} instead. Will be removed in v2.0.0.
|
|
5269
|
-
* @private
|
|
5270
|
-
*/
|
|
5271
|
-
static equalsFrame(a, b) {
|
|
5272
|
-
return _DivRect.equalsEdges(a, b);
|
|
5273
|
-
}
|
|
5274
|
-
/**
|
|
5275
|
-
* @deprecated - Use {@link clone()} instead. Will be removed in v2.0.0.
|
|
5276
|
-
* @private
|
|
5277
|
-
*/
|
|
5278
|
-
copy() {
|
|
5279
|
-
return new _DivRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
|
|
5280
|
-
}
|
|
5281
|
-
/**
|
|
5282
|
-
* Created duplicate of this Rect.
|
|
5283
|
-
* @returns - Duplicate.
|
|
5284
|
-
*/
|
|
5285
|
-
clone() {
|
|
5286
|
-
return new _DivRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
|
|
5287
|
-
}
|
|
5288
|
-
/**
|
|
5289
|
-
* Move this rect by (dx, dy). Modifies this Rect.
|
|
5290
|
-
*
|
|
5291
|
-
* @param dx - Offset amount in x-direction.
|
|
5292
|
-
* @param dy - Offset amount in y-direction.
|
|
5293
|
-
* @returns - This DivRect instance.
|
|
5294
|
-
*/
|
|
5295
|
-
offsetInPlace(dx, dy) {
|
|
5296
|
-
this.left += dx;
|
|
5297
|
-
this.anchorX += dx;
|
|
5298
|
-
this.right += dx;
|
|
5299
|
-
this.top += dy;
|
|
5300
|
-
this.anchorY += dy;
|
|
5301
|
-
this.bottom += dy;
|
|
5302
|
-
return this;
|
|
5303
|
-
}
|
|
5304
|
-
/**
|
|
5305
|
-
* Move this rect by (dx, dy). Immutable, returns modified copy.
|
|
5306
|
-
*
|
|
5307
|
-
* @param dx - Offset amount in x-direction.
|
|
5308
|
-
* @param dy - Offset amount in y-direction.
|
|
5309
|
-
* @returns - DivRect copy with applied offset.
|
|
5310
|
-
*/
|
|
5311
|
-
offsetCopy(dx, dy) {
|
|
5312
|
-
return this.clone().offsetInPlace(dx, dy);
|
|
5313
|
-
}
|
|
5314
|
-
/**
|
|
5315
|
-
* Expand this Rect by given Rect. Modifies this Rect.
|
|
5316
|
-
*
|
|
5317
|
-
* @param rect - DivRect to expand this instance with.
|
|
5318
|
-
* @returns - This DivRect instance.
|
|
5319
|
-
*/
|
|
5320
|
-
expandInPlace(rect) {
|
|
5321
|
-
this.left = Math.min(this.left, rect.left);
|
|
5322
|
-
this.right = Math.max(this.right, rect.right);
|
|
5323
|
-
this.top = Math.min(this.top, rect.top);
|
|
5324
|
-
this.bottom = Math.max(this.bottom, rect.bottom);
|
|
5325
|
-
return this;
|
|
5326
|
-
}
|
|
5327
|
-
/**
|
|
5328
|
-
* Expand this Rect by given Rect. Immutable, returns modified copy.
|
|
5329
|
-
*
|
|
5330
|
-
* @param rect - DivRect to expand this instance with.
|
|
5331
|
-
* @returns - Expanded copy of this DivRect.
|
|
5332
|
-
*/
|
|
5333
|
-
expandCopy(rect) {
|
|
5334
|
-
return this.clone().expandInPlace(rect);
|
|
5335
|
-
}
|
|
5336
|
-
/**
|
|
5337
|
-
* Clip this Rect by given Rect. Mmodifies this Rect.
|
|
5338
|
-
*
|
|
5339
|
-
* @param clipRect - DivRect to clip this instance with.
|
|
5340
|
-
* @returns - This DivRect instance.
|
|
5341
|
-
*/
|
|
5342
|
-
clipInPlace(clipRect) {
|
|
5343
|
-
this.left = Math.max(this.left, clipRect.left);
|
|
5344
|
-
this.right = Math.min(this.right, clipRect.right);
|
|
5345
|
-
this.anchorX = clamp(this.anchorX, this.left, this.right);
|
|
5346
|
-
this.top = Math.max(this.top, clipRect.top);
|
|
5347
|
-
this.bottom = Math.min(this.bottom, clipRect.bottom);
|
|
5348
|
-
this.anchorY = clamp(this.anchorY, this.top, this.bottom);
|
|
5349
|
-
return this;
|
|
5350
|
-
}
|
|
5351
|
-
/**
|
|
5352
|
-
* Clip this Rect by given Rect. Immutable, return modified copy.
|
|
5353
|
-
*
|
|
5354
|
-
* @param clipRect - DivRecto to clip this instance with.
|
|
5355
|
-
* @returns - Clipped DivRect copy.
|
|
5356
|
-
*/
|
|
5357
|
-
clipCopy(clipRect) {
|
|
5358
|
-
return this.clone().clipInPlace(clipRect);
|
|
5359
|
-
}
|
|
5360
|
-
/**
|
|
5361
|
-
* Scale Rect. Anchor pos is (anchorX, anchorY). Modifies this Rect.
|
|
5362
|
-
*
|
|
5363
|
-
* @param scaleX - Scale x-amount.
|
|
5364
|
-
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
5365
|
-
* @returns This DivRect instance.
|
|
5366
|
-
*/
|
|
5367
|
-
scaleInPlace(scaleX, scaleY = scaleX) {
|
|
5368
|
-
this.left = this.anchorX - this.leftw * scaleX;
|
|
5369
|
-
this.right = this.anchorX + this.rightw * scaleX;
|
|
5370
|
-
this.top = this.anchorY - this.toph * scaleY;
|
|
5371
|
-
this.bottom = this.anchorY + this.bottomh * scaleY;
|
|
5372
|
-
return this;
|
|
5373
|
-
}
|
|
5374
|
-
/**
|
|
5375
|
-
* Scale Rect. Anchor pos is (anchorX, anchorY). Immutable, returns modified copy.
|
|
5376
|
-
*
|
|
5377
|
-
* @param scaleX - Scale x-amount.
|
|
5378
|
-
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
5379
|
-
* @returns Scaled copy of this DivRect.
|
|
5380
|
-
*/
|
|
5381
|
-
scaleCopy(scaleX, scaleY = scaleX) {
|
|
5382
|
-
return this.clone().scaleInPlace(scaleX, scaleY);
|
|
5383
|
-
}
|
|
5384
|
-
/**
|
|
5385
|
-
* Get this DivRect instance.
|
|
5386
|
-
* @returns - This DivRect instance.
|
|
5387
|
-
*/
|
|
5388
|
-
getRect() {
|
|
5389
|
-
return this;
|
|
5390
|
-
}
|
|
5391
|
-
toRect() {
|
|
5392
|
-
return new Rect(this.left, this.right, this.width, this.height);
|
|
5393
|
-
}
|
|
5394
|
-
};
|
|
5395
|
-
export {
|
|
5396
|
-
AnchoredRect,
|
|
5397
|
-
assert_exports as Assert,
|
|
5398
|
-
BaseContainer,
|
|
5399
|
-
BiMap,
|
|
5400
|
-
cookies_exports as Cookies,
|
|
5401
|
-
DeepSet,
|
|
5402
|
-
DefaultArray,
|
|
5403
|
-
DefaultEqualityFn,
|
|
5404
|
-
device_exports as Device,
|
|
5405
|
-
DivRect,
|
|
5406
|
-
guard_exports as Guard,
|
|
5407
|
-
IndexArray,
|
|
5408
|
-
LRUCache,
|
|
5409
|
-
LinkedList,
|
|
5410
|
-
Map1,
|
|
5411
|
-
Map2,
|
|
5412
|
-
Map3,
|
|
5413
|
-
MultiContainer,
|
|
5414
|
-
Rect,
|
|
5415
|
-
Set1,
|
|
5416
|
-
SetBase,
|
|
5417
|
-
SignedIndexArray,
|
|
5418
|
-
SmallIntCache,
|
|
5419
|
-
Stack,
|
|
5420
|
-
TriMap,
|
|
5421
|
-
UniMap,
|
|
5422
|
-
utils_exports as Utils,
|
|
5423
|
-
ValueSet,
|
|
5424
|
-
Vec,
|
|
5425
|
-
Vec2,
|
|
5426
|
-
asMulti
|
|
5427
|
-
};
|
|
4273
|
+
export { AnchoredRect, assert_exports as Assert, BaseContainer, BiMap, cookies_exports as Cookies, DefaultArray, DefaultEqualityFn, device_exports as Device, guard_exports as Guard, IndexArray, LRUCache, LinkedList, MultiContainer, Rect, SignedIndexArray, Stack, TriMap, UniMap, utils_exports as Utils, ValueSet, Vec, asMulti, getLibInfo };
|
|
4274
|
+
//# sourceMappingURL=index.mjs.map
|
|
5428
4275
|
//# sourceMappingURL=index.mjs.map
|