Skip to content

Commit efbb726

Browse files
committed
just use a Set
1 parent 06adc59 commit efbb726

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: lib/resolve-external.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function resolveExternal (parser, options) {
4444
* @param {string} path - The full path of `obj`, possibly with a JSON Pointer in the hash
4545
* @param {$Refs} $refs
4646
* @param {$RefParserOptions} options
47-
* @param {WeakMap} seen - Internal.
47+
* @param {Set} seen - Internal.
4848
*
4949
* @returns {Promise[]}
5050
* Returns an array of promises. There will be one promise for each JSON reference in `obj`.
@@ -53,11 +53,11 @@ function resolveExternal (parser, options) {
5353
* then the corresponding promise will internally reference an array of promises.
5454
*/
5555
function crawl (obj, path, $refs, options, seen) {
56-
seen = seen || new WeakMap();
56+
seen = seen || new Set();
5757
let promises = [];
5858

5959
if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj) && !seen.has(obj)) {
60-
seen.set(obj, 1); // Track previously seen objects to avoid infinite recursion
60+
seen.add(obj); // Track previously seen objects to avoid infinite recursion
6161
if ($Ref.isExternal$Ref(obj)) {
6262
promises.push(resolve$Ref(obj, path, $refs, options));
6363
}

0 commit comments

Comments
 (0)