-
-
Notifications
You must be signed in to change notification settings - Fork 7.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
Improve stripProtoKeys performance, especially for TypedArray #9742
Improve stripProtoKeys performance, especially for TypedArray #9742
Conversation
fcd6fc1
to
2cca33a
Compare
b2ea591
to
62d2f6d
Compare
Pull Request Test Coverage Report for Build 29996fd0-df63-435a-96f3-db353cf09d52
💛 - Coveralls |
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.
can you please run npm run format
@@ -190,12 +191,20 @@ export class ValidationPipe implements PipeTransform<any> { | |||
return isNil(value) ? {} : value; | |||
} | |||
|
|||
protected stripProtoKeys(value: Record<string, any>) { | |||
protected stripProtoKeys(value: any) { | |||
if (value == null || typeof value !== 'object' || types.isTypedArray(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.
I guess
if (value == null || typeof value !== 'object' || types.isTypedArray(value)) { | |
if (!value || !isObject(value) || types.isTypedArray(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.
This causes a typescript compilation error because isObject
is a type guard and Property '__proto__' does not exist on type 'object'
I would suggest just leaving as-is?
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.
oh, it's fine then
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.
Great, I think this should be good to merge then 🤞
62d2f6d
to
f445f23
Compare
LGTM |
Thanks all, appreciate your work 👍 |
Fixes 9708
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: 9708
What is the new behavior?
Does not waste cycles on iterating through typed arrays, or allocating keys arrays.
Does this PR introduce a breaking change?
Other information