squash-object
v1.0.1
Published
Flattens and expands objects
Downloads
3
Readme
squash-object
Flattens and expands objects
Installation
$ npm i --save squash-object
Usage
const squash = require('./index')
let obj = {
a: 'a',
b: {
c: 'c',
d: 'd',
e: {
f: 'f'
}
}
}
console.log(obj) // { a: 'a', b: { c: 'c', d: 'd', e: { f: 'f' } } }
obj = squash.flatten(obj)
console.log(obj) // { a: 'a', 'b.c': 'c', 'b.d': 'd', 'b.e.f': 'f' }
obj = squash.expand(obj)
console.log(obj) // { a: 'a', b: { c: 'c', d: 'd', e: { f: 'f' } } }