lodash with auto-curried iteratee-first data-last methods.
Using bower:
$ bower i lodash-fp#0.10.2
In browsers:
<script src="dist/lodash-fp.js"></script>
Using npm:
$ {sudo -H} npm i -g npm
$ npm i --save lodash-fp
In Node.js/io.js:
var _ = require('lodash-fp');
var items = [
{ 'value': _.constant(['a', 'b']) },
{ 'value': _.constant(['b', 'c']) }
];
var getValues = _.flow(
_.map(_.result('value')),
_.flatten,
_.uniq
);
getValues(items);
// => ['a', 'b', 'c']
// shortcut fusion is supported too
var combined = _.flow(
_.map(function(value) { console.log('map'); return value * value; }),
_.filter(function(value) { console.log('filter'); return value % 2 == 0; }),
_.take(2)
);
combined(_.range(0, 200));
// logs map, filter, map, filter, map, filter
// => [0, 4]
See the package source for more details.
Note:
Don’t assign values to the special variable _
when in the REPL.
Install n_ for a REPL that includes lodash by default.