@nu-art/ts-common 0.204.97 → 0.204.98
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/package.json +1 -1
- package/utils/array-tools.d.ts +6 -0
- package/utils/array-tools.js +10 -1
package/package.json
CHANGED
package/utils/array-tools.d.ts
CHANGED
|
@@ -113,6 +113,12 @@ export declare function asOptionalArray<T>(toBeArray?: T | T[]): T[] | undefined
|
|
|
113
113
|
export declare function lastElement<T>(array: T[] | undefined): T | undefined;
|
|
114
114
|
export declare function firstElement<T>(array?: T[]): T | undefined;
|
|
115
115
|
export declare function arrayIncludesAny<T>(arr1: T[], arr2: T[]): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Clear array instance and keep the same instance so save memory
|
|
118
|
+
* This function will take any array and clear it's content completely while keeping the same instance to save memory
|
|
119
|
+
* @param arr - Any array
|
|
120
|
+
*/
|
|
121
|
+
export declare function clearArrayInstance<T extends any[]>(arr: T): void;
|
|
116
122
|
/**
|
|
117
123
|
* Returns true if arr1 returns the entirety of arr2
|
|
118
124
|
* @param arr1
|
package/utils/array-tools.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.arrayIncludesAll = exports.arrayIncludesAny = exports.firstElement = exports.lastElement = exports.asOptionalArray = exports.asArray = exports.generateArray = exports.toggleInArray = exports.groupArrayBy = exports.filterFlatInstances = exports.flatArray = exports.batchActionParallel = exports.Promise_all_sequentially = exports.batchAction = exports.sortArray = exports.reduceToMap = exports.arrayToMap = exports.filterFalsy = exports.filterInstances = exports.filterDuplicates = exports.findDuplicates = exports.filterAsync = exports.toggleElementInArray = exports.addItemToArrayAtIndex = exports.addItemToArray = exports.swapInArrayByIndex = exports.removeFromArrayByIndex = exports.removeFromArray = exports.removeItemFromArray = exports.filterInOut = void 0;
|
|
20
|
+
exports.arrayIncludesAll = exports.clearArrayInstance = exports.arrayIncludesAny = exports.firstElement = exports.lastElement = exports.asOptionalArray = exports.asArray = exports.generateArray = exports.toggleInArray = exports.groupArrayBy = exports.filterFlatInstances = exports.flatArray = exports.batchActionParallel = exports.Promise_all_sequentially = exports.batchAction = exports.sortArray = exports.reduceToMap = exports.arrayToMap = exports.filterFalsy = exports.filterInstances = exports.filterDuplicates = exports.findDuplicates = exports.filterAsync = exports.toggleElementInArray = exports.addItemToArrayAtIndex = exports.addItemToArray = exports.swapInArrayByIndex = exports.removeFromArrayByIndex = exports.removeFromArray = exports.removeItemFromArray = exports.filterInOut = void 0;
|
|
21
21
|
const tools_1 = require("./tools");
|
|
22
22
|
const object_tools_1 = require("./object-tools");
|
|
23
23
|
const exceptions_1 = require("../core/exceptions/exceptions");
|
|
@@ -304,6 +304,15 @@ function arrayIncludesAny(arr1, arr2) {
|
|
|
304
304
|
return arr1.some(item => arr2.includes(item));
|
|
305
305
|
}
|
|
306
306
|
exports.arrayIncludesAny = arrayIncludesAny;
|
|
307
|
+
/**
|
|
308
|
+
* Clear array instance and keep the same instance so save memory
|
|
309
|
+
* This function will take any array and clear it's content completely while keeping the same instance to save memory
|
|
310
|
+
* @param arr - Any array
|
|
311
|
+
*/
|
|
312
|
+
function clearArrayInstance(arr) {
|
|
313
|
+
arr.length = 0;
|
|
314
|
+
}
|
|
315
|
+
exports.clearArrayInstance = clearArrayInstance;
|
|
307
316
|
/**
|
|
308
317
|
* Returns true if arr1 returns the entirety of arr2
|
|
309
318
|
* @param arr1
|