These are chat archives for ramda/ramda

May 2018
May 26 2018 14:54
Hi, all I'm trying to obtaine object with distance beetwen API directions in TRY RAMDA evrything is clear but in typescript I have an error TypeError: Cannot read property 'fantasy-land/map' of undefined. Typescript: const pathToLegs = R.path(["json", "json", "routes"]);
R.compose(R.pluck('value'), R.pluck('distance'), R.mergeAll, R.pluck("legs"))(pathToLegs(geoJSON))
pls Need advice becauce I rewrite it without and it does not helped
distance = R.reduce(R.add, "0", R.compose(R.flatten, getValue("value"), getValue("distance"), R.pluck("legs"))(pathToLegs(geoJSON))); - also provide an error
const getValue = (value: string) =>;
Stephen Niemans
May 26 2018 17:44
Hi, you can format code blocks by putting it between ``` at the beginning and end. It might make your snippets easier to follow for people wanting to help :)
Brad Compton (he/him)
May 26 2018 20:14
pluck uses map internally (pluck(x) === map(prop(x))) so that's where your error is coming from. It looks like at some point your object is missing the property you are attempting to pluck over. If you don't want to validate the object before processing I would suggest using functions like propOr and defaultTo to make sure you're always able to apply your mappings.