0.0.1 • Published 7 years ago

get-from-object-path v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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