flatten-object
Flattens nested javascript objects into a single level. Enumerates keys that collide.
Usage
npm install flatten-object
> var flattenObject = ;> var nested = foo: 'bar' baz: foo: 'bar';> : foo_0: 'bar' foo_1: 'bar';
> var flattenObject = ;> var nested = foo: 'bar' baz: foo: 'bar';> : foo-0: 'bar' foo-1: 'bar';
API
flattenObject(object, maxDepth, separator)
/**
* Flatten an object down to a optionally specified maximum depth
* @method exports
* @param {object} obj Object to flatten
* @param {integer} [maxDepth=0] Maximum depth to recurse to. Zero is unlimited.
* @param {string} [sep=_] Separator for keys. If you use this, you must specify maxDepth. It's just how javascript is
* @returns {object} flattened object
*/
License
MIT license, Copyright © 2015 Todd Kennedy