Re:Ramda – A practical functional library for Javascript
by wldlyinaccurate on Friday November 28, 2014 @06:25PM
(#8672504)
Neither 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;
}
Re:Ramda – A practical functional library for Javascript
by eurleif on Saturday November 29, 2014 @09:57AM
(#8673850)
Note that with statements kill performance, at least in V8. https://github.com/petkaantonov/bluebird/wiki/Optimization-k...
Re:Ramda – A practical functional library for Javascript
by Cyranix on Friday November 28, 2014 @10:56PM
(#8673037)
Destructuring 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)
Re:Ramda – A practical functional library for Javascript
by tracker1 on Monday December 01, 2014 @02:23PM
(#8683065)
I'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.
Re:Ramda – A practical functional library for Javascript
by jtblin on Friday November 28, 2014 @08:33PM
(#8672769)
You could always do something like this:
var R = require('ramda');
for (var fn in R) if (typeof R[fn] === 'function') global[fn] = R[fn];
Re:Ramda – A practical functional library for Javascript
by buzzdecafe on Saturday November 29, 2014 @07:44AM
(#8673642)
> 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
Re:Ramda – A practical functional library for Javascript
by buzzdecafe on Saturday November 29, 2014 @08:05AM
(#8673660)
... also, `propEq` is already in the lib.
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...
over...