Created
May 16, 2015 20:29
-
-
Save fusepilot/8b7a5ef1099a2f3ca4e1 to your computer and use it in GitHub Desktop.
remove circular references from jsx object
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
function(data, out) { | |
var e, k, results; | |
if (out == null) { | |
out = {}; | |
} | |
if (!data) { | |
return void 0; | |
} | |
if (typeof data === 'object') { | |
results = []; | |
for (k in data) { | |
if (k === "containingComp" || k === "parentFolder" || k === "source") { | |
if (data[k]) { | |
out[k] = data[k].id; | |
} | |
continue; | |
} | |
if (k === "parentProperty") { | |
if (!_.isNull(data[k])) { | |
out[k] = data[k].name; | |
} | |
continue; | |
} | |
if (k === "lightType") { | |
continue; | |
} | |
if (k === "maxValue" || k === "minValue") { | |
continue; | |
} | |
if (k === "separationDimension" || k === "separationLeader") { | |
continue; | |
} | |
try { | |
results.push(out[k] = prepObjectForStringify(data[k])); | |
} catch (_error) { | |
e = _error; | |
} | |
} | |
return results; | |
} else { | |
return data; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment