util-arrays
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

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

Package Sidebar

Install

npm i util-arrays

Weekly Downloads

4

Version

0.0.4

License

ISC

Unpacked Size

18 kB

Total Files

9

Last publish

Collaborators

  • rahuja445