bubble-gum-get
Get a property from a nested object or a nested array using an array path
bubble-gum-get
is part of bubble-gum-tools, check this here
Install
You can install bubble-gum-get using npm.
npm install --save bubble-gum-get
API Reference
bubble-gum-get
*
⏏
module.exports(target, path, [defaultValue]) ⇒ It gets a property from a nested object or a nested array using an array path
Kind: Exported function
Returns: *
- propertyValue
Param | Type | Description |
---|---|---|
target | Object | Array |
Target object or target array |
path | Array |
Path to property |
[defaultValue] | * |
Value to be returned in case the property does not exist |
Example
const get = ; const target = root: foo: 'bar' arr: 'baz' ; // Working with nested objects const bar = ; console; // => 'bar' // Working with nested arrays const baz = ; console; // => 'baz' // Set a default const defaultVal = ; console; // => 'default'
License
MIT @ Nicolas Quiceno