1.2.7 • Published 8 years ago

safe-nestled-element v1.2.7

Weekly downloads
3
License
ISC
Repository
github
Last release
8 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

8 years ago

1.2.5

8 years ago

1.2.3

8 years ago

1.2.1

8 years ago

1.0.12

8 years ago

1.0.10

8 years ago

1.0.8

8 years ago

1.0.6

8 years ago

1.0.4

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago