@monsterbilligt/deep-tinker
v0.2.4
Published
A few tools to get, set, and flatten deep object properties
Downloads
7
Readme
deep-tinker
A few tools to get, set and flatten deep object properties in Javascript.
Install
npm i @monsterbilligt/deep-tinker
Usage
Generally, do the following:
import deep from '@monsterbilligt/deep-tinker'
deep.getDeep(obj, path)
deep.setDeep(obj, path, value)
deep.flatten(obj)
Example:
const obj = {
foo: [
{
bar: 'baz'
}
]
}
const nextObj = deep.setDeep(obj, 'foo[0].bar', 'foo')
console.log(nextObj)
/*
Logs:
{
foo: [
{
bar: 'foo'
}
]
}
*/