This Meteor package is a wrapper for Hughsk Flat node package: https://github.com/hughsk/flat Take a nested Javascript object and flatten it, or unflatten an object with delimited keys.
Flattens the object - it'll return an object one level deep, regardless of how nested the original object was:
flatten({
key1: {
keyA: 'valueI'
},
key2: {
keyB: 'valueII'
},
key3: { a: { b: { c: 2 } } }
})
// {
// 'key1.keyA': 'valueI',
// 'key2.keyB': 'valueII',
// 'key3.a.b.c': 2
// }
Flattening is reversible too, you can call flatten.unflatten()
on an object:
unflatten({
'three.levels.deep': 42,
'three.levels': {
nested: true
}
})
// {
// three: {
// levels: {
// deep: 42,
// nested: true
// }
// }
// }
You can find documentation, options and more about Flat node package here:
- Flat GIT: https://github.com/hughsk/flat
- Pascal Richier @pascalrichier
- Add testing
MIT