0.0.4 • Published 5 months ago

util-arrays v0.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

Array Utility Functions

A collection of TypeScript functions for working with arrays. These functions provide various array manipulation and analysis capabilities.

Installation

To use these utility functions in your TypeScript or JavaScript project, you can install them via npm:

npm install util-arrays

Usage Examples

import {
    deepClone,
    isEqual,
    chunkArray,
    isSameLength,
    sumArray,
    findMax,
    findMin,
} from 'util-arrays';

// Example 1: deepClone
const originalArray = [1, 2, 3];
const clonedArray = deepClone(originalArray);
console.log(clonedArray); // [1, 2, 3]

// Example 2: isEqual
const array1 = [1, 2, 3];
const array2 = [1, 2, 3];
const areEqual = isEqual(array1, array2);
console.log(areEqual); // true

// Example 3: chunkArray
const originalArray = [1, 2, 3, 4, 5, 6];
const chunkedArray = chunkArray(originalArray, 3);
console.log(chunkedArray); // [[1, 2, 3], [4, 5, 6]]

// Example 4: isSameLength
const array1 = [1, 2, 3];
const array2 = ['a', 'b', 'c'];
const sameLength = isSameLength(array1, array2);
console.log(sameLength); // true

// Example 5: sumArray
const numbers = [1, 2, 3, 4, 5];
const sum = sumArray(numbers);
console.log(sum); // 15

// Example 6: findMax
const numbers = [10, 5, 8, 20, 15];
const max = findMax(numbers);
console.log(max); // 20

// Example 7: findMin
const numbers = [10, 5, 8, 20, 15];
const min = findMin(numbers);
console.log(min); // 5
0.0.4

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago