npm

Need private packages and team management tools?Check out npm Orgs. »

safeget-json

1.0.0 • Public • Published

safeget 🛡

V1.0

Build Status

Super simple NPM module which allows to safely unwrap complex JSON files and provide default value in case of failure

Build Setup

In order to add safeget to your project, run:

npm i safeget-json

You can use safeget by passing JSON as a result of an anonymous function + default value as follows:

const safeget = require("safeget-json")
 
const really = {
  what: {
    can: {
      go: {
        wrong: '?'
      }
    }
  }
}
 
const core = safeget(() => really.what.can.go.wrong, 'stub!')

If JSON contains required node, it will be retrieved. In case node doesn't exist, defauls value ('stub!' in example) will be assigned instead.

Feel free to contribute!

install

npm i safeget-json

Downloadsweekly downloads

3

version

1.0.0

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability