diff --git a/lib/resolve-external.js b/lib/resolve-external.js index 848525c8..0d0a8648 100644 --- a/lib/resolve-external.js +++ b/lib/resolve-external.js @@ -44,7 +44,7 @@ function resolveExternal (parser, options) { * @param {string} path - The full path of `obj`, possibly with a JSON Pointer in the hash * @param {$Refs} $refs * @param {$RefParserOptions} options - * @param {WeakMap} seen - Internal. + * @param {Set} seen - Internal. * * @returns {Promise[]} * Returns an array of promises. There will be one promise for each JSON reference in `obj`. @@ -53,11 +53,11 @@ function resolveExternal (parser, options) { * then the corresponding promise will internally reference an array of promises. */ function crawl (obj, path, $refs, options, seen) { - seen = seen || new WeakMap(); + seen = seen || new Set(); let promises = []; if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj) && !seen.has(obj)) { - seen.set(obj, 1); // Track previously seen objects to avoid infinite recursion + seen.add(obj); // Track previously seen objects to avoid infinite recursion if ($Ref.isExternal$Ref(obj)) { promises.push(resolve$Ref(obj, path, $refs, options)); }