Matt at Keyboard Writes Code

A blog about software development, technology and other things that interest me

When.js Vs Ramda

May 31, 2015 — Matt Forrester

Something unfortunate happened to me over the weekend... I was writing code using the great Ramda, there was promises going on and the code was wonderful... Then along came the awesome When.js to solve my more complicated future based problems but this made me write code like the following:

return, sittings),
    whenGuard(whenGuard.n(1), getUsers)

This was enough to make me cry. It's not that I don't love both of these tools but the fact that Ramda takes it's arguments in the proper way, what_to_map_over) (because it does currying) while when.js does the more javascript centric way of, mapping_function) makes absolutely horrible code!

So I'm sold on Ramda already, it's a lot nicer to work with than other libraries though I do appreciate them existing because at least they have made some people think in different ways than they used to. Still flip flopping of parameter order in my code has to be stopped right now.

While thinking about this I realised that I was only using when.all, (always with a guard of 1) and the standard promise functionality from when.js. The guard of 1 is a really important point, this is essentially a limit on concurrency, saying only do one asynchronous operation at once. So Promise.all I already have if I switch to Node v0.11 or polyfill it later so all I need to do is hack up a sequential promise mapper and I'll have a much lighter set of code...

So I did, you can get it at GitHub or via npm.