@noname-land/get

1.0.0 • Public • Published

@noname-land/get

npm

Returns the value in a nested object, by string-sequence of keys. Returns undefined if the key is not present, or the default value if supplied.

Installation

npm i --save @noname-land/get

Usage

import get from '@noname-land/get';

const obj = {
  a: 1,
  b: 2,
  c: {
    d: 1,
    e: 2,
    f: {
      g: 1,
      h: 2,
      i: 3,
    },
  },
};

console.log(get(obj, 'c.f.i')); // 3
console.log(get(obj, 'c.f.i.j')); // undefined
console.log(get(obj, 'c.f.i.j', 1)); // 1

Readme

Keywords

none

Package Sidebar

Install

npm i @noname-land/get

Weekly Downloads

0

Version

1.0.0

License

none

Unpacked Size

1.47 kB

Total Files

4

Last publish

Collaborators

  • igoradamenko