From e43a591b6bb92117274020774a33be2cafd1d365 Mon Sep 17 00:00:00 2001 From: sasaplus1 Date: Mon, 13 Jun 2016 21:38:22 +0900 Subject: [PATCH] fixed #10, fixed #11, fixed #12 --- src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index f820a1c0..c21e4184 100644 --- a/src/index.js +++ b/src/index.js @@ -61,6 +61,10 @@ function recursiveCopy(target, customizer, clone, visited, reference) { value = target[key]; index = indexOf(visited, value); + resultCopy = undefined; + result = undefined; + ref = undefined; + if (index === -1) { resultCopy = copy(value, customizer); result = (resultCopy !== null) ? resultCopy : value; @@ -68,8 +72,6 @@ function recursiveCopy(target, customizer, clone, visited, reference) { if (value !== null && /^(?:function|object)$/.test(typeof value)) { visited.push(value); reference.push(result); - } else { - ref = result; } } else { // circular reference