@riim/curry

1.0.0 • Public • Published

curry

Fast curry implementation with placeholders and function-bind-syntax support.

Build Status Coverage Status Dependency Status Dev Dependency Status

Installation

npm install @riim/curry --save

Usage

Basic

var curry = require('@riim/curry');

var sum = curry(function(a, b) { return a + b; });
var addOne = sum(1); // or sum(curry.__, 1)

console.log(addOne(2));
// => 3

Placeholders

var curry = require('@riim/curry');

var setProperty = curry(function(obj, name, value) {
	obj[name] = value;
	return obj;
});

var setUserAge = setProperty(curry.__, 'age');

console.log(setUserAge({}, 30));
// => { age: 30 }

ES.Next syntax

import { curry, __ } from '@riim/curry';

let setProperty = curry((obj, name, value) => {
	obj[name] = value;
	return obj;
});

let setUserAge = setProperty(__, 'age');

console.log(setUserAge({}, 30));
// => { age: 30 }

Function bind syntax

import { curry, __ } from '@riim/curry';

let setProperty = ((obj, name, value) => {
	obj[name] = value;
	return obj;
})::curry();

let setUserAge = setProperty(__, 'age');

console.log(setUserAge({}, 30));
// => { age: 30 }

Benchmark

Create - sum = curry((a, b) => a + b) - least important result
Lift - addOne = sum(1)
Call - addOne(2) - much more important result than the previous two

Results in K ops/sec.

Library Create Lift Call
@riim/curry 2,450 5,500 6,600
curry 13,500 400 350
cast-curry 4,550 165 350
just-curry 900 200 195
auto-curry 385 170 155
light-curry 21,900 3,950 1,200
@thisables/curry 400 700 600
@ibrokethat/curry 6,100 250 2,050
instant-curry 7,100 250 1,600
fj-curry 13,750 385 350
curry-d 9,100 350 330

Benchmark sources can be found in the folder perf.

Readme

Keywords

none

Package Sidebar

Install

npm i @riim/curry

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • riim