flatten-object-strict

1.0.1 • Public • Published

flatten-object-strict NPM version Build Status Dependency Status Coverage Status

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

Readme

Keywords

Package Sidebar

Install

npm i flatten-object-strict

Weekly Downloads

54

Version

1.0.1

License

MIT

Last publish

Collaborators

  • voltrevo