complete-common 2.4.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/functions/array.d.cts +17 -3
- package/dist/functions/array.d.mts +17 -3
- package/dist/functions/array.d.ts +17 -3
- package/dist/functions/array.d.ts.map +1 -1
- package/dist/functions/assert.d.cts +6 -0
- package/dist/functions/assert.d.mts +6 -0
- package/dist/functions/assert.d.ts +6 -0
- package/dist/functions/assert.d.ts.map +1 -1
- package/dist/functions/string.d.ts.map +1 -1
- package/dist/index.cjs +23 -2
- package/dist/index.mjs +22 -3
- package/package.json +8 -13
- package/src/functions/array.ts +38 -4
- package/src/functions/assert.ts +17 -0
- package/src/functions/string.test.ts +1 -1
- package/src/functions/string.ts +2 -0
- package/src/functions/utils.test.ts +3 -3
|
@@ -19,9 +19,24 @@ export declare function arrayEquals<T>(array1: readonly T[], array2: readonly T[
|
|
|
19
19
|
* array. If the specified element(s) are not found in the array, it will simply return a shallow
|
|
20
20
|
* copy of the array.
|
|
21
21
|
*
|
|
22
|
+
* If there is more than one matching element in the array, this function will remove all of them.
|
|
23
|
+
*
|
|
22
24
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
23
25
|
*/
|
|
24
26
|
export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): readonly T[];
|
|
27
|
+
/**
|
|
28
|
+
* Removes all of the specified element(s) from the array. If the specified element(s) are not found
|
|
29
|
+
* in the array, this function will do nothing.
|
|
30
|
+
*
|
|
31
|
+
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
32
|
+
*
|
|
33
|
+
* If there is more than one matching element in the array, this function will remove every matching
|
|
34
|
+
* element. If you want to only remove the first matching element, use the `arrayRemoveInPlace`
|
|
35
|
+
* function instead.
|
|
36
|
+
*
|
|
37
|
+
* @returns True if one or more elements were removed, false otherwise.
|
|
38
|
+
*/
|
|
39
|
+
export declare function arrayRemoveAllInPlace<T>(array: T[], ...elementsToRemove: readonly T[]): boolean;
|
|
25
40
|
/**
|
|
26
41
|
* Removes the specified element(s) from the array. If the specified element(s) are not found in the
|
|
27
42
|
* array, this function will do nothing.
|
|
@@ -29,8 +44,7 @@ export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsT
|
|
|
29
44
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
30
45
|
*
|
|
31
46
|
* If there is more than one matching element in the array, this function will only remove the first
|
|
32
|
-
*
|
|
33
|
-
* function instead.
|
|
47
|
+
* one. If you want to remove all of the elements, use the `arrayRemoveAllInPlace` function instead.
|
|
34
48
|
*
|
|
35
49
|
* @returns The removed elements. This will be an empty array if no elements were removed.
|
|
36
50
|
*/
|
|
@@ -81,7 +95,7 @@ export declare function includes<T, TupleElement extends WidenLiteral<T>>(array:
|
|
|
81
95
|
*/
|
|
82
96
|
export declare function includesAny<T>(array: readonly T[], ...searchElements: readonly T[]): boolean;
|
|
83
97
|
/** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
|
|
84
|
-
export declare function isArray(
|
|
98
|
+
export declare function isArray(variable: unknown): variable is unknown[];
|
|
85
99
|
/** Initializes an array with all elements containing the specified default value. */
|
|
86
100
|
export declare function newArray<T>(length: number, value: T): readonly T[];
|
|
87
101
|
/** Helper function to sum every value in an array together. */
|
|
@@ -19,9 +19,24 @@ export declare function arrayEquals<T>(array1: readonly T[], array2: readonly T[
|
|
|
19
19
|
* array. If the specified element(s) are not found in the array, it will simply return a shallow
|
|
20
20
|
* copy of the array.
|
|
21
21
|
*
|
|
22
|
+
* If there is more than one matching element in the array, this function will remove all of them.
|
|
23
|
+
*
|
|
22
24
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
23
25
|
*/
|
|
24
26
|
export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): readonly T[];
|
|
27
|
+
/**
|
|
28
|
+
* Removes all of the specified element(s) from the array. If the specified element(s) are not found
|
|
29
|
+
* in the array, this function will do nothing.
|
|
30
|
+
*
|
|
31
|
+
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
32
|
+
*
|
|
33
|
+
* If there is more than one matching element in the array, this function will remove every matching
|
|
34
|
+
* element. If you want to only remove the first matching element, use the `arrayRemoveInPlace`
|
|
35
|
+
* function instead.
|
|
36
|
+
*
|
|
37
|
+
* @returns True if one or more elements were removed, false otherwise.
|
|
38
|
+
*/
|
|
39
|
+
export declare function arrayRemoveAllInPlace<T>(array: T[], ...elementsToRemove: readonly T[]): boolean;
|
|
25
40
|
/**
|
|
26
41
|
* Removes the specified element(s) from the array. If the specified element(s) are not found in the
|
|
27
42
|
* array, this function will do nothing.
|
|
@@ -29,8 +44,7 @@ export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsT
|
|
|
29
44
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
30
45
|
*
|
|
31
46
|
* If there is more than one matching element in the array, this function will only remove the first
|
|
32
|
-
*
|
|
33
|
-
* function instead.
|
|
47
|
+
* one. If you want to remove all of the elements, use the `arrayRemoveAllInPlace` function instead.
|
|
34
48
|
*
|
|
35
49
|
* @returns The removed elements. This will be an empty array if no elements were removed.
|
|
36
50
|
*/
|
|
@@ -81,7 +95,7 @@ export declare function includes<T, TupleElement extends WidenLiteral<T>>(array:
|
|
|
81
95
|
*/
|
|
82
96
|
export declare function includesAny<T>(array: readonly T[], ...searchElements: readonly T[]): boolean;
|
|
83
97
|
/** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
|
|
84
|
-
export declare function isArray(
|
|
98
|
+
export declare function isArray(variable: unknown): variable is unknown[];
|
|
85
99
|
/** Initializes an array with all elements containing the specified default value. */
|
|
86
100
|
export declare function newArray<T>(length: number, value: T): readonly T[];
|
|
87
101
|
/** Helper function to sum every value in an array together. */
|
|
@@ -19,9 +19,24 @@ export declare function arrayEquals<T>(array1: readonly T[], array2: readonly T[
|
|
|
19
19
|
* array. If the specified element(s) are not found in the array, it will simply return a shallow
|
|
20
20
|
* copy of the array.
|
|
21
21
|
*
|
|
22
|
+
* If there is more than one matching element in the array, this function will remove all of them.
|
|
23
|
+
*
|
|
22
24
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
23
25
|
*/
|
|
24
26
|
export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): readonly T[];
|
|
27
|
+
/**
|
|
28
|
+
* Removes all of the specified element(s) from the array. If the specified element(s) are not found
|
|
29
|
+
* in the array, this function will do nothing.
|
|
30
|
+
*
|
|
31
|
+
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
32
|
+
*
|
|
33
|
+
* If there is more than one matching element in the array, this function will remove every matching
|
|
34
|
+
* element. If you want to only remove the first matching element, use the `arrayRemoveInPlace`
|
|
35
|
+
* function instead.
|
|
36
|
+
*
|
|
37
|
+
* @returns True if one or more elements were removed, false otherwise.
|
|
38
|
+
*/
|
|
39
|
+
export declare function arrayRemoveAllInPlace<T>(array: T[], ...elementsToRemove: readonly T[]): boolean;
|
|
25
40
|
/**
|
|
26
41
|
* Removes the specified element(s) from the array. If the specified element(s) are not found in the
|
|
27
42
|
* array, this function will do nothing.
|
|
@@ -29,8 +44,7 @@ export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsT
|
|
|
29
44
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
30
45
|
*
|
|
31
46
|
* If there is more than one matching element in the array, this function will only remove the first
|
|
32
|
-
*
|
|
33
|
-
* function instead.
|
|
47
|
+
* one. If you want to remove all of the elements, use the `arrayRemoveAllInPlace` function instead.
|
|
34
48
|
*
|
|
35
49
|
* @returns The removed elements. This will be an empty array if no elements were removed.
|
|
36
50
|
*/
|
|
@@ -81,7 +95,7 @@ export declare function includes<T, TupleElement extends WidenLiteral<T>>(array:
|
|
|
81
95
|
*/
|
|
82
96
|
export declare function includesAny<T>(array: readonly T[], ...searchElements: readonly T[]): boolean;
|
|
83
97
|
/** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
|
|
84
|
-
export declare function isArray(
|
|
98
|
+
export declare function isArray(variable: unknown): variable is unknown[];
|
|
85
99
|
/** Initializes an array with all elements containing the specified default value. */
|
|
86
100
|
export declare function newArray<T>(length: number, value: T): readonly T[];
|
|
87
101
|
/** Helper function to sum every value in an array together. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/functions/array.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAI7D;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,GACjC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,CAQ7B;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,MAAM,EAAE,SAAS,CAAC,EAAE,GACnB,OAAO,CAST;AAED
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/functions/array.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAI7D;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,GACjC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,CAQ7B;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,MAAM,EAAE,SAAS,CAAC,EAAE,GACnB,OAAO,CAST;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,aAAa,EAAE,SAAS,CAAC,EAAE,EAC3B,GAAG,gBAAgB,EAAE,S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,EAAE,GAC9B,OAAO,CAET;AAED,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,OAAO,EAAE,CAEhE;AAED,qFAAqF;AACrF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,CAElE;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEzD"}
|
|
@@ -27,6 +27,12 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
|
|
|
27
27
|
* should be more performant for enums with around 52 or more elements.
|
|
28
28
|
*/
|
|
29
29
|
export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<string | number>): asserts value is T[keyof T];
|
|
30
|
+
/**
|
|
31
|
+
* Helper function to throw an error if the provided value is not an instance of the expected class.
|
|
32
|
+
*
|
|
33
|
+
* This is useful to have TypeScript narrow a value to a specific type in a concise way.
|
|
34
|
+
*/
|
|
35
|
+
export declare function assertIs<T extends abstract new (...args: unknown[]) => unknown>(value: unknown, constructor: T, msg: string): asserts value is InstanceType<T>;
|
|
30
36
|
/**
|
|
31
37
|
* Helper function to throw an error if the provided value is equal to `null`.
|
|
32
38
|
*
|
|
@@ -27,6 +27,12 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
|
|
|
27
27
|
* should be more performant for enums with around 52 or more elements.
|
|
28
28
|
*/
|
|
29
29
|
export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<string | number>): asserts value is T[keyof T];
|
|
30
|
+
/**
|
|
31
|
+
* Helper function to throw an error if the provided value is not an instance of the expected class.
|
|
32
|
+
*
|
|
33
|
+
* This is useful to have TypeScript narrow a value to a specific type in a concise way.
|
|
34
|
+
*/
|
|
35
|
+
export declare function assertIs<T extends abstract new (...args: unknown[]) => unknown>(value: unknown, constructor: T, msg: string): asserts value is InstanceType<T>;
|
|
30
36
|
/**
|
|
31
37
|
* Helper function to throw an error if the provided value is equal to `null`.
|
|
32
38
|
*
|
|
@@ -27,6 +27,12 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
|
|
|
27
27
|
* should be more performant for enums with around 52 or more elements.
|
|
28
28
|
*/
|
|
29
29
|
export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<string | number>): asserts value is T[keyof T];
|
|
30
|
+
/**
|
|
31
|
+
* Helper function to throw an error if the provided value is not an instance of the expected class.
|
|
32
|
+
*
|
|
33
|
+
* This is useful to have TypeScript narrow a value to a specific type in a concise way.
|
|
34
|
+
*/
|
|
35
|
+
export declare function assertIs<T extends abstract new (...args: unknown[]) => unknown>(value: unknown, constructor: T, msg: string): asserts value is InstanceType<T>;
|
|
30
36
|
/**
|
|
31
37
|
* Helper function to throw an error if the provided value is equal to `null`.
|
|
32
38
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/functions/assert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAIjE,+EAA+E;AAC/E,wBAAgB,WAAW,CACzB,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE,CAI5B;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,OAAO,CAI1B;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CA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E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,UAAQ,GACd,MAAM,CAWR;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOjE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAMxE"}
|
package/dist/index.cjs
CHANGED
|
@@ -56,6 +56,11 @@ function assertEnumValue(value, transpiledEnum, msg, set) {
|
|
|
56
56
|
throw new TypeError(msg);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
function assertIs(value, constructor, msg) {
|
|
60
|
+
if (!(value instanceof constructor)) {
|
|
61
|
+
throw new TypeError(msg);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
59
64
|
function assertNotNull(value, ...[msg]) {
|
|
60
65
|
if (value === null) {
|
|
61
66
|
throw new TypeError(msg);
|
|
@@ -120,6 +125,20 @@ function arrayRemove(originalArray, ...elementsToRemove) {
|
|
|
120
125
|
}
|
|
121
126
|
return array;
|
|
122
127
|
}
|
|
128
|
+
function arrayRemoveAllInPlace(array, ...elementsToRemove) {
|
|
129
|
+
let removedOneOrMoreElements = false;
|
|
130
|
+
for (const element of elementsToRemove) {
|
|
131
|
+
let index;
|
|
132
|
+
do {
|
|
133
|
+
index = array.indexOf(element);
|
|
134
|
+
if (index > -1) {
|
|
135
|
+
removedOneOrMoreElements = true;
|
|
136
|
+
array.splice(index, 1);
|
|
137
|
+
}
|
|
138
|
+
} while (index > -1);
|
|
139
|
+
}
|
|
140
|
+
return removedOneOrMoreElements;
|
|
141
|
+
}
|
|
123
142
|
function arrayRemoveInPlace(array, ...elementsToRemove) {
|
|
124
143
|
const removedElements = [];
|
|
125
144
|
for (const element of elementsToRemove) {
|
|
@@ -174,8 +193,8 @@ function includes(array, searchElement) {
|
|
|
174
193
|
function includesAny(array, ...searchElements) {
|
|
175
194
|
return searchElements.some((element) => array.includes(element));
|
|
176
195
|
}
|
|
177
|
-
function isArray(
|
|
178
|
-
return Array.isArray(
|
|
196
|
+
function isArray(variable) {
|
|
197
|
+
return Array.isArray(variable);
|
|
179
198
|
}
|
|
180
199
|
function newArray(length, value) {
|
|
181
200
|
return Array.from({ length }, () => value);
|
|
@@ -522,11 +541,13 @@ exports.addSetsToSet = addSetsToSet;
|
|
|
522
541
|
exports.arrayCopyTwoDimensional = arrayCopyTwoDimensional;
|
|
523
542
|
exports.arrayEquals = arrayEquals;
|
|
524
543
|
exports.arrayRemove = arrayRemove;
|
|
544
|
+
exports.arrayRemoveAllInPlace = arrayRemoveAllInPlace;
|
|
525
545
|
exports.arrayRemoveInPlace = arrayRemoveInPlace;
|
|
526
546
|
exports.assertArray = assertArray;
|
|
527
547
|
exports.assertBoolean = assertBoolean;
|
|
528
548
|
exports.assertDefined = assertDefined;
|
|
529
549
|
exports.assertEnumValue = assertEnumValue;
|
|
550
|
+
exports.assertIs = assertIs;
|
|
530
551
|
exports.assertNotNull = assertNotNull;
|
|
531
552
|
exports.assertNumber = assertNumber;
|
|
532
553
|
exports.assertObject = assertObject;
|
package/dist/index.mjs
CHANGED
|
@@ -54,6 +54,11 @@ function assertEnumValue(value, transpiledEnum, msg, set) {
|
|
|
54
54
|
throw new TypeError(msg);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
function assertIs(value, constructor, msg) {
|
|
58
|
+
if (!(value instanceof constructor)) {
|
|
59
|
+
throw new TypeError(msg);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
57
62
|
function assertNotNull(value, ...[msg]) {
|
|
58
63
|
if (value === null) {
|
|
59
64
|
throw new TypeError(msg);
|
|
@@ -118,6 +123,20 @@ function arrayRemove(originalArray, ...elementsToRemove) {
|
|
|
118
123
|
}
|
|
119
124
|
return array;
|
|
120
125
|
}
|
|
126
|
+
function arrayRemoveAllInPlace(array, ...elementsToRemove) {
|
|
127
|
+
let removedOneOrMoreElements = false;
|
|
128
|
+
for (const element of elementsToRemove) {
|
|
129
|
+
let index;
|
|
130
|
+
do {
|
|
131
|
+
index = array.indexOf(element);
|
|
132
|
+
if (index > -1) {
|
|
133
|
+
removedOneOrMoreElements = true;
|
|
134
|
+
array.splice(index, 1);
|
|
135
|
+
}
|
|
136
|
+
} while (index > -1);
|
|
137
|
+
}
|
|
138
|
+
return removedOneOrMoreElements;
|
|
139
|
+
}
|
|
121
140
|
function arrayRemoveInPlace(array, ...elementsToRemove) {
|
|
122
141
|
const removedElements = [];
|
|
123
142
|
for (const element of elementsToRemove) {
|
|
@@ -172,8 +191,8 @@ function includes(array, searchElement) {
|
|
|
172
191
|
function includesAny(array, ...searchElements) {
|
|
173
192
|
return searchElements.some((element) => array.includes(element));
|
|
174
193
|
}
|
|
175
|
-
function isArray(
|
|
176
|
-
return Array.isArray(
|
|
194
|
+
function isArray(variable) {
|
|
195
|
+
return Array.isArray(variable);
|
|
177
196
|
}
|
|
178
197
|
function newArray(length, value) {
|
|
179
198
|
return Array.from({ length }, () => value);
|
|
@@ -511,4 +530,4 @@ function* tupleKeys(tuple) {
|
|
|
511
530
|
|
|
512
531
|
const ReadonlyMap = Map;
|
|
513
532
|
|
|
514
|
-
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveInPlace, assertArray, assertBoolean, assertDefined, assertEnumValue, assertNotNull, assertNumber, assertObject, assertString, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterMap, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, includesAny, interfaceSatisfiesEnum, isArray, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isLowerCase, isObject, isSemanticVersion, isUpperCase, kebabCaseToCamelCase, kebabCaseToPascalCase, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter, objectKeysToSet, objectToMap, objectToReverseMap, objectValuesToSet, parseFloatSafe, parseIntSafe, parseSemanticVersion, removeLinesBetweenMarkers, removeLinesMatching, removeNonPrintableCharacters, removeWhitespace, repeat, setAdd, setHas, sortCaseInsensitive, sumArray, todo, trimPrefix, trimSuffix, truncateString, tupleEntries, tupleKeys };
|
|
533
|
+
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveAllInPlace, arrayRemoveInPlace, assertArray, assertBoolean, assertDefined, assertEnumValue, assertIs, assertNotNull, assertNumber, assertObject, assertString, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterMap, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, includesAny, interfaceSatisfiesEnum, isArray, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isLowerCase, isObject, isSemanticVersion, isUpperCase, kebabCaseToCamelCase, kebabCaseToPascalCase, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter, objectKeysToSet, objectToMap, objectToReverseMap, objectValuesToSet, parseFloatSafe, parseIntSafe, parseSemanticVersion, removeLinesBetweenMarkers, removeLinesMatching, removeNonPrintableCharacters, removeWhitespace, repeat, setAdd, setHas, sortCaseInsensitive, sumArray, todo, trimPrefix, trimSuffix, truncateString, tupleEntries, tupleKeys };
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "complete-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Helper functions for TypeScript projects.",
|
|
5
|
-
"keywords": [],
|
|
6
5
|
"homepage": "https://complete-ts.github.io/",
|
|
7
6
|
"bugs": {
|
|
8
7
|
"url": "https://github.com/complete-ts/complete/issues"
|
|
@@ -23,24 +22,20 @@
|
|
|
23
22
|
"types": "./dist/index.d.ts",
|
|
24
23
|
"files": [
|
|
25
24
|
"dist",
|
|
26
|
-
"src"
|
|
27
|
-
"LICENSE",
|
|
28
|
-
"package.json",
|
|
29
|
-
"README.md"
|
|
25
|
+
"src"
|
|
30
26
|
],
|
|
31
27
|
"scripts": {
|
|
32
28
|
"build": "tsx ./scripts/build.ts",
|
|
33
29
|
"docs": "typedoc",
|
|
34
30
|
"lint": "tsx ./scripts/lint.ts",
|
|
35
|
-
"test": "
|
|
31
|
+
"test": "tsx --test"
|
|
36
32
|
},
|
|
37
33
|
"devDependencies": {
|
|
38
|
-
"@types/node": "24.
|
|
39
|
-
"complete-node": "
|
|
34
|
+
"@types/node": "24.7.1",
|
|
35
|
+
"complete-node": "12.2.0",
|
|
40
36
|
"eslint-plugin-sort-exports": "0.9.1",
|
|
41
|
-
"
|
|
42
|
-
"typescript": "
|
|
43
|
-
"
|
|
44
|
-
"unbuild": "3.5.0"
|
|
37
|
+
"typescript": "5.9.3",
|
|
38
|
+
"typescript-eslint": "8.46.0",
|
|
39
|
+
"unbuild": "3.6.1"
|
|
45
40
|
}
|
|
46
41
|
}
|
package/src/functions/array.ts
CHANGED
|
@@ -48,6 +48,8 @@ export function arrayEquals<T>(
|
|
|
48
48
|
* array. If the specified element(s) are not found in the array, it will simply return a shallow
|
|
49
49
|
* copy of the array.
|
|
50
50
|
*
|
|
51
|
+
* If there is more than one matching element in the array, this function will remove all of them.
|
|
52
|
+
*
|
|
51
53
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
52
54
|
*/
|
|
53
55
|
export function arrayRemove<T>(
|
|
@@ -66,6 +68,39 @@ export function arrayRemove<T>(
|
|
|
66
68
|
return array;
|
|
67
69
|
}
|
|
68
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Removes all of the specified element(s) from the array. If the specified element(s) are not found
|
|
73
|
+
* in the array, this function will do nothing.
|
|
74
|
+
*
|
|
75
|
+
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
76
|
+
*
|
|
77
|
+
* If there is more than one matching element in the array, this function will remove every matching
|
|
78
|
+
* element. If you want to only remove the first matching element, use the `arrayRemoveInPlace`
|
|
79
|
+
* function instead.
|
|
80
|
+
*
|
|
81
|
+
* @returns True if one or more elements were removed, false otherwise.
|
|
82
|
+
*/
|
|
83
|
+
export function arrayRemoveAllInPlace<T>(
|
|
84
|
+
// eslint-disable-next-line complete/prefer-readonly-parameter-types
|
|
85
|
+
array: T[],
|
|
86
|
+
...elementsToRemove: readonly T[]
|
|
87
|
+
): boolean {
|
|
88
|
+
let removedOneOrMoreElements = false;
|
|
89
|
+
|
|
90
|
+
for (const element of elementsToRemove) {
|
|
91
|
+
let index: number;
|
|
92
|
+
do {
|
|
93
|
+
index = array.indexOf(element);
|
|
94
|
+
if (index > -1) {
|
|
95
|
+
removedOneOrMoreElements = true;
|
|
96
|
+
array.splice(index, 1);
|
|
97
|
+
}
|
|
98
|
+
} while (index > -1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return removedOneOrMoreElements;
|
|
102
|
+
}
|
|
103
|
+
|
|
69
104
|
/**
|
|
70
105
|
* Removes the specified element(s) from the array. If the specified element(s) are not found in the
|
|
71
106
|
* array, this function will do nothing.
|
|
@@ -73,8 +108,7 @@ export function arrayRemove<T>(
|
|
|
73
108
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
74
109
|
*
|
|
75
110
|
* If there is more than one matching element in the array, this function will only remove the first
|
|
76
|
-
*
|
|
77
|
-
* function instead.
|
|
111
|
+
* one. If you want to remove all of the elements, use the `arrayRemoveAllInPlace` function instead.
|
|
78
112
|
*
|
|
79
113
|
* @returns The removed elements. This will be an empty array if no elements were removed.
|
|
80
114
|
*/
|
|
@@ -207,8 +241,8 @@ export function includesAny<T>(
|
|
|
207
241
|
}
|
|
208
242
|
|
|
209
243
|
/** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
|
|
210
|
-
export function isArray(
|
|
211
|
-
return Array.isArray(
|
|
244
|
+
export function isArray(variable: unknown): variable is unknown[] {
|
|
245
|
+
return Array.isArray(variable);
|
|
212
246
|
}
|
|
213
247
|
|
|
214
248
|
/** Initializes an array with all elements containing the specified default value. */
|
package/src/functions/assert.ts
CHANGED
|
@@ -67,6 +67,23 @@ export function assertEnumValue<T extends TranspiledEnum>(
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Helper function to throw an error if the provided value is not an instance of the expected class.
|
|
72
|
+
*
|
|
73
|
+
* This is useful to have TypeScript narrow a value to a specific type in a concise way.
|
|
74
|
+
*/
|
|
75
|
+
export function assertIs<
|
|
76
|
+
T extends abstract new (...args: unknown[]) => unknown,
|
|
77
|
+
>(
|
|
78
|
+
value: unknown,
|
|
79
|
+
constructor: T,
|
|
80
|
+
msg: string,
|
|
81
|
+
): asserts value is InstanceType<T> {
|
|
82
|
+
if (!(value instanceof constructor)) {
|
|
83
|
+
throw new TypeError(msg);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
70
87
|
/**
|
|
71
88
|
* Helper function to throw an error if the provided value is equal to `null`.
|
|
72
89
|
*
|
package/src/functions/string.ts
CHANGED
|
@@ -227,6 +227,7 @@ export function parseSemanticVersion(versionString: string):
|
|
|
227
227
|
return { majorVersion, minorVersion, patchVersion };
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
/* eslint-disable jsdoc/escape-inline-tags */
|
|
230
231
|
/**
|
|
231
232
|
* Helper function to remove lines from a multi-line string. This function looks for a "-start" and
|
|
232
233
|
* a "-end" suffix after the marker. Lines with markets will be completely removed from the output.
|
|
@@ -249,6 +250,7 @@ export function parseSemanticVersion(versionString: string):
|
|
|
249
250
|
* line4
|
|
250
251
|
* ```
|
|
251
252
|
*/
|
|
253
|
+
/* eslint-enable jsdoc/escape-inline-tags */
|
|
252
254
|
export function removeLinesBetweenMarkers(
|
|
253
255
|
string: string,
|
|
254
256
|
marker: string,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { deepStrictEqual, strictEqual } from "node:assert";
|
|
2
|
-
import
|
|
2
|
+
import { describe, test } from "node:test";
|
|
3
3
|
import { assertDefined, assertNotNull } from "./assert.js";
|
|
4
4
|
import { eRange, iRange, parseFloatSafe, parseIntSafe } from "./utils.js";
|
|
5
5
|
|
|
@@ -372,7 +372,7 @@ describe("parseFloatSafe", () => {
|
|
|
372
372
|
});
|
|
373
373
|
|
|
374
374
|
test("bigint", () => {
|
|
375
|
-
const result = parseFloatSafe(
|
|
375
|
+
const result = parseFloatSafe(1n as unknown as string);
|
|
376
376
|
strictEqual(result, undefined);
|
|
377
377
|
});
|
|
378
378
|
|
|
@@ -693,7 +693,7 @@ describe("parseIntSafe", () => {
|
|
|
693
693
|
});
|
|
694
694
|
|
|
695
695
|
test("bigint", () => {
|
|
696
|
-
const result = parseIntSafe(
|
|
696
|
+
const result = parseIntSafe(1n as unknown as string);
|
|
697
697
|
strictEqual(result, undefined);
|
|
698
698
|
});
|
|
699
699
|
|