From efbb7269568b8511f1e5c99a67349e16c76fea62 Mon Sep 17 00:00:00 2001 From: Cody Greene Date: Tue, 18 May 2021 11:25:20 -0700 Subject: [PATCH] just use a Set --- lib/resolve-external.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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)); }