Skip to content

Instantly share code, notes, and snippets.

@fusepilot
Created May 16, 2015 20:29
Show Gist options
  • Save fusepilot/8b7a5ef1099a2f3ca4e1 to your computer and use it in GitHub Desktop.
Save fusepilot/8b7a5ef1099a2f3ca4e1 to your computer and use it in GitHub Desktop.
remove circular references from jsx object
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