highland
highland copied to clipboard
[feature request] object-path -like pluck
Object path has an incredibly useful way of retrieving data from complex object structures.
https://github.com/mariocasciaro/object-path
Would love to see an API like this:
_([{ foo: { bar: [1,2,3] }}])
.pluck('foo.bar.0')
.doto(_.log) // 1
If ObjectPath's arguments were in the right order and curried you could just use it with map. You can achieve the same thing with Ramda:
var R = require('ramda');
_([{ foo: { bar: [1,2,3] }}])
.map(R.path(['foo', 'bar', '0']))
.doto(_.log) // => 1
Oh neat. Thanks!
Could always use http://highlandjs.org/#flip too.
But I feel like it's useful enough to exist in the core.