get-property-value
TypeScript icon, indicating that this package has built-in type declarations

4.0.3 • Public • Published

get-property-value

get the property value from a nested object by using a dot path a.b.c

Build StatusCode Coverage 100%ISC LicenseNodeJS

API

var getPropValue = require('get-property-value')

getPropValue({}, 'path')

Usage

var getPropValue = require('get-property-value')

var obj = {a: {b: 1}, c: {d: {f: 'hello'}}}

var fValue = getPropertyValue(obj, 'c.d.f')// hello
var aValue = getPropertyValue(obj, 'a')// {b: 1}

var propNotExist = getPropertyValue(obj, 'c.d.g') // undefined

var badObject = getPropertyValue('hello', 'c.d.g') // hello

var badPath = getPropertyValue({a: 1})// {a: 1}

ISC License (ISC)

Package Sidebar

Install

npm i get-property-value

Weekly Downloads

882

Version

4.0.3

License

ISC

Unpacked Size

4.01 kB

Total Files

5

Last publish

Collaborators

  • quim