New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

safe-get-plus

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

safe-get-plus

Securely get attributes from objects and can provide default value

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

safe-get-plus

Install

npm install safe-get-plus --save

Start

const safeGet = require('safe-get-plus')

const response = {
  data: {
    user: {
      name: 'eryou',
      age: 18,
      friends: ['xiaoming', 'xiaohong'],
    },
    list: [1, 2, 3],
  }
}

const data = safeGet(response, 'data.user.friends', []) // ['xiaoming', 'xiaohong']

const data = safeGet(response, 'data.user.address', '') // ''

API

const safeGet = require('safe-get-plus')
safeGet(Object, [Property dot string], [Default Value])

Arguments

Object: The object to be valued.
[Property dot string]: A string that gets a value with a point.
[Default Value]|null: Default value when no value is taken.

FAQs

Package last updated on 19 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts