functional.js
Version:
A functional JavaScript library that facilitates currying and point-free programming, with optional lambda expressions.
66 lines (42 loc) • 1.85 kB
Markdown
<img align="right" src="http://functionaljs.com/css/images/logo@2x.png">
**functional.js is a functional JavaScript library.**
It facilitates [currying](http://en.wikipedia.org/wiki/Currying) and [point-free / tacit](http://en.wikipedia.org/wiki/Tacit_programming) programming, with optional lambda expressions.
Visit [functionaljs.com](http://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.
```javascript
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
```
```javascript
var add = fjs.curry("a, b => a + b");
var add3 = add(3);
add(1, 2, 3); // => 6
add3(1, 2, 3, 4, 5); // => 18
```
```javascript
const add = fjs.curry((a, b) => a + b);
const add3 = add(3);
add(1, 2, 3); // => 6
add3(1, 2, 3, 4, 5); // => 18
```
```javascript
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); // => "€63.50"
poundsToEUR(50); // => "$152.00"
```
[](http://ilee.mit-license.org)