complete-common 1.0.0 → 1.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/LICENSE +1 -1
- package/README.md +3 -3
- package/dist/constants.d.cts +7 -0
- package/dist/constants.d.mts +7 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/functions/array.d.cts +83 -0
- package/dist/functions/array.d.mts +83 -0
- package/dist/functions/array.d.ts +83 -0
- package/dist/functions/array.d.ts.map +1 -0
- package/dist/functions/assert.d.cts +45 -0
- package/dist/functions/assert.d.mts +45 -0
- package/dist/functions/assert.d.ts +45 -0
- package/dist/functions/assert.d.ts.map +1 -0
- package/dist/functions/enums.d.cts +73 -0
- package/dist/functions/enums.d.mts +73 -0
- package/dist/functions/enums.d.ts +73 -0
- package/dist/functions/enums.d.ts.map +1 -0
- package/dist/functions/map.d.cts +24 -0
- package/dist/functions/map.d.mts +24 -0
- package/dist/functions/map.d.ts +24 -0
- package/dist/functions/map.d.ts.map +1 -0
- package/dist/functions/math.d.cts +13 -0
- package/dist/functions/math.d.mts +13 -0
- package/dist/functions/math.d.ts +13 -0
- package/dist/functions/math.d.ts.map +1 -0
- package/dist/functions/object.d.cts +60 -0
- package/dist/functions/object.d.mts +60 -0
- package/dist/functions/object.d.ts +60 -0
- package/dist/functions/object.d.ts.map +1 -0
- package/dist/functions/random.d.cts +23 -0
- package/dist/functions/random.d.mts +23 -0
- package/dist/functions/random.d.ts +23 -0
- package/dist/functions/random.d.ts.map +1 -0
- package/dist/functions/set.d.cts +61 -0
- package/dist/functions/set.d.mts +61 -0
- package/dist/functions/set.d.ts +61 -0
- package/dist/functions/set.d.ts.map +1 -0
- package/dist/functions/sort.d.cts +14 -0
- package/dist/functions/sort.d.mts +14 -0
- package/dist/functions/sort.d.ts +14 -0
- package/dist/functions/sort.d.ts.map +1 -0
- package/dist/functions/string.d.cts +122 -0
- package/dist/functions/string.d.mts +122 -0
- package/dist/functions/string.d.ts +122 -0
- package/dist/functions/string.d.ts.map +1 -0
- package/dist/functions/string.test.d.cts +2 -0
- package/dist/functions/string.test.d.mts +2 -0
- package/dist/functions/string.test.d.ts +2 -0
- package/dist/functions/string.test.d.ts.map +1 -0
- package/dist/functions/time.d.cts +20 -0
- package/dist/functions/time.d.mts +20 -0
- package/dist/functions/time.d.ts +20 -0
- package/dist/functions/time.d.ts.map +1 -0
- package/dist/functions/tuple.d.cts +27 -0
- package/dist/functions/tuple.d.mts +27 -0
- package/dist/functions/tuple.d.ts +27 -0
- package/dist/functions/tuple.d.ts.map +1 -0
- package/dist/functions/types.d.cts +13 -0
- package/dist/functions/types.d.mts +13 -0
- package/dist/functions/types.d.ts +13 -0
- package/dist/functions/types.d.ts.map +1 -0
- package/dist/functions/utils.d.cts +131 -0
- package/dist/functions/utils.d.mts +131 -0
- package/dist/functions/utils.d.ts +131 -0
- package/dist/functions/utils.d.ts.map +1 -0
- package/dist/functions/utils.test.d.cts +2 -0
- package/dist/functions/utils.test.d.mts +2 -0
- package/dist/functions/utils.test.d.ts +2 -0
- package/dist/functions/utils.test.d.ts.map +1 -0
- package/dist/index.cjs +122 -77
- package/dist/index.d.cts +30 -705
- package/dist/index.d.mts +30 -705
- package/dist/index.d.ts +30 -705
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +118 -78
- package/dist/types/AddSubtract.d.cts +23 -0
- package/dist/types/AddSubtract.d.mts +23 -0
- package/dist/types/AddSubtract.d.ts +23 -0
- package/dist/types/AddSubtract.d.ts.map +1 -0
- package/dist/types/CompositionTypeSatisfiesEnum.d.cts +35 -0
- package/dist/types/CompositionTypeSatisfiesEnum.d.mts +35 -0
- package/dist/types/CompositionTypeSatisfiesEnum.d.ts +35 -0
- package/dist/types/CompositionTypeSatisfiesEnum.d.ts.map +1 -0
- package/dist/types/ERange.d.cts +12 -0
- package/dist/types/ERange.d.mts +12 -0
- package/dist/types/ERange.d.ts +12 -0
- package/dist/types/ERange.d.ts.map +1 -0
- package/dist/types/IRange.d.cts +13 -0
- package/dist/types/IRange.d.mts +13 -0
- package/dist/types/IRange.d.ts +13 -0
- package/dist/types/IRange.d.ts.map +1 -0
- package/dist/types/Immutable.d.cts +17 -0
- package/dist/types/Immutable.d.mts +17 -0
- package/dist/types/Immutable.d.ts +17 -0
- package/dist/types/Immutable.d.ts.map +1 -0
- package/dist/types/NaturalNumbersLessThan.d.cts +8 -0
- package/dist/types/NaturalNumbersLessThan.d.mts +8 -0
- package/dist/types/NaturalNumbersLessThan.d.ts +8 -0
- package/dist/types/NaturalNumbersLessThan.d.ts.map +1 -0
- package/dist/types/NaturalNumbersLessThanOrEqualTo.d.cts +8 -0
- package/dist/types/NaturalNumbersLessThanOrEqualTo.d.mts +8 -0
- package/dist/types/NaturalNumbersLessThanOrEqualTo.d.ts +8 -0
- package/dist/types/NaturalNumbersLessThanOrEqualTo.d.ts.map +1 -0
- package/dist/types/ObjectValues.d.cts +3 -0
- package/dist/types/ObjectValues.d.mts +3 -0
- package/dist/types/ObjectValues.d.ts +3 -0
- package/dist/types/ObjectValues.d.ts.map +1 -0
- package/dist/types/ReadonlyMap.d.cts +9 -0
- package/dist/types/ReadonlyMap.d.mts +9 -0
- package/dist/types/ReadonlyMap.d.ts +9 -0
- package/dist/types/ReadonlyMap.d.ts.map +1 -0
- package/dist/types/ReadonlyRecord.d.cts +7 -0
- package/dist/types/ReadonlyRecord.d.mts +7 -0
- package/dist/types/ReadonlyRecord.d.ts +7 -0
- package/dist/types/ReadonlyRecord.d.ts.map +1 -0
- package/dist/types/ReadonlySet.d.cts +8 -0
- package/dist/types/ReadonlySet.d.mts +8 -0
- package/dist/types/ReadonlySet.d.ts +8 -0
- package/dist/types/ReadonlySet.d.ts.map +1 -0
- package/dist/types/Tuple.d.cts +10 -0
- package/dist/types/Tuple.d.mts +10 -0
- package/dist/types/Tuple.d.ts +10 -0
- package/dist/types/Tuple.d.ts.map +1 -0
- package/dist/types/WidenLiteral.d.cts +3 -0
- package/dist/types/WidenLiteral.d.mts +3 -0
- package/dist/types/WidenLiteral.d.ts +3 -0
- package/dist/types/WidenLiteral.d.ts.map +1 -0
- package/dist/types/Writeable.d.cts +9 -0
- package/dist/types/Writeable.d.mts +9 -0
- package/dist/types/Writeable.d.ts +9 -0
- package/dist/types/Writeable.d.ts.map +1 -0
- package/package.json +13 -2
- package/src/constants.ts +5 -0
- package/src/functions/array.ts +8 -2
- package/src/functions/assert.ts +86 -0
- package/src/functions/enums.ts +6 -0
- package/src/functions/map.ts +7 -45
- package/src/functions/math.ts +6 -0
- package/src/functions/object.ts +90 -3
- package/src/functions/random.ts +6 -0
- package/src/functions/set.ts +7 -0
- package/src/functions/sort.ts +6 -0
- package/src/functions/string.ts +25 -0
- package/src/functions/time.ts +26 -0
- package/src/functions/tuple.ts +6 -0
- package/src/functions/types.ts +6 -0
- package/src/functions/utils.test.ts +2 -8
- package/src/functions/utils.ts +7 -37
- package/src/index.ts +14 -12
- package/src/types/AddSubtract.ts +10 -2
- package/src/types/CompositionTypeSatisfiesEnum.ts +5 -3
- package/src/types/ObjectValues.ts +1 -0
- package/src/types/ReadonlyRecord.ts +5 -0
- package/src/types/Tuple.ts +1 -0
- package/src/types/WidenLiteral.ts +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,yCAAyC,CAAC;AAC7D,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,4CAA4C,CAAC;AAChE,mBAAmB,yBAAyB,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,2BAA2B,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,sBAAsB,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -4,25 +4,21 @@ const HOUR_IN_MILLISECONDS = 60 * MINUTE_IN_MILLISECONDS;
|
|
|
4
4
|
|
|
5
5
|
const ReadonlySet = Set;
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
max = Math.floor(max);
|
|
10
|
-
if (min > max) {
|
|
11
|
-
const oldMin = min;
|
|
12
|
-
const oldMax = max;
|
|
13
|
-
min = oldMax;
|
|
14
|
-
max = oldMin;
|
|
15
|
-
}
|
|
16
|
-
const exceptionsSet = new ReadonlySet(exceptions);
|
|
17
|
-
let randomInt;
|
|
18
|
-
do {
|
|
19
|
-
randomInt = Math.floor(Math.random() * (max - min + 1)) + min;
|
|
20
|
-
} while (exceptionsSet.has(randomInt));
|
|
21
|
-
return randomInt;
|
|
7
|
+
function isObject(variable) {
|
|
8
|
+
return typeof variable === "object" && variable !== null && !Array.isArray(variable);
|
|
22
9
|
}
|
|
23
10
|
|
|
24
|
-
const
|
|
25
|
-
|
|
11
|
+
const TYPES_TO_VALIDATION_FUNCTIONS = {
|
|
12
|
+
string: (val) => typeof val === "string",
|
|
13
|
+
number: (val) => typeof val === "number",
|
|
14
|
+
boolean: (val) => typeof val === "boolean",
|
|
15
|
+
object: (val) => val !== null && typeof val === "object",
|
|
16
|
+
array: (val) => Array.isArray(val),
|
|
17
|
+
null: (val) => val === null,
|
|
18
|
+
undefined: (val) => val === void 0,
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
20
|
+
function: (val) => typeof val === "function"
|
|
21
|
+
};
|
|
26
22
|
function assertDefined(value, ...[msg]) {
|
|
27
23
|
if (value === void 0) {
|
|
28
24
|
throw new TypeError(msg);
|
|
@@ -33,56 +29,33 @@ function assertNotNull(value, ...[msg]) {
|
|
|
33
29
|
throw new TypeError(msg);
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
|
-
function
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
for (let i = start; i < end; i += increment) {
|
|
42
|
-
yield i;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function* iRange(start, end, increment = 1) {
|
|
46
|
-
if (end === void 0) {
|
|
47
|
-
yield* iRange(0, start, increment);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const exclusiveEnd = end + 1;
|
|
51
|
-
yield* eRange(start, exclusiveEnd, increment);
|
|
52
|
-
}
|
|
53
|
-
function isKeyOf(key, target) {
|
|
54
|
-
return key in target;
|
|
55
|
-
}
|
|
56
|
-
function noop() {
|
|
57
|
-
}
|
|
58
|
-
function parseFloatSafe(string) {
|
|
59
|
-
if (typeof string !== "string") {
|
|
60
|
-
return void 0;
|
|
61
|
-
}
|
|
62
|
-
const trimmedString = string.trim();
|
|
63
|
-
if (FLOAT_REGEX.exec(trimmedString) === null) {
|
|
64
|
-
return void 0;
|
|
32
|
+
function assertObject(value, msg) {
|
|
33
|
+
if (!isObject(value)) {
|
|
34
|
+
throw new TypeError(msg);
|
|
65
35
|
}
|
|
66
|
-
const number = Number.parseFloat(trimmedString);
|
|
67
|
-
return Number.isNaN(number) ? void 0 : number;
|
|
68
36
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const trimmedString = string.trim();
|
|
74
|
-
if (INTEGER_REGEX.exec(trimmedString) === null) {
|
|
75
|
-
return void 0;
|
|
37
|
+
function assertType(value, type, msg) {
|
|
38
|
+
const validationFunction = TYPES_TO_VALIDATION_FUNCTIONS[type];
|
|
39
|
+
if (!validationFunction(value)) {
|
|
40
|
+
throw new TypeError(msg);
|
|
76
41
|
}
|
|
77
|
-
const number = Number.parseInt(trimmedString, 10);
|
|
78
|
-
return Number.isNaN(number) ? void 0 : number;
|
|
79
42
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
43
|
+
|
|
44
|
+
function getRandomInt(min, max, exceptions = []) {
|
|
45
|
+
min = Math.ceil(min);
|
|
46
|
+
max = Math.floor(max);
|
|
47
|
+
if (min > max) {
|
|
48
|
+
const oldMin = min;
|
|
49
|
+
const oldMax = max;
|
|
50
|
+
min = oldMax;
|
|
51
|
+
max = oldMin;
|
|
83
52
|
}
|
|
84
|
-
|
|
85
|
-
|
|
53
|
+
const exceptionsSet = new ReadonlySet(exceptions);
|
|
54
|
+
let randomInt;
|
|
55
|
+
do {
|
|
56
|
+
randomInt = Math.floor(Math.random() * (max - min + 1)) + min;
|
|
57
|
+
} while (exceptionsSet.has(randomInt));
|
|
58
|
+
return randomInt;
|
|
86
59
|
}
|
|
87
60
|
|
|
88
61
|
function arrayCopyTwoDimensional(array) {
|
|
@@ -115,7 +88,7 @@ function arrayRemoveInPlace(array, ...elementsToRemove) {
|
|
|
115
88
|
const removedElements = [];
|
|
116
89
|
for (const element of elementsToRemove) {
|
|
117
90
|
const index = array.indexOf(element);
|
|
118
|
-
if (index
|
|
91
|
+
if (index !== -1) {
|
|
119
92
|
const removedElement = array.splice(index, 1);
|
|
120
93
|
removedElements.push(...removedElement);
|
|
121
94
|
}
|
|
@@ -217,16 +190,6 @@ function mapFind(map, predicate) {
|
|
|
217
190
|
}
|
|
218
191
|
return void 0;
|
|
219
192
|
}
|
|
220
|
-
function objectToMap(object) {
|
|
221
|
-
const map = /* @__PURE__ */ new Map();
|
|
222
|
-
for (const [key, value] of Object.entries(object)) {
|
|
223
|
-
map.set(key, value);
|
|
224
|
-
}
|
|
225
|
-
return map;
|
|
226
|
-
}
|
|
227
|
-
function objectToReadonlyMap(object) {
|
|
228
|
-
return objectToMap(object);
|
|
229
|
-
}
|
|
230
193
|
|
|
231
194
|
function clamp(num, min, max) {
|
|
232
195
|
return Math.max(min, Math.min(num, max));
|
|
@@ -243,6 +206,26 @@ function objectFilter(object, predicate) {
|
|
|
243
206
|
}
|
|
244
207
|
return array;
|
|
245
208
|
}
|
|
209
|
+
function objectToMap(object) {
|
|
210
|
+
const map = /* @__PURE__ */ new Map();
|
|
211
|
+
for (const [key, value] of Object.entries(object)) {
|
|
212
|
+
map.set(key, value);
|
|
213
|
+
}
|
|
214
|
+
return map;
|
|
215
|
+
}
|
|
216
|
+
function objectToReadonlyMap(object) {
|
|
217
|
+
return objectToMap(object);
|
|
218
|
+
}
|
|
219
|
+
function objectToReverseMap(object) {
|
|
220
|
+
const map = /* @__PURE__ */ new Map();
|
|
221
|
+
for (const [key, value] of Object.entries(object)) {
|
|
222
|
+
map.set(value, key);
|
|
223
|
+
}
|
|
224
|
+
return map;
|
|
225
|
+
}
|
|
226
|
+
function objectToReverseReadonlyMap(object) {
|
|
227
|
+
return objectToReverseMap(object);
|
|
228
|
+
}
|
|
246
229
|
|
|
247
230
|
function addSetsToSet(mainSet, ...setsToAdd) {
|
|
248
231
|
for (const set of setsToAdd) {
|
|
@@ -306,6 +289,60 @@ function sortCaseInsensitive(array) {
|
|
|
306
289
|
return newArray;
|
|
307
290
|
}
|
|
308
291
|
|
|
292
|
+
const FLOAT_REGEX = /^-?\d*\.?\d+$/;
|
|
293
|
+
const INTEGER_REGEX = /^-?\d+$/;
|
|
294
|
+
function* eRange(start, end, increment = 1) {
|
|
295
|
+
if (end === void 0) {
|
|
296
|
+
yield* eRange(0, start, increment);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
for (let i = start; i < end; i += increment) {
|
|
300
|
+
yield i;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function* iRange(start, end, increment = 1) {
|
|
304
|
+
if (end === void 0) {
|
|
305
|
+
yield* iRange(0, start, increment);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const exclusiveEnd = end + 1;
|
|
309
|
+
yield* eRange(start, exclusiveEnd, increment);
|
|
310
|
+
}
|
|
311
|
+
function isKeyOf(key, target) {
|
|
312
|
+
return key in target;
|
|
313
|
+
}
|
|
314
|
+
function noop() {
|
|
315
|
+
}
|
|
316
|
+
function parseFloatSafe(string) {
|
|
317
|
+
if (typeof string !== "string") {
|
|
318
|
+
return void 0;
|
|
319
|
+
}
|
|
320
|
+
const trimmedString = string.trim();
|
|
321
|
+
if (FLOAT_REGEX.exec(trimmedString) === null) {
|
|
322
|
+
return void 0;
|
|
323
|
+
}
|
|
324
|
+
const number = Number.parseFloat(trimmedString);
|
|
325
|
+
return Number.isNaN(number) ? void 0 : number;
|
|
326
|
+
}
|
|
327
|
+
function parseIntSafe(string) {
|
|
328
|
+
if (typeof string !== "string") {
|
|
329
|
+
return void 0;
|
|
330
|
+
}
|
|
331
|
+
const trimmedString = string.trim();
|
|
332
|
+
if (INTEGER_REGEX.exec(trimmedString) === null) {
|
|
333
|
+
return void 0;
|
|
334
|
+
}
|
|
335
|
+
const number = Number.parseInt(trimmedString, 10);
|
|
336
|
+
return Number.isNaN(number) ? void 0 : number;
|
|
337
|
+
}
|
|
338
|
+
function repeat(num, func) {
|
|
339
|
+
for (let i = 0; i < num; i++) {
|
|
340
|
+
func(i);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function todo(...args) {
|
|
344
|
+
}
|
|
345
|
+
|
|
309
346
|
const DIACRITIC_REGEX = /\p{Diacritic}/u;
|
|
310
347
|
const EMOJI_REGEX = /(\p{Extended_Pictographic}|\p{Emoji_Component})/u;
|
|
311
348
|
const FIRST_LETTER_CAPITALIZED_REGEX = /^\p{Lu}/u;
|
|
@@ -447,6 +484,13 @@ function truncateString(string, maxLength) {
|
|
|
447
484
|
return string.slice(0, maxLength);
|
|
448
485
|
}
|
|
449
486
|
|
|
487
|
+
function getElapsedSeconds(startTime) {
|
|
488
|
+
const endTime = Date.now();
|
|
489
|
+
const elapsedMilliseconds = endTime - startTime;
|
|
490
|
+
const elapsedSeconds = elapsedMilliseconds / 1e3;
|
|
491
|
+
return Math.floor(elapsedSeconds);
|
|
492
|
+
}
|
|
493
|
+
|
|
450
494
|
function* tupleEntries(tuple) {
|
|
451
495
|
yield* tuple.entries();
|
|
452
496
|
}
|
|
@@ -454,10 +498,6 @@ function* tupleKeys(tuple) {
|
|
|
454
498
|
yield* tuple.keys();
|
|
455
499
|
}
|
|
456
500
|
|
|
457
|
-
function isObject(variable) {
|
|
458
|
-
return typeof variable === "object" && variable !== null && !Array.isArray(variable);
|
|
459
|
-
}
|
|
460
|
-
|
|
461
501
|
const ReadonlyMap = Map;
|
|
462
502
|
|
|
463
|
-
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveInPlace, assertDefined, assertNotNull, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterMap, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, interfaceSatisfiesEnum, isArray, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isObject, isSemanticVersion, kebabCaseToCamelCase, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter, objectKeysToReadonlySet, objectKeysToSet, objectToMap, objectToReadonlyMap, objectValuesToReadonlySet, objectValuesToSet, parseFloatSafe, parseIntSafe, parseSemanticVersion, removeLinesBetweenMarkers, removeLinesMatching, removeNonPrintableCharacters, removeWhitespace, repeat, setAdd, setHas, sortCaseInsensitive, sumArray, todo, trimPrefix, trimSuffix, truncateString, tupleEntries, tupleKeys };
|
|
503
|
+
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveInPlace, assertDefined, assertNotNull, assertObject, assertType, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterMap, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, interfaceSatisfiesEnum, isArray, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isObject, isSemanticVersion, kebabCaseToCamelCase, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter, objectKeysToReadonlySet, objectKeysToSet, objectToMap, objectToReadonlyMap, objectToReverseMap, objectToReverseReadonlyMap, objectValuesToReadonlySet, objectValuesToSet, parseFloatSafe, parseIntSafe, parseSemanticVersion, removeLinesBetweenMarkers, removeLinesMatching, removeNonPrintableCharacters, removeWhitespace, repeat, setAdd, setHas, sortCaseInsensitive, sumArray, todo, trimPrefix, trimSuffix, truncateString, tupleEntries, tupleKeys };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to add two other types.
|
|
3
|
+
*
|
|
4
|
+
* From: https://gist.github.com/ryandabler/8b4ff4f36aed47bc09acc03174638468
|
|
5
|
+
*/
|
|
6
|
+
export type Add<A extends number, B extends number> = Length<[
|
|
7
|
+
...BuildTuple<A>,
|
|
8
|
+
...BuildTuple<B>
|
|
9
|
+
]>;
|
|
10
|
+
/**
|
|
11
|
+
* Helper type to subtract two other types.
|
|
12
|
+
*
|
|
13
|
+
* From: https://gist.github.com/ryandabler/8b4ff4f36aed47bc09acc03174638468
|
|
14
|
+
*/
|
|
15
|
+
export type Subtract<A extends number, B extends number> = A extends A ? BuildTuple<A> extends [...infer U, ...BuildTuple<B>] ? Length<U> : never : never;
|
|
16
|
+
type BuildTuple<L extends number, T extends unknown[] = []> = T extends {
|
|
17
|
+
length: L;
|
|
18
|
+
} ? T : BuildTuple<L, [...T, unknown]>;
|
|
19
|
+
type Length<T extends unknown[]> = T extends {
|
|
20
|
+
length: infer L;
|
|
21
|
+
} ? L : never;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=AddSubtract.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to add two other types.
|
|
3
|
+
*
|
|
4
|
+
* From: https://gist.github.com/ryandabler/8b4ff4f36aed47bc09acc03174638468
|
|
5
|
+
*/
|
|
6
|
+
export type Add<A extends number, B extends number> = Length<[
|
|
7
|
+
...BuildTuple<A>,
|
|
8
|
+
...BuildTuple<B>
|
|
9
|
+
]>;
|
|
10
|
+
/**
|
|
11
|
+
* Helper type to subtract two other types.
|
|
12
|
+
*
|
|
13
|
+
* From: https://gist.github.com/ryandabler/8b4ff4f36aed47bc09acc03174638468
|
|
14
|
+
*/
|
|
15
|
+
export type Subtract<A extends number, B extends number> = A extends A ? BuildTuple<A> extends [...infer U, ...BuildTuple<B>] ? Length<U> : never : never;
|
|
16
|
+
type BuildTuple<L extends number, T extends unknown[] = []> = T extends {
|
|
17
|
+
length: L;
|
|
18
|
+
} ? T : BuildTuple<L, [...T, unknown]>;
|
|
19
|
+
type Length<T extends unknown[]> = T extends {
|
|
20
|
+
length: infer L;
|
|
21
|
+
} ? L : never;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=AddSubtract.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to add two other types.
|
|
3
|
+
*
|
|
4
|
+
* From: https://gist.github.com/ryandabler/8b4ff4f36aed47bc09acc03174638468
|
|
5
|
+
*/
|
|
6
|
+
export type Add<A extends number, B extends number> = Length<[
|
|
7
|
+
...BuildTuple<A>,
|
|
8
|
+
...BuildTuple<B>
|
|
9
|
+
]>;
|
|
10
|
+
/**
|
|
11
|
+
* Helper type to subtract two other types.
|
|
12
|
+
*
|
|
13
|
+
* From: https://gist.github.com/ryandabler/8b4ff4f36aed47bc09acc03174638468
|
|
14
|
+
*/
|
|
15
|
+
export type Subtract<A extends number, B extends number> = A extends A ? BuildTuple<A> extends [...infer U, ...BuildTuple<B>] ? Length<U> : never : never;
|
|
16
|
+
type BuildTuple<L extends number, T extends unknown[] = []> = T extends {
|
|
17
|
+
length: L;
|
|
18
|
+
} ? T : BuildTuple<L, [...T, unknown]>;
|
|
19
|
+
type Length<T extends unknown[]> = T extends {
|
|
20
|
+
length: infer L;
|
|
21
|
+
} ? L : never;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=AddSubtract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddSubtract.d.ts","sourceRoot":"","sources":["../../src/types/AddSubtract.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,MAAM,CAC1D;IAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAAE,GAAG,UAAU,CAAC,CAAC,CAAC;CAAC,CACrC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,GAClE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,GAClD,MAAM,CAAC,CAAC,CAAC,GACT,KAAK,GACP,KAAK,CAAC;AAEV,KAAK,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS;IACtE,MAAM,EAAE,CAAC,CAAC;CACX,GACG,CAAC,GACD,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAEnC,KAAK,MAAM,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to validate that a union of interfaces with a field of `type` that is based on an
|
|
3
|
+
* enum is complete.
|
|
4
|
+
*
|
|
5
|
+
* For example:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* enum ObjectiveType {
|
|
9
|
+
* Foo,
|
|
10
|
+
* Bar,
|
|
11
|
+
* Baz,
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* interface FooObjective {
|
|
15
|
+
* type: ObjectiveType.Foo;
|
|
16
|
+
* fooThing: number;
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* interface BarObjective {
|
|
20
|
+
* type: ObjectiveType.Bar;
|
|
21
|
+
* barThing: string;
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* type Objective = FooObjective | BarObjective;
|
|
25
|
+
* type _Test = CompositionTypeSatisfiesEnum<Objective, ObjectiveType>;
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* In this example, `Test` would be flagged by TypeScript because `Objective` does not contain an
|
|
29
|
+
* entry for `BazObjective`.
|
|
30
|
+
*/
|
|
31
|
+
export type CompositionTypeSatisfiesEnum<T extends {
|
|
32
|
+
/** The type of the discriminated union. */
|
|
33
|
+
type: unknown;
|
|
34
|
+
}, _Enum extends T["type"]> = unknown;
|
|
35
|
+
//# sourceMappingURL=CompositionTypeSatisfiesEnum.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to validate that a union of interfaces with a field of `type` that is based on an
|
|
3
|
+
* enum is complete.
|
|
4
|
+
*
|
|
5
|
+
* For example:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* enum ObjectiveType {
|
|
9
|
+
* Foo,
|
|
10
|
+
* Bar,
|
|
11
|
+
* Baz,
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* interface FooObjective {
|
|
15
|
+
* type: ObjectiveType.Foo;
|
|
16
|
+
* fooThing: number;
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* interface BarObjective {
|
|
20
|
+
* type: ObjectiveType.Bar;
|
|
21
|
+
* barThing: string;
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* type Objective = FooObjective | BarObjective;
|
|
25
|
+
* type _Test = CompositionTypeSatisfiesEnum<Objective, ObjectiveType>;
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* In this example, `Test` would be flagged by TypeScript because `Objective` does not contain an
|
|
29
|
+
* entry for `BazObjective`.
|
|
30
|
+
*/
|
|
31
|
+
export type CompositionTypeSatisfiesEnum<T extends {
|
|
32
|
+
/** The type of the discriminated union. */
|
|
33
|
+
type: unknown;
|
|
34
|
+
}, _Enum extends T["type"]> = unknown;
|
|
35
|
+
//# sourceMappingURL=CompositionTypeSatisfiesEnum.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to validate that a union of interfaces with a field of `type` that is based on an
|
|
3
|
+
* enum is complete.
|
|
4
|
+
*
|
|
5
|
+
* For example:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* enum ObjectiveType {
|
|
9
|
+
* Foo,
|
|
10
|
+
* Bar,
|
|
11
|
+
* Baz,
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* interface FooObjective {
|
|
15
|
+
* type: ObjectiveType.Foo;
|
|
16
|
+
* fooThing: number;
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* interface BarObjective {
|
|
20
|
+
* type: ObjectiveType.Bar;
|
|
21
|
+
* barThing: string;
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* type Objective = FooObjective | BarObjective;
|
|
25
|
+
* type _Test = CompositionTypeSatisfiesEnum<Objective, ObjectiveType>;
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* In this example, `Test` would be flagged by TypeScript because `Objective` does not contain an
|
|
29
|
+
* entry for `BazObjective`.
|
|
30
|
+
*/
|
|
31
|
+
export type CompositionTypeSatisfiesEnum<T extends {
|
|
32
|
+
/** The type of the discriminated union. */
|
|
33
|
+
type: unknown;
|
|
34
|
+
}, _Enum extends T["type"]> = unknown;
|
|
35
|
+
//# sourceMappingURL=CompositionTypeSatisfiesEnum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompositionTypeSatisfiesEnum.d.ts","sourceRoot":"","sources":["../../src/types/CompositionTypeSatisfiesEnum.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,MAAM,4BAA4B,CACtC,CAAC,SAAS;IACR,2CAA2C;IAC3C,IAAI,EAAE,OAAO,CAAC;CACf,EACD,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,IACrB,OAAO,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NaturalNumbersLessThan } from "./NaturalNumbersLessThan.js";
|
|
2
|
+
/**
|
|
3
|
+
* Helper type to get a range of integers. It is inclusive on the lower end and exclusive on the
|
|
4
|
+
* high end. (The "E" in the type name stands for exclusive.)
|
|
5
|
+
*
|
|
6
|
+
* For example, `ERange<3, 5>` will return `3 | 4`.
|
|
7
|
+
*
|
|
8
|
+
* From:
|
|
9
|
+
* https://stackoverflow.com/questions/39494689/is-it-possible-to-restrict-number-to-a-certain-range
|
|
10
|
+
*/
|
|
11
|
+
export type ERange<Low extends number, High extends number> = Exclude<NaturalNumbersLessThan<High>, NaturalNumbersLessThan<Low>>;
|
|
12
|
+
//# sourceMappingURL=ERange.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NaturalNumbersLessThan } from "./NaturalNumbersLessThan.js";
|
|
2
|
+
/**
|
|
3
|
+
* Helper type to get a range of integers. It is inclusive on the lower end and exclusive on the
|
|
4
|
+
* high end. (The "E" in the type name stands for exclusive.)
|
|
5
|
+
*
|
|
6
|
+
* For example, `ERange<3, 5>` will return `3 | 4`.
|
|
7
|
+
*
|
|
8
|
+
* From:
|
|
9
|
+
* https://stackoverflow.com/questions/39494689/is-it-possible-to-restrict-number-to-a-certain-range
|
|
10
|
+
*/
|
|
11
|
+
export type ERange<Low extends number, High extends number> = Exclude<NaturalNumbersLessThan<High>, NaturalNumbersLessThan<Low>>;
|
|
12
|
+
//# sourceMappingURL=ERange.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NaturalNumbersLessThan } from "./NaturalNumbersLessThan.js";
|
|
2
|
+
/**
|
|
3
|
+
* Helper type to get a range of integers. It is inclusive on the lower end and exclusive on the
|
|
4
|
+
* high end. (The "E" in the type name stands for exclusive.)
|
|
5
|
+
*
|
|
6
|
+
* For example, `ERange<3, 5>` will return `3 | 4`.
|
|
7
|
+
*
|
|
8
|
+
* From:
|
|
9
|
+
* https://stackoverflow.com/questions/39494689/is-it-possible-to-restrict-number-to-a-certain-range
|
|
10
|
+
*/
|
|
11
|
+
export type ERange<Low extends number, High extends number> = Exclude<NaturalNumbersLessThan<High>, NaturalNumbersLessThan<Low>>;
|
|
12
|
+
//# sourceMappingURL=ERange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ERange.d.ts","sourceRoot":"","sources":["../../src/types/ERange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E;;;;;;;;GAQG;AACH,MAAM,MAAM,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,IAAI,OAAO,CACnE,sBAAsB,CAAC,IAAI,CAAC,EAC5B,sBAAsB,CAAC,GAAG,CAAC,CAC5B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NaturalNumbersLessThan } from "./NaturalNumbersLessThan.js";
|
|
2
|
+
import type { NaturalNumbersLessThanOrEqualTo } from "./NaturalNumbersLessThanOrEqualTo.js";
|
|
3
|
+
/**
|
|
4
|
+
* Helper type to get a range of integers. It is inclusive on both ends. (The "I" in the type name
|
|
5
|
+
* stands for inclusive.)
|
|
6
|
+
*
|
|
7
|
+
* For example, `IRange<3, 5>` will return `3 | 4 | 5`.
|
|
8
|
+
*
|
|
9
|
+
* From:
|
|
10
|
+
* https://stackoverflow.com/questions/39494689/is-it-possible-to-restrict-number-to-a-certain-range
|
|
11
|
+
*/
|
|
12
|
+
export type IRange<Low extends number, High extends number> = Exclude<NaturalNumbersLessThanOrEqualTo<High>, NaturalNumbersLessThan<Low>>;
|
|
13
|
+
//# sourceMappingURL=IRange.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NaturalNumbersLessThan } from "./NaturalNumbersLessThan.js";
|
|
2
|
+
import type { NaturalNumbersLessThanOrEqualTo } from "./NaturalNumbersLessThanOrEqualTo.js";
|
|
3
|
+
/**
|
|
4
|
+
* Helper type to get a range of integers. It is inclusive on both ends. (The "I" in the type name
|
|
5
|
+
* stands for inclusive.)
|
|
6
|
+
*
|
|
7
|
+
* For example, `IRange<3, 5>` will return `3 | 4 | 5`.
|
|
8
|
+
*
|
|
9
|
+
* From:
|
|
10
|
+
* https://stackoverflow.com/questions/39494689/is-it-possible-to-restrict-number-to-a-certain-range
|
|
11
|
+
*/
|
|
12
|
+
export type IRange<Low extends number, High extends number> = Exclude<NaturalNumbersLessThanOrEqualTo<High>, NaturalNumbersLessThan<Low>>;
|
|
13
|
+
//# sourceMappingURL=IRange.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NaturalNumbersLessThan } from "./NaturalNumbersLessThan.js";
|
|
2
|
+
import type { NaturalNumbersLessThanOrEqualTo } from "./NaturalNumbersLessThanOrEqualTo.js";
|
|
3
|
+
/**
|
|
4
|
+
* Helper type to get a range of integers. It is inclusive on both ends. (The "I" in the type name
|
|
5
|
+
* stands for inclusive.)
|
|
6
|
+
*
|
|
7
|
+
* For example, `IRange<3, 5>` will return `3 | 4 | 5`.
|
|
8
|
+
*
|
|
9
|
+
* From:
|
|
10
|
+
* https://stackoverflow.com/questions/39494689/is-it-possible-to-restrict-number-to-a-certain-range
|
|
11
|
+
*/
|
|
12
|
+
export type IRange<Low extends number, High extends number> = Exclude<NaturalNumbersLessThanOrEqualTo<High>, NaturalNumbersLessThan<Low>>;
|
|
13
|
+
//# sourceMappingURL=IRange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRange.d.ts","sourceRoot":"","sources":["../../src/types/IRange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAE5F;;;;;;;;GAQG;AACH,MAAM,MAAM,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,IAAI,OAAO,CACnE,+BAA+B,CAAC,IAAI,CAAC,EACrC,sBAAsB,CAAC,GAAG,CAAC,CAC5B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Immutable is a utility type that will make the given array/map/set/object recursively read-only.
|
|
3
|
+
*
|
|
4
|
+
* You can use this type to easily build safe data structures.
|
|
5
|
+
*
|
|
6
|
+
* From: https://stackoverflow.com/questions/41879327/deepreadonly-object-typescript
|
|
7
|
+
*/
|
|
8
|
+
export type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
|
|
9
|
+
type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
|
|
10
|
+
type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
|
|
11
|
+
type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
12
|
+
type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
13
|
+
type ImmutableObject<T> = {
|
|
14
|
+
readonly [K in keyof T]: Immutable<T[K]>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=Immutable.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Immutable is a utility type that will make the given array/map/set/object recursively read-only.
|
|
3
|
+
*
|
|
4
|
+
* You can use this type to easily build safe data structures.
|
|
5
|
+
*
|
|
6
|
+
* From: https://stackoverflow.com/questions/41879327/deepreadonly-object-typescript
|
|
7
|
+
*/
|
|
8
|
+
export type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
|
|
9
|
+
type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
|
|
10
|
+
type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
|
|
11
|
+
type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
12
|
+
type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
13
|
+
type ImmutableObject<T> = {
|
|
14
|
+
readonly [K in keyof T]: Immutable<T[K]>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=Immutable.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Immutable is a utility type that will make the given array/map/set/object recursively read-only.
|
|
3
|
+
*
|
|
4
|
+
* You can use this type to easily build safe data structures.
|
|
5
|
+
*
|
|
6
|
+
* From: https://stackoverflow.com/questions/41879327/deepreadonly-object-typescript
|
|
7
|
+
*/
|
|
8
|
+
export type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
|
|
9
|
+
type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
|
|
10
|
+
type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
|
|
11
|
+
type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
12
|
+
type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
13
|
+
type ImmutableObject<T> = {
|
|
14
|
+
readonly [K in keyof T]: Immutable<T[K]>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=Immutable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Immutable.d.ts","sourceRoot":"","sources":["../../src/types/Immutable.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,kBAAkB,GACnD,CAAC,GACD,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACtB,cAAc,CAAC,CAAC,CAAC,GACjB,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC7B,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAClB,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,GACpB,YAAY,CAAC,CAAC,CAAC,GACf,eAAe,CAAC,CAAC,CAAC,CAAC;AAE7B,KAAK,kBAAkB,GACnB,SAAS,GACT,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,QAAQ,CAAC;AACb,KAAK,cAAc,CAAC,CAAC,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,KAAK,YAAY,CAAC,CAAC,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,KAAK,eAAe,CAAC,CAAC,IAAI;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to get a range of integers between 0 and N - 1.
|
|
3
|
+
*
|
|
4
|
+
* From:
|
|
5
|
+
* https://stackoverflow.com/questions/39494689/is-it-possible-to-restrict-number-to-a-certain-range
|
|
6
|
+
*/
|
|
7
|
+
export type NaturalNumbersLessThan<N extends number, Acc extends number[] = []> = Acc["length"] extends N ? Acc[number] : NaturalNumbersLessThan<N, [...Acc, Acc["length"]]>;
|
|
8
|
+
//# sourceMappingURL=NaturalNumbersLessThan.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to get a range of integers between 0 and N - 1.
|
|
3
|
+
*
|
|
4
|
+
* From:
|
|
5
|
+
* https://stackoverflow.com/questions/39494689/is-it-possible-to-restrict-number-to-a-certain-range
|
|
6
|
+
*/
|
|
7
|
+
export type NaturalNumbersLessThan<N extends number, Acc extends number[] = []> = Acc["length"] extends N ? Acc[number] : NaturalNumbersLessThan<N, [...Acc, Acc["length"]]>;
|
|
8
|
+
//# sourceMappingURL=NaturalNumbersLessThan.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to get a range of integers between 0 and N - 1.
|
|
3
|
+
*
|
|
4
|
+
* From:
|
|
5
|
+
* https://stackoverflow.com/questions/39494689/is-it-possible-to-restrict-number-to-a-certain-range
|
|
6
|
+
*/
|
|
7
|
+
export type NaturalNumbersLessThan<N extends number, Acc extends number[] = []> = Acc["length"] extends N ? Acc[number] : NaturalNumbersLessThan<N, [...Acc, Acc["length"]]>;
|
|
8
|
+
//# sourceMappingURL=NaturalNumbersLessThan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NaturalNumbersLessThan.d.ts","sourceRoot":"","sources":["../../src/types/NaturalNumbersLessThan.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,CAChC,CAAC,SAAS,MAAM,EAChB,GAAG,SAAS,MAAM,EAAE,GAAG,EAAE,IACvB,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,GACvB,GAAG,CAAC,MAAM,CAAC,GACX,sBAAsB,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to get a range of integers between 0 and N.
|
|
3
|
+
*
|
|
4
|
+
* From:
|
|
5
|
+
* https://stackoverflow.com/questions/39494689/is-it-possible-to-restrict-number-to-a-certain-range
|
|
6
|
+
*/
|
|
7
|
+
export type NaturalNumbersLessThanOrEqualTo<N extends number, T extends number[] = []> = T extends [unknown, ...infer Tail] ? Tail["length"] extends N ? T[number] : NaturalNumbersLessThanOrEqualTo<N, [...T, T["length"]]> : NaturalNumbersLessThanOrEqualTo<N, [...T, T["length"]]>;
|
|
8
|
+
//# sourceMappingURL=NaturalNumbersLessThanOrEqualTo.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to get a range of integers between 0 and N.
|
|
3
|
+
*
|
|
4
|
+
* From:
|
|
5
|
+
* https://stackoverflow.com/questions/39494689/is-it-possible-to-restrict-number-to-a-certain-range
|
|
6
|
+
*/
|
|
7
|
+
export type NaturalNumbersLessThanOrEqualTo<N extends number, T extends number[] = []> = T extends [unknown, ...infer Tail] ? Tail["length"] extends N ? T[number] : NaturalNumbersLessThanOrEqualTo<N, [...T, T["length"]]> : NaturalNumbersLessThanOrEqualTo<N, [...T, T["length"]]>;
|
|
8
|
+
//# sourceMappingURL=NaturalNumbersLessThanOrEqualTo.d.ts.map
|