Skip to content

schtauffen/crry

Repository files navigation

crry

crry is a small library intended to offer currying similar to ramda and lodash/fp.
However, it only focuses on such and therefore does not bring any bloat into your code.

I created this after finding that curry does not support placeholders, does not have a LICENSE associated with it, and appears to be inactive.

Usage

crry exports two functions and a constant:

import { curry, curryN, __ } from 'crry'

A umd version is available:

<script src="//unpkg.com/crry/dest/umd/index.js"></script>

curry

curry takes a function as its lone argument and returns a curried version of that function.

const sumTrio = curry((a, b, c) => a + b + c)

sumTrio(1, 2, 3) // -> 6
sumTrio(1, 2)(3) // -> 6
sumTrio(1)(2, 3) // -> 6
sumTrio(1)(2)(3) // -> 6

curryN

curryN is for when your function cannot be automatically determined by curry

const calculate = curryN(3, (...args) => args[0] + args[1] * args[2])

calculate(7)(2)(3) // -> 13

__

__ is a placeholder, which allows you to wait for arguments in specific positions.

const calculate = curry((a, b, c) => (b - a) * c

calculate(2, __, 3)(1) // -> -3

About

A micro library for your currying needs

Resources

License

Stars

Watchers

Forks

Packages

No packages published