Skip to content

Commit

Permalink
Move getCircularReplacer inside abort
Browse files Browse the repository at this point in the history
  • Loading branch information
i404788 authored May 23, 2019
1 parent 3487315 commit 81d77fa
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 = '';
Expand Down

0 comments on commit 81d77fa

Please sign in to comment.