Skip to content

Commit

Permalink
refactor: seen WeakSet (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi authored May 2, 2024
1 parent 934efaa commit b152325
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/memoize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const trackMemoOriginalObjSet = new WeakSet<object>();

const isObject = (x: unknown): x is object => typeof x === 'object' && x !== null;

const untrack = <T>(x: T, seen: Set<T>): T => {
const untrack = <T>(x: T, seen: WeakSet<object>): T => {
if (!isObject(x)) return x;
const originalObj = getUntracked(x);
if (originalObj !== null) {
Expand Down Expand Up @@ -131,7 +131,7 @@ export function memoize<Obj extends object, Result>(
}
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,
Expand Down

0 comments on commit b152325

Please sign in to comment.