Created
September 17, 2013 17:45
-
-
Save adamvr/6597880 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Postorder flatten | |
var flatten = function (obj) { | |
var flat = {}; | |
function flatt (obj) { | |
for (var k in obj) { | |
var v = obj[k]; | |
if ('object' === typeof v) { | |
flatt(v); | |
} else if ('function' === typeof v) { | |
// Ignore | |
} else if (v instanceof Buffer) { | |
// Ignore | |
} else { | |
flat[k] = v; | |
} | |
} | |
} | |
flatt(obj); | |
return flat; | |
}; | |
var a = { | |
b: { | |
c: 'a', | |
b: { | |
c: 'b' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment