Array Utils is a simple utility package that extends JavaScript's Array
prototype with several helpful methods for manipulating arrays.
This package adds 10 useful higher-order functions (HOFs) to arrays, enabling common operations like calculating sums, removing duplicates, and more with ease.
To install array_utils_node
in your project, run the following command:
npm install array_utils_node
```How to use
// Import the array-utils package
require('array-utils');
// Example usage:
const arr = [1, 2, 3, 4, 5, 1, 2];
console.log(arr.sum()); // 18
console.log(arr.unique()); // [1, 2, 3, 4, 5]
console.log(arr.average()); // 3
console.log(arr.allEven()); // false
console.log(arr.allOdd()); // false
console.log(arr.max()); // 5
console.log(arr.min()); // 1
console.log(arr.filterBelow(3)); // [3, 4, 5]
console.log(arr.clean()); // [1, 2, 3, 4, 5, 1, 2]
console.log(arr.mergeUnique([3, 6, 7])); // [1, 2, 3, 4, 5, 1, 2, 6, 7]