0.0.1 • Published 2 years ago
zget v0.0.1
zget = safe get
a tiny and safety function to accessing deeply nested JS object property.
This is one of must-have function that I need to use in every js projects, instead of installing lodash, ramda or any other utility library
install
npm i --save zget
// or
yarn add zget
usage
import zget from "zget"
zget(object, path)
var object = { 'a': [{ 'b': { 'c': 3 } }] };
zget(object, 'a.0.b.c');
// => 3
zget(object, ['a', '0', 'b', 'c']);
// => 3
zget(object, 'a.c');
// => 'undefined'