Skip to content

Instantly share code, notes, and snippets.

@adamvr
Created September 17, 2013 17:45
Show Gist options
  • Save adamvr/6597880 to your computer and use it in GitHub Desktop.
Save adamvr/6597880 to your computer and use it in GitHub Desktop.
// 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