node package manager

getvalue

Getvalue

NPM version NPM downloads Build status Test coverage

Get a nested value from an object by path.

Installation

npm install getvalue --save

Usage

Arguments

  1. object (Object) The object to query
  2. path (Array) The path of the property to get
  3. (Optional) defaultValue (any) The value returned for undefined resolved values

Example

import { get } from 'getvalue'
 
const obj = { a: { b: { c: 10 } } }
 
get(obj, ['a', 'b', 'c']) //=> 10 
get(obj, ['not', 'here']) //=> undefined 
get(obj, ['or', 'here'], 1) //=> 1 

License

Apache 2.0