get-from-object-path
v0.0.1
Published
Get a value from an object path
Downloads
1
Maintainers
Readme
get-from-object-path
Get the value of an object key by path
Usage
const getFromObjectPath = require('getFromObjectPath');
const obj = {
foo: 'Foo',
foz: {
bar: 'bar',
},
bar: [
{
baz: 'baz',
},
{
bar: 'bar',
},
],
};
getFromObjectPath(obj, 'foo'); // => Foo
getFromObjectPath(obj, 'foz.bar'); // => bar
getFromObjectPath(obj, 'bar[0].baz') // => baz