flatten-object-strict
v1.0.1
Published
Flattens a nested object. Throws on collisions.
Downloads
62
Readme
flatten-object-strict
Flattens a nested object. Throws on collisions.
Install
$ npm install --save flatten-object-strict
Usage
'use strict';
var flattenObjectStrict = require('flatten-object-strict');
console.log(flattenObjectStrict({
foo: {
one: 1,
two: 2
},
bar: {
three: 3,
four: 4
}
}))
// { one: 1, two: 2, three: 3, four: 4 }
console.log(flattenObjectStrict({
foo: {
dup1: 1
},
bar: {
dup1: 13,
dup2: 281
},
baz: {
dup2: 38
}
}));
// Error: Duplicate keys found: {
// "dup1": [
// ".foo.dup1",
// ".bar.dup1"
// ],
// "dup2": [
// ".bar.dup2",
// ".baz.dup2"
// ]
// }
License
MIT © Andrew Morris