Flatten nested javascript objects into a single-depth object.
$ npm install flatify-obj
const flatifyObject = require('flatify-obj');
flatifyObject({foo: {bar: {unicorn: '🦄'}}})
//=> { 'foo.bar.unicorn': '🦄' }
flatifyObject({foo: {unicorn: '🦄'}, bar: 'unicorn'}, {onlyLeaves: true});
//=> {unicorn: '🦄', bar: 'unicorn'}
Type: object
Object to flatten
Type: boolean
Default: false
Removes the parent property and only returns the leaf nodes of the object
MIT © Rocktim Saikia