Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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);


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;
    }


Note that with statements kill performance, at least in V8. https://github.com/petkaantonov/bluebird/wiki/Optimization-k...


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)


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.


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];


> 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


... also, `propEq` is already in the lib.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: