Skip to content

Commit ceaf57e

Browse files
committed
refer to memoization methods by name rather than number
1 parent 4110322 commit ceaf57e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/utils/src/memo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
22
/* eslint-disable @typescript-eslint/no-explicit-any */
33

4-
export type MemoFunc = [(obj: any) => boolean, (obj: any) => void];
4+
export type MemoFunc = { memoize: (obj: any) => boolean; unmemoize: (obj: any) => void };
55

66
/**
77
* Helper to decycle json objects
@@ -40,5 +40,5 @@ export function memoBuilder(): MemoFunc {
4040
}
4141
}
4242
}
43-
return [memoize, unmemoize];
43+
return { memoize, unmemoize };
4444
}

packages/utils/src/object.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ export function walk(key: string, value: any, depth: number = +Infinity, memo: M
338338
const acc: { [key: string]: any } = Array.isArray(value) ? [] : {};
339339

340340
// If we already walked that branch, bail out, as it's circular reference
341-
if (memo[0](value)) {
341+
if (memo.memoize(value)) {
342342
return '[Circular ~]';
343343
}
344344

@@ -354,7 +354,7 @@ export function walk(key: string, value: any, depth: number = +Infinity, memo: M
354354
}
355355

356356
// Once walked through all the branches, remove the parent from memo storage
357-
memo[1](value);
357+
memo.unmemoize(value);
358358

359359
// Return accumulated values
360360
return acc;

0 commit comments

Comments
 (0)