Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there something similar to lodash _.toArray for ramda.js?

I want to stop using lodash.js and switch to ramda.js but I don't see any function like _.toArray() for objects, is there something like this in ramda that I should compose or should I continue using lodash for these functions (and possibly more cases that I have not run into yet.)

For example In lodash if you have an Object like :

{"key1": {"inner": "val"}, "key2" : {"inner": "val"}}

you can convert it to an array like this:

[{"inner": "val"}, {"inner": "val"}]

using the function _.toArray()

like image 655
simplesthing Avatar asked May 08 '15 18:05

simplesthing


1 Answers

Well, Ramda has values, which seems to be what you're looking for:

var obj = {"key1": {"inner": "val"}, "key2" : {"inner": "val"}};
R.values(obj); //=> [{"inner": "val"}, {"inner": "val"}]

But it's pretty unclear from the lodash documentation, what kinds of values _.toArray function accepts, so this might not be a complete replacement.

like image 121
Scott Sauyet Avatar answered Sep 29 '22 21:09

Scott Sauyet