jscurry

1.0.0 • Public • Published

JS Curry

JavaScript auto-curry. Works with native code functions, regulars ones, ...rest and parameters with default values. It does not depend on function.length.

Install

npm install jscurry

Usage

const { curry } = require("jscurry");
const add = curry((a, b) => a + b);
const add2 = add(2);
console.log(add2(3)); // logs 5

How to know if function is curried?

const { Curry } = require("jscurry")
console.log(fn instanceof Curry)

Advanced usage

const { Curry } = require("jscurry")
const add2 = new Curry(
  (a, b) => a + b, // function
  2, // arity, pass null to autocompute
  [2] // list of args to start with
)
console.log(add2(3)) // logs 5

Readme

Keywords

none

Package Sidebar

Install

npm i jscurry

Weekly Downloads

0

Version

1.0.0

License

Apache-2.0

Unpacked Size

2.71 kB

Total Files

4

Last publish

Collaborators

  • pouya-eghbali