Skip to content
A functional JavaScript library that facilitates currying and point-free programming
JavaScript
Branch: master
Clone or download
leecrossley Merge pull request #8 from r3oath/master
Fix `real world example` sample outputs.
Latest commit dd60e51 Dec 21, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Migrate to gulp Oct 10, 2015
.jshintrc Migrate to gulp Oct 10, 2015
.travis.yml Migrate to gulp Oct 10, 2015
README.md Fix `real world example` sample outputs. Oct 2, 2016
bower.json No more min version Sep 4, 2016
component.json No more min version Sep 4, 2016
functional.js Update functional.js May 10, 2016
gulpfile.js No more min version Sep 4, 2016
package.json Remove unused depend Sep 4, 2016
spec.js Migrate to gulp Oct 10, 2015

README.md

functional.js (fjs) Build Status npm version devDependency Status

functional.js is a functional JavaScript library.

It facilitates currying and point-free / tacit programming, with optional lambda expressions.

Documentation

Visit functionaljs.com for the full documentation including curry, each, map, reduce, fold, apply, every, any, select, pluck, toArray, first, last, best, partition, group, while and more.

Curry function example

var add = fjs.curry(function(a, b) {
    return a + b;
});

var add3 = add(3);

add(1, 2, 3); // => 6
add3(1, 2, 3, 4, 5); // => 18

Curry expression example

var add = fjs.curry("a, b => a + b");

var add3 = add(3);

add(1, 2, 3); // => 6
add3(1, 2, 3, 4, 5); // => 18

Curry ES6 example

const add = fjs.curry((a, b) => a + b);

const add3 = add(3);

add(1, 2, 3); // => 6
add3(1, 2, 3, 4, 5); // => 18

Real world example

var converter = fjs.curry(function(rate, symbol, input) {
    var output = input * rate;
    return symbol + output.toFixed(2);
});

var poundsToUSD = converter(1.52, "$");
var poundsToEUR = converter(1.27, "");

poundsToUSD(100); // => "$152.00"
poundsToEUR(50); // => "€63.50"

License

MIT License

You can’t perform that action at this time.