From 81d77fa1ef2002608b56c258bc4a2448ad52a31c Mon Sep 17 00:00:00 2001 From: i404788 <50617709+i404788@users.noreply.github.com> Date: Thu, 23 May 2019 12:46:11 +0100 Subject: [PATCH] Move getCircularReplacer inside abort --- src/postamble.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/postamble.js b/src/postamble.js index 82cba621f7659..dd1ccd09d5e81 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -397,19 +397,6 @@ function exit(status, implicit) { Module['quit'](status, new ExitStatus(status)); } -function getCircularReplacer() { - var seen = new WeakSet(); - return function (key, value) { - if (typeof value === "object" && value !== null) { - if (seen.has(value)) { - return "[Circular]"; - } - seen.add(value); - } - return value; - }; -}; - var abortDecorators = []; function abort(what) { @@ -423,6 +410,19 @@ function abort(what) { if (what !== undefined) { out(what); err(what); + + function getCircularReplacer() { + var seen = new WeakSet(); + return function (key, value) { + if (typeof value === "object" && value !== null) { + if (seen.has(value)) { + return "[Circular]"; + } + seen.add(value); + } + return value; + }; + }; what = JSON.stringify(what, getCircularReplacer()) } else { what = '';