-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref(utils): convert memo from class to function #4283
Conversation
@@ -303,7 +303,7 @@ export function walk(key: string, value: any, depth: number = +Infinity, memo: M | |||
const acc = Array.isArray(value) ? [] : {}; | |||
|
|||
// If we already walked that branch, bail out, as it's circular reference | |||
if (memo.memoize(value)) { | |||
if (memo[0](value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taking the reacts hook approach to being minification friendly (return a tuple) 😄
size-limit report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Out of curiosity I wonder though what the impact of using {memoize, unmemoize}: MemoFunc = memoBuilder()
would be instead of m[0]
and m[1]
.
Goes to |
Unnecessary class, we can just store the private state in a closure. It's only being used by one method,
walk
in@sentry/utils
.