From 4c0a3e15999222859d14e4ee1c3b62bffc08a9cf Mon Sep 17 00:00:00 2001 From: Nick Deis <nickjdeis@gmail.com> Date: Tue, 1 Oct 2019 22:51:22 -0400 Subject: [PATCH] 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. --- src/core/utils.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/core/utils.js b/src/core/utils.js index c0146b13..a145f8e6 100644 --- a/src/core/utils.js +++ b/src/core/utils.js @@ -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) { -- GitLab