Skip to content

Instantly share code, notes, and snippets.

@syzer
Created January 18, 2018 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syzer/b717ecc4b656f04df16333742daf9a94 to your computer and use it in GitHub Desktop.
Save syzer/b717ecc4b656f04df16333742daf9a94 to your computer and use it in GitHub Desktop.
getting complex objects can be hard
const dotPath = R.useWith(R.path, [R.split('.')])
const propsDotPath = R.useWith(R.ap, [R.map(dotPath), R.of])
var obj = {
a: { b: { c: 42 } },
d: 2
}
propsDotPath(['a.b.c', 'd'], obj)
// => [ 42, 2 ]
var obj = {
a: { b: 5 },
d: 2
}
propsDotPath(['a.b.c', 'd'], obj)
// => [undefined, 2]
// maybe rejectFalsy ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment