@ts-utilkit/array
v0.2.0
Published
Comprehensive array manipulation utilities including sorting, filtering, transformation, and mathematical operations
Maintainers
Readme
@ts-utilkit/array
Comprehensive array manipulation utilities with 26 functions for sorting, filtering, transformation, and mathematical operations on arrays.
Installation
npm install @ts-utilkit/arrayFeatures
- 🚀 TypeScript-first with complete type definitions
- ✅ Comprehensive test coverage (>95%)
- 📦 Tree-shakeable ESM and CommonJS support
- 🔒 Type-safe with strict TypeScript configuration
- ⚡ Performance-optimized implementations
- 📖 Extensive JSDoc documentation
Available Functions (26)
arrayDifference- Find elements in first array not in secondarrayIntersection- Find common elements between arrayscartesianProduct- Generate Cartesian product of arrayschunkArray- Split array into chunks of specified sizefindCommonWithCondition- Find common elements with custom logicfindDuplicates- Find duplicate elementsfindIndexOfElement- Find index with custom comparisonfindMax- Find maximum value in arrayfindMin- Find minimum value in arrayfindUniqueElements- Find unique elementsflattenArray- Flatten nested arrays completelyflattenArrayDepth- Flatten arrays to specified depthgeneratePrimes- Generate array of prime numbers up to limitgroupBy- Group array elements by key or functionjoinStrings- Join array elements into stringmergeUnique- Merge arrays with unique elements onlyremoveByCondition- Remove elements matching conditionremoveByIndex- Remove element at specific indexremoveDuplicates- Remove duplicate valuesremoveFalsyValues- Remove falsy values (null, undefined, false, 0, '')rotateArrayLeft- Rotate array elements to the leftrotateArrayRight- Rotate array elements to the rightsortBy- Sort objects by property or custom functionsumArrayElements- Sum all numeric elementsuniqueElementsWithCounts- Get unique elements with occurrence countszipMultiple- Zip multiple arrays together
Quick Example
import { chunkArray, removeDuplicates, flattenArray } from '@ts-utilkit/array';
chunkArray([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
removeDuplicates([1, 2, 2, 3]); // [1, 2, 3]
flattenArray([1, [2, [3, 4]]]); // [1, 2, 3, 4]License
MIT © Mykyta Forofontov
