Skip to content

Commit

Permalink
patch: modify unreliable references
Browse files Browse the repository at this point in the history
  • Loading branch information
liaokunhua committed Dec 5, 2021
1 parent 4d81e9c commit 07c3758
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/stringify.js
Expand Up @@ -56,7 +56,7 @@ var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
|| typeof v === 'bigint';
};

var scSym = Object.create(null);
var sentinel = {};

var stringify = function stringify(
object,
Expand All @@ -80,7 +80,7 @@ var stringify = function stringify(
var tmpSc = sideChannel;
var step = 0;
var findFlag = false;
while ((tmpSc = tmpSc.get(scSym)) !== undefined && !findFlag) {
while ((tmpSc = tmpSc.get(sentinel)) !== undefined && !findFlag) {
// Where object last appeared in the ref tree
var pos = tmpSc.get(object);
step += 1;
Expand All @@ -91,7 +91,7 @@ var stringify = function stringify(
findFlag = true; // Break while
}
}
if (tmpSc.get(scSym) === undefined) {
if (tmpSc.get(sentinel) === undefined) {
step = 0;
}
}
Expand Down Expand Up @@ -164,7 +164,7 @@ var stringify = function stringify(

sideChannel.set(object, step);
var valueSideChannel = getSideChannel();
valueSideChannel.set(scSym, sideChannel);
valueSideChannel.set(sentinel, sideChannel);
pushToArray(values, stringify(
value,
keyPrefix,
Expand Down

0 comments on commit 07c3758

Please sign in to comment.