These are chat archives for ramda/ramda

20th
Jul 2018
Jason Gretz
@jagretz
Jul 20 2018 12:14
I can't figure out what the utility is but I am trying to use a util similar to has(<object>, <path>) but on an array. In other words, has(<array>) : boolean if it has 1 or more elements.
I saw I can use countBy, but I want the name to be indicative of what I am doing.
Nicolás Fantone
@nfantone
Jul 20 2018 13:44
@jagretz would isEmpty help in your case?
isEmpty([]); // true
isEmpty([1, 2]); // false
I'm having a hard time figuring out an "elegant" to way to deal with the following scenario: a context object containing a bunch of properties, including an array - I need to map elements on that array and extend each object with new properties derived from the original context object
here's a contrived example:
{
   foos: [{ id: 1 }, { id: 2 }],
   details: [{ fooId: 1, bar: true }, { fooId: 2, bar: false }]
}
Nicolás Fantone
@nfantone
Jul 20 2018 13:50
and what I need is iterate through foos and "join" values in details, to obtain a single array such as:
[id: 1, details: { fooId: 1, bar: true } ], [id: 2, details: { fooId: 2, bar: false } ]
Nicolás Fantone
@nfantone
Jul 20 2018 14:08
// This would be the base implementation without ramda
o.foos.map(foo => ({ ...foo, details: o.details.find(d => d.fooId === foo.id) }));
Oliver Weiler
@helpermethod
Jul 20 2018 14:34
Hi, probably stupid question, but why doesn't R.partial accept a varargs as a second parameter, something like: R.partial(fn, arg1, arg2) instead of R.partial(fn, [arg1, arg2])?
Nicolás Fantone
@nfantone
Jul 20 2018 14:47
@helpermethod I'd guess it's because ramda has made a policy/philosophy out of returning and providing fixed arity functions
which make things like composition and writing Haskell notations easier to do and reason with
Oliver Weiler
@helpermethod
Jul 20 2018 14:52
@nfantone OK that makes sense, thank you very much.
Nicolás Fantone
@nfantone
Jul 20 2018 14:55
@helpermethod :ok_hand:
Jason Gretz
@jagretz
Jul 20 2018 15:06
Thanks @nfantone I think that reads well enough
Jason Gretz
@jagretz
Jul 20 2018 15:19
@helpermethod Well partial is for partial application which is different that curry
if you need what you're asking for then use curry instead