array-fx
v1.1.5
Published
Lightweight and modular array utilities for JavaScript and Node.js: shuffle, unique, chunk, groupBy, flatten, difference, intersection, and more.
Maintainers
Readme
array-fx
🚀 Lightweight and useful array utilities for JavaScript and Node.js.
Great for both frontend (React, Next.js) and backend (Node.js).
✨ Features
Basic utilities
shuffle(array)→ Randomly shuffles arrayunique(array)→ Removes duplicate valueschunk(array, size)→ Splits array into chunksgroupBy(array, key)→ Groups array by property or callbackflatten(array)→ Flattens 1-level nested arraysdifference(a, b)→ Returns elements inabut not inbintersection(a, b)→ Returns elements common to both
Advanced utilities
differenceBy(a, b, fn)→ Difference by mapping functionfindMax(array, fn?)→ Max element by value or selectorfindMin(array, fn?)→ Min element by value or selectorfindMiddle(array, fn?)→ Middle element in sorted ordersample(array)→ Random elementsampleSize(array, n)→ N random elementscompact(array)→ Removes falsy valuesisEqual(a, b)→ Deep equality check
Frontend helpers
paginate(array, size, page)→ Get a page of array itemstoMatrix(array, columns)→ Convert array to 2D grid
📦 Installation
npm install array-fx