get-from-object-path

0.0.1 • Public • Published

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

Package Sidebar

Install

npm i get-from-object-path

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • hauptrolle