From 1c5d775d3003ec3d16d90c0c754c3a7dd9509a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Trob=C3=A4ck?= Date: Thu, 14 Dec 2023 10:24:26 +0100 Subject: [PATCH] fix: rename caches to commonCaches Renames the `caches` variable because it interferes with the global browser API. Fixes #492 --- src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 08366c7..f1adb4e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -131,7 +131,7 @@ export interface OptionsWithCacheInstance< cache: CommonCache, Entry, NoInfer>>; }; -const caches = new Set>(); +const commonCaches = new Set>(); export function wrap< TArgs extends any[], @@ -179,14 +179,14 @@ export function wrap< // since we just finished computing its value. cache.set(key, entry); - caches.add(cache); + commonCaches.add(cache); // Clean up any excess entries in the cache, but only if there is no // active parent entry, meaning we're not in the middle of a larger // computation that might be flummoxed by the cleaning. if (! parentEntrySlot.hasValue()) { - caches.forEach(cache => cache.clean()); - caches.clear(); + commonCaches.forEach(cache => cache.clean()); + commonCaches.clear(); } return value;