-
Notifications
You must be signed in to change notification settings - Fork 29.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
lib: use ObjectHasOwn
instead of alternatives
#54710
Conversation
Review requested:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #54710 +/- ##
==========================================
- Coverage 87.61% 87.60% -0.02%
==========================================
Files 650 650
Lines 182834 182834
Branches 35382 35389 +7
==========================================
- Hits 160194 160175 -19
- Misses 15925 15929 +4
- Partials 6715 6730 +15
|
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.
lgtm
@@ -330,7 +330,7 @@ declare namespace primordials { | |||
export const ObjectEntries: typeof Object.entries | |||
export const ObjectFromEntries: typeof Object.fromEntries | |||
export const ObjectValues: typeof Object.values | |||
export const ObjectPrototypeHasOwnProperty: UncurryThis<typeof Object.prototype.hasOwnProperty> | |||
export const ObjectHasOwn: typeof Object.hasOwn |
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.
Not sure about this change, both technically exist. In any case, ObjectHasOwn
should ideally appear before ObjectValues
, in the same order they are listed in the spec.
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.
ObjectPrototypeHasOwnProperty will likely have an inherent slowdown due to the bind in UncurryThis, so preferring ObjectHasOwn makes sense to me
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'm talking about this specific change, the one in typings/primordials.d.ts
, not about the whole PR.
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 was my intention.
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 replaced to discourage people from reusing it.
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.
In any case, ObjectHasOwn
should ideally appear before ObjectValues
, in the same order they are listed in the spec.
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.
lgtm
In V8
|
oof, that's very sad for v8. |
I'm closing due to @joyeecheung's comment. Thank you all for reviewing. |
Let's use
ObjectHasOwn
instead of the alternative:ObjectPrototypeHasOwnProperty