Skip to content

Instantly share code, notes, and snippets.

View erodozer's full-sized avatar
🚧
I may be slow to respond between 8am-8pm EST M-F

Nicholas Hydock / ero erodozer

🚧
I may be slow to respond between 8am-8pm EST M-F
View GitHub Profile
@erodozer
erodozer / Object Flatten
Created March 9, 2016 18:00 — forked from penguinboy/Object Flatten
Flatten javascript objects into a single-depth object
/**
* Flattens a json object into a single-dimensional representation
* @param: stripPrefix: boolean
* by default, subobjects will have their property name prefixed to the flattened property name.
* This is done to prevent overwriting of properties with the same name. If this is a non-issue
* for your data type, then feel free to set this to true
* @return: a single dimensional copy of the original object
*/
Object.defineProperty(Object.prototype, 'flatten', {
value: function(stripPrefix) {