Created
January 18, 2018 18:19
-
-
Save syzer/b717ecc4b656f04df16333742daf9a94 to your computer and use it in GitHub Desktop.
getting complex objects can be hard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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