Skip to content
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

napi_get_own_property_names #698

Closed
dherman opened this issue Apr 9, 2020 · 2 comments
Closed

napi_get_own_property_names #698

dherman opened this issue Apr 9, 2020 · 2 comments

Comments

@dherman
Copy link

dherman commented Apr 9, 2020

The property APIs include napi_get_property_names() for doing what I think is roughly equivalent to a for-in loop to collect all enumerable property keys, and napi_get_all_property_names() for collecting all property keys whether enumerable or not.

But AFAICT there's no API for doing the equivalent of Object.getOwnPropertyNames(). This one, especially in combination with napi_get_prototype, actually makes for a more powerful primitive, since you can incrementally crawl the prototype chain looking at the properties of one object at a time.

I imagine this one wouldn't be too hard to implement, and I suspect the design is fairly straightforward too: naming conventions strongly suggest napi_get_own_property_names by analogy to the corresponding JS API, and the behavior would simply be the same as 15.2.3.4.

@cjihrig
Copy link

cjihrig commented Apr 9, 2020

Do the key_mode and key_filter inputs to napi_get_all_property_names() do what you need?

@dherman
Copy link
Author

dherman commented Apr 10, 2020

Oh! I completely misread the docs for napi_get_all_property_names(). I'll close the issue, thanks!

@dherman dherman closed this as completed Apr 10, 2020
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

No branches or pull requests

2 participants