1.2.2 • Published 2 years ago

crry v1.2.2

Weekly downloads
12
License
ISC
Repository
github
Last release
2 years ago

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
1.2.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.0

7 years ago