1.0.0 • Published 8 years ago

@riim/curry v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

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.

LibraryCreateLiftCall
@riim/curry2,4505,5006,600
curry13,500400350
cast-curry4,550165350
just-curry900200195
auto-curry385170155
light-curry21,9003,9501,200
@thisables/curry400700600
@ibrokethat/curry6,1002502,050
instant-curry7,1002501,600
fj-curry13,750385350
curry-d9,100350330

Benchmark sources can be found in the folder perf.