Skip to content
Snippets Groups Projects
Commit 4c0a3e15 authored by Nick Deis's avatar Nick Deis Committed by Alvaro Cabrera Durán
Browse files

Updated clone to be stackless (#527)

Currently this function is causing stack errors. I've tried extending the stack but that just causes memory to run out. I think this is due to objects with repetitive references.
parent 91c08322
Branches
Tags
No related merge requests found
......@@ -193,18 +193,7 @@ function merge(a, b) {
}
function clone(obj) {
if (!obj || typeof obj !== 'object') {
return obj;
}
if (Array.isArray(obj)) {
return obj.map(x => clone(x));
}
return Object.keys(obj).reduce((prev, cur) => {
prev[cur] = clone(obj[cur]);
return prev;
}, {});
return JSON.parse(JSON.stringify(obj));
}
function short(schema) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment