1.2.7 • Published 6 years ago

safe-nestled-element v1.2.7

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

GNU nano 2.0.6 File: readme.md Modified

Installation

using NPM:

install npm i --save safe-nestled-element
var safe = require ('safe-nestled-element')

Useful function for retrieving elements from foreign objects/arrays.

If an element doesn't exist it will return null. This is particularly useful if you're trying to access an element in a response object that may be undefined, ie. JSON from Spotify.

Example:

var targetObj = { a: { b: 'Value One', { c: 'Target Value' } } }

console.log (safe (targetObj , 'a.b[1].c' ))

will return 'Target Value' console.log (safe (targetObj , 'a.b1.d' ))

will return null

where

console.log (targetObj.a.b[1].d)

would return 'undefined'

1.2.7

6 years ago

1.2.5

6 years ago

1.2.3

6 years ago

1.2.1

6 years ago

1.0.12

6 years ago

1.0.10

6 years ago

1.0.8

6 years ago

1.0.6

6 years ago

1.0.4

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago