2 ms·
Interesting library... I haven't dug in, but a cursory glance suggests this could just about replace lodash/underscore ... The build-in currying of most of the
by tracker1 12y ago
Interesting library... I haven't dug in, but a cursory glance suggests this could just about replace lodash/underscore ...
The build-in currying of most of the methods is pretty cool as well.
For me, it's difficult to break away from using the built-ins such as Array.prototype.map/reduce etc in favor of more functional variants. The same goes for Immutables... I see the value in adjusting the code in terms of explicitness, it's still hard to get used to.
--edit
Is there something built-in to apply all the functions into the current global? I'd rather not have to do...
var R = require('ramda');
var propEq = R.use(R.pipe).over(R.get, R.eq);
over...
require('ramda').assignTo(this);
var propEq = use(pipe).over(get, eq);
- wldlyinaccurate 12y agoNeither are very elegant, but you could always do something like: var R = require('ramda'); with (R) { var propEq = use(pipe).over(get, eq); } ...Or even: var R = require('ramda'); for (var f in R) { window[f] = R.f; }
- eurleif 12y agoNote that with statements kill performance, at least in V8. https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#2-unsupported-syntax https://github.com/petkaantonov/bluebird/wiki/Optimization-k...
- jtblin 12y agoYou could always do something like this: var R = require('ramda'); for (var fn in R) if (typeof R[fn] === 'function') global[fn] = R[fn];
- Cyranix 12y agoDestructuring assignment in CoffeeScript helps with this (not globals, I suppose, but well-scoped locals): { use, pipe, get, eq } = R propEq = use(pipe).over(get, eq)
- tracker1 12y agoI'm currently targetting Node 0.11 --harmony for active development, which also has destructuring. It's an option I hadn't considered... I haven't adopted all the ES6 bits, such as es6-style modules in favor of keeping with built-in node patterns, but have been adopting some bits here and there.
- buzzdecafe 12y ago> Is there something built-in to apply all the functions into the current global? yes: `R.installTo(global)` will pull all of the ramda functions on the `global` object
- buzzdecafe 12y ago... also, `propEq` is already in the lib.