From 400b61cdec3ddd3797cfa69b09145483cfe0fa6f Mon Sep 17 00:00:00 2001 From: daishi Date: Thu, 2 May 2024 11:36:25 +0900 Subject: [PATCH] refactor: seen WeakSet --- src/memoize.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/memoize.ts b/src/memoize.ts index f535584..1d729e4 100644 --- a/src/memoize.ts +++ b/src/memoize.ts @@ -30,7 +30,7 @@ const trackMemoOriginalObjSet = new WeakSet(); const isObject = (x: unknown): x is object => typeof x === 'object' && x !== null; -const untrack = (x: T, seen: Set): T => { +const untrack = (x: T, seen: WeakSet): T => { if (!isObject(x)) return x; const originalObj = getUntracked(x); if (originalObj !== null) { @@ -131,7 +131,7 @@ export function memoize( } const affected: Affected = new WeakMap(); const proxy = createProxy(obj, affected, undefined, targetCache); - const result = untrack(fn(proxy), new Set()); + const result = untrack(fn(proxy), new WeakSet()); touchAffected(obj, obj, affected); const entry: Entry = { [OBJ_PROPERTY]: obj,