complete-common 2.4.0 → 2.5.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 +13 -0
- package/dist/functions/array.d.mts +13 -0
- package/dist/functions/array.d.ts +13 -0
- package/dist/functions/array.d.ts.map +1 -1
- package/dist/index.cjs +15 -0
- package/dist/index.mjs +15 -1
- package/package.json +3 -3
- package/src/functions/array.ts +33 -0
|
@@ -22,6 +22,19 @@ export declare function arrayEquals<T>(array1: readonly T[], array2: readonly T[
|
|
|
22
22
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
23
23
|
*/
|
|
24
24
|
export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): readonly T[];
|
|
25
|
+
/**
|
|
26
|
+
* Removes all of the specified element(s) from the array. If the specified element(s) are not found
|
|
27
|
+
* in the array, this function will do nothing.
|
|
28
|
+
*
|
|
29
|
+
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
30
|
+
*
|
|
31
|
+
* If there is more than one matching element in the array, this function will remove every matching
|
|
32
|
+
* element. If you want to only remove the first matching element, use the `arrayRemoveInPlace`
|
|
33
|
+
* function instead.
|
|
34
|
+
*
|
|
35
|
+
* @returns True if one or more elements were removed, false otherwise.
|
|
36
|
+
*/
|
|
37
|
+
export declare function arrayRemoveAllInPlace<T>(array: T[], ...elementsToRemove: readonly T[]): boolean;
|
|
25
38
|
/**
|
|
26
39
|
* Removes the specified element(s) from the array. If the specified element(s) are not found in the
|
|
27
40
|
* array, this function will do nothing.
|
|
@@ -22,6 +22,19 @@ export declare function arrayEquals<T>(array1: readonly T[], array2: readonly T[
|
|
|
22
22
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
23
23
|
*/
|
|
24
24
|
export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): readonly T[];
|
|
25
|
+
/**
|
|
26
|
+
* Removes all of the specified element(s) from the array. If the specified element(s) are not found
|
|
27
|
+
* in the array, this function will do nothing.
|
|
28
|
+
*
|
|
29
|
+
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
30
|
+
*
|
|
31
|
+
* If there is more than one matching element in the array, this function will remove every matching
|
|
32
|
+
* element. If you want to only remove the first matching element, use the `arrayRemoveInPlace`
|
|
33
|
+
* function instead.
|
|
34
|
+
*
|
|
35
|
+
* @returns True if one or more elements were removed, false otherwise.
|
|
36
|
+
*/
|
|
37
|
+
export declare function arrayRemoveAllInPlace<T>(array: T[], ...elementsToRemove: readonly T[]): boolean;
|
|
25
38
|
/**
|
|
26
39
|
* Removes the specified element(s) from the array. If the specified element(s) are not found in the
|
|
27
40
|
* array, this function will do nothing.
|
|
@@ -22,6 +22,19 @@ export declare function arrayEquals<T>(array1: readonly T[], array2: readonly T[
|
|
|
22
22
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
23
23
|
*/
|
|
24
24
|
export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): readonly T[];
|
|
25
|
+
/**
|
|
26
|
+
* Removes all of the specified element(s) from the array. If the specified element(s) are not found
|
|
27
|
+
* in the array, this function will do nothing.
|
|
28
|
+
*
|
|
29
|
+
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
30
|
+
*
|
|
31
|
+
* If there is more than one matching element in the array, this function will remove every matching
|
|
32
|
+
* element. If you want to only remove the first matching element, use the `arrayRemoveInPlace`
|
|
33
|
+
* function instead.
|
|
34
|
+
*
|
|
35
|
+
* @returns True if one or more elements were removed, false otherwise.
|
|
36
|
+
*/
|
|
37
|
+
export declare function arrayRemoveAllInPlace<T>(array: T[], ...elementsToRemove: readonly T[]): boolean;
|
|
25
38
|
/**
|
|
26
39
|
* Removes the specified element(s) from the array. If the specified element(s) are not found in the
|
|
27
40
|
* array, this function will do nothing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/functions/array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AS,CAAC,EAAE,GAC9B,OAAO,CAET;AAED,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,EAAE,CAEtD;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"}
|
package/dist/index.cjs
CHANGED
|
@@ -120,6 +120,20 @@ function arrayRemove(originalArray, ...elementsToRemove) {
|
|
|
120
120
|
}
|
|
121
121
|
return array;
|
|
122
122
|
}
|
|
123
|
+
function arrayRemoveAllInPlace(array, ...elementsToRemove) {
|
|
124
|
+
let removedOneOrMoreElements = false;
|
|
125
|
+
for (const element of elementsToRemove) {
|
|
126
|
+
let index;
|
|
127
|
+
do {
|
|
128
|
+
index = array.indexOf(element);
|
|
129
|
+
if (index > -1) {
|
|
130
|
+
removedOneOrMoreElements = true;
|
|
131
|
+
array.splice(index, 1);
|
|
132
|
+
}
|
|
133
|
+
} while (index > -1);
|
|
134
|
+
}
|
|
135
|
+
return removedOneOrMoreElements;
|
|
136
|
+
}
|
|
123
137
|
function arrayRemoveInPlace(array, ...elementsToRemove) {
|
|
124
138
|
const removedElements = [];
|
|
125
139
|
for (const element of elementsToRemove) {
|
|
@@ -522,6 +536,7 @@ exports.addSetsToSet = addSetsToSet;
|
|
|
522
536
|
exports.arrayCopyTwoDimensional = arrayCopyTwoDimensional;
|
|
523
537
|
exports.arrayEquals = arrayEquals;
|
|
524
538
|
exports.arrayRemove = arrayRemove;
|
|
539
|
+
exports.arrayRemoveAllInPlace = arrayRemoveAllInPlace;
|
|
525
540
|
exports.arrayRemoveInPlace = arrayRemoveInPlace;
|
|
526
541
|
exports.assertArray = assertArray;
|
|
527
542
|
exports.assertBoolean = assertBoolean;
|
package/dist/index.mjs
CHANGED
|
@@ -118,6 +118,20 @@ function arrayRemove(originalArray, ...elementsToRemove) {
|
|
|
118
118
|
}
|
|
119
119
|
return array;
|
|
120
120
|
}
|
|
121
|
+
function arrayRemoveAllInPlace(array, ...elementsToRemove) {
|
|
122
|
+
let removedOneOrMoreElements = false;
|
|
123
|
+
for (const element of elementsToRemove) {
|
|
124
|
+
let index;
|
|
125
|
+
do {
|
|
126
|
+
index = array.indexOf(element);
|
|
127
|
+
if (index > -1) {
|
|
128
|
+
removedOneOrMoreElements = true;
|
|
129
|
+
array.splice(index, 1);
|
|
130
|
+
}
|
|
131
|
+
} while (index > -1);
|
|
132
|
+
}
|
|
133
|
+
return removedOneOrMoreElements;
|
|
134
|
+
}
|
|
121
135
|
function arrayRemoveInPlace(array, ...elementsToRemove) {
|
|
122
136
|
const removedElements = [];
|
|
123
137
|
for (const element of elementsToRemove) {
|
|
@@ -511,4 +525,4 @@ function* tupleKeys(tuple) {
|
|
|
511
525
|
|
|
512
526
|
const ReadonlyMap = Map;
|
|
513
527
|
|
|
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 };
|
|
528
|
+
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveAllInPlace, 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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "complete-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Helper functions for TypeScript projects.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://complete-ts.github.io/",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"test": "glob \"./src/**/*.test.ts\" --cmd=\"node --import tsx --test --test-reporter spec\""
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/node": "24.0.
|
|
39
|
-
"complete-node": "7.4.
|
|
38
|
+
"@types/node": "24.0.15",
|
|
39
|
+
"complete-node": "7.4.3",
|
|
40
40
|
"eslint-plugin-sort-exports": "0.9.1",
|
|
41
41
|
"glob": "11.0.3",
|
|
42
42
|
"typescript": "5.8.3",
|
package/src/functions/array.ts
CHANGED
|
@@ -66,6 +66,39 @@ export function arrayRemove<T>(
|
|
|
66
66
|
return array;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Removes all of the specified element(s) from the array. If the specified element(s) are not found
|
|
71
|
+
* in the array, this function will do nothing.
|
|
72
|
+
*
|
|
73
|
+
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
74
|
+
*
|
|
75
|
+
* If there is more than one matching element in the array, this function will remove every matching
|
|
76
|
+
* element. If you want to only remove the first matching element, use the `arrayRemoveInPlace`
|
|
77
|
+
* function instead.
|
|
78
|
+
*
|
|
79
|
+
* @returns True if one or more elements were removed, false otherwise.
|
|
80
|
+
*/
|
|
81
|
+
export function arrayRemoveAllInPlace<T>(
|
|
82
|
+
// eslint-disable-next-line complete/prefer-readonly-parameter-types
|
|
83
|
+
array: T[],
|
|
84
|
+
...elementsToRemove: readonly T[]
|
|
85
|
+
): boolean {
|
|
86
|
+
let removedOneOrMoreElements = false;
|
|
87
|
+
|
|
88
|
+
for (const element of elementsToRemove) {
|
|
89
|
+
let index: number;
|
|
90
|
+
do {
|
|
91
|
+
index = array.indexOf(element);
|
|
92
|
+
if (index > -1) {
|
|
93
|
+
removedOneOrMoreElements = true;
|
|
94
|
+
array.splice(index, 1);
|
|
95
|
+
}
|
|
96
|
+
} while (index > -1);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return removedOneOrMoreElements;
|
|
100
|
+
}
|
|
101
|
+
|
|
69
102
|
/**
|
|
70
103
|
* Removes the specified element(s) from the array. If the specified element(s) are not found in the
|
|
71
104
|
* array, this function will do nothing.
|