@simpill/array.utils
v1.0.0
Published
Array utilities: unique, chunk, compact, groupBy, sortBy, flattenOnce (Node and Edge).
Downloads
115
Maintainers
Readme
Features: Type-safe · Node & Edge · Tree-shakeable · Lightweight
Installation
From npm
npm install @simpill/array.utilsFrom GitHub
To use this package from the monorepo source:
git clone https://github.com/SkinnnyJay/simpill.git
cd simpill/utils/@simpill-array.utils
npm install && npm run buildIn your project you can then install from the local path:
npm install /path/to/simpill/utils/@simpill-array.utils
or use npm link from the package directory.
Usage
import {
unique,
chunk,
compact,
groupBy,
sortBy,
flattenOnce,
partition,
zip,
keyBy,
countBy,
intersection,
difference,
union,
sample,
shuffle,
take,
drop,
} from "@simpill/array.utils";API Reference
- Unique / compact:
unique,uniqueBy,compact - Chunking / flatten:
chunk,flattenOnce - Grouping / keying:
groupBy,keyBy,countBy - Sorting:
sortBy(withSortOrder) - Partition / zip:
partition,zip,unzip - Set-like:
intersection,difference,union - Sampling / slice:
sample,shuffle,take,takeRight,drop,dropRight - First / last:
first,last - Guards:
isArrayLike,isNonEmptyArray,ensureArray
Subpath exports: @simpill/array.utils, @simpill/array.utils/client, @simpill/array.utils/server, @simpill/array.utils/shared.
