given the following data structure
var categories = [
{_id: 1, order: 0, ancestors: []},
{_id: 2, order: 0, ancestors: [1]},
{_id: 3, order: 0, ancestors: [1]},
{_id: 4, order: 0, ancestors: []},
{_id: 5, order: 0, ancestors: [4]},
]
and the functions
var byLevel = R.curry((level) => R.filter(o => o.ancestors.length == level))
var levelZero = byLevel(0);
I'd like to be able to call both of these like so :-
console.log(byLevel(0,categories));
console.log(levelZero(categories));
and get the same result (an array of two categories with ids 1 and 4)
however byLevel returns a function. I can call it like
console.log(byLevel(0)(categories));
and it does what I want. But if I write byLevel like :-
var byLevel = R.curry((level, l) => R.filter(o => o.ancestors.length == level, l))
then
console.log(byLevel(0,categories));
works fine and curries fine. However, it seems not as "clean".
Question
Is there a "Ramda" way to make it so I can define the function so that I can do f(x,y)
instead of f(x)(y)