Really simple functions for working with built-in collection types, inspired by F#'s collection modules design.
- Covers, iterables, arrays, maps and sets.
- Composable functional design.
Calculating primes without loops:
const primes = pipe(init(x => x, 100))
.then(
map(x => ({
x,
factors: pipe(init(i => i + 1, x))
.then(filter(y => x % y === 0))
.result
}))
)
.then(filter(num => Iterables.length(num.factors) === 2))
.then(map(num => num.x))
.then(toArray)
.result
You can import the generated bundle to use the whole library:
import myLib from 'collection-fns'
Additionally, you can import the specific modules from dist/lib
:
import { groupBy } from 'collection-fns/dist/lib/iterable'
yarn t
: Run test suiteyarn start
: Runyarn build
in watch modeyarn test:watch
: Run test suite in interactive watch modeyarn test:prod
: Run linting and generate coverageyarn build
: Generate bundles and typings, create docsyarn lint
: Lints codeyarn commit
: Commit using conventional commit style (husky will tell you to use it if you haven't 😉)