0.3.0 • Published 4 years ago

obj-safe v0.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

Returns the value of a nested object, an included parameter, or undefined

This is not necessary when using ECMAScript 2020 or later or TypeScript 3.7 or later which support optional chaining.

duckling?.name?.maiden

const objSafe = require('objSafe');

const duckling = {
    name: {
        current: 'Quackers'
    }
 };

objSafe (duckling.name.maiden); // -> undefined
objSafe (() => duckling.feathers.color, 'white'); // -> 'white'
objSafe (duckling.name.current, 'Arnold'); // -> 'Quackers'

from (StackOverflow answer)https://stackoverflow.com/questions/14782232/how-to-avoid-cannot-read-property-of-undefined-errors

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago