Skip to content

fix(ext/node): use primordials in ext/node/polyfills/internal_binding/util.ts #30014

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jbronder
Copy link
Contributor

@jbronder jbronder commented Jul 6, 2025

Towards #24236. Replaces JS builtins with equivalent primordials.

`ext/node/polyfills/internal_binding/util.ts`
Comment on lines 106 to 109
let allProperties = [
...Object.getOwnPropertyNames(obj),
...Object.getOwnPropertySymbols(obj),
...new SafeArrayIterator(ObjectGetOwnPropertyNames(obj)),
...new SafeArrayIterator(ObjectGetOwnPropertySymbols(obj)),
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems better to use Reflect.ownKeys.

let allProperties = ReflectOwnKeys(obj);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense. I've updated it. Thank you for your review!

Comment on lines 123 to 124
for (const key of new SafeArrayIterator(allProperties)) {
const desc = ObjectGetOwnPropertyDescriptor(obj, key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SafeArrayIterator has a slight performance cost, I would like to use a simple loop based on the index.

Suggested change
for (const key of new SafeArrayIterator(allProperties)) {
const desc = ObjectGetOwnPropertyDescriptor(obj, key);
for (let i = 0; i < allProperties.length; ++i) {
const key = allProperties[i];
const desc = ObjectGetOwnPropertyDescriptor(obj, key);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bartlomieju bartlomieju enabled auto-merge (squash) August 7, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants