1.0.0 • Published 5 years ago

@noname-land/get v1.0.0

Weekly downloads
-
License
-
Repository
github
Last release
5 years ago

@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