/curry

An useful function to make a multi params function be called in chains.

Primary LanguageJavaScript



Curry any function.

An useful function to make a multi params function be called in chains.

Built with ❤︎ by Kaneda

Instalation

npm install curry-fn

How to use

Normal use

const {curry} from 'curry-fn';

const add = (x, y, z) => x + y + z;
const curriedAdd = curry(add);
console.log(curriedAdd(1)(2)(3));
// if you pass more than one arg, then the function will ignore them.
// unary functions should receive only one parameter.
console.log(curriedAdd(1)(2, 3)(3)); // => 6

Changelog

1.0.0

First release.

1.1.0

Tests added.

1.2.0

For the sake of fudamentalism, I removed somes features, given the fact that unary functions are a requirement in curry, and the potential leading to errors, and misunderstanding about arbitrary parameters sizes in function composition.

Removed features:

  1. Placeholders.
  2. Arbitrary arity.
  3. 1..N parameters per curried function.

Motivation

I just want to write some useful functional code in javascript.

TODO

  1. add tests.
  2. add code coverage.

Feel free to fork and contribute.