You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
n-api: add method to get own property names #28942
Is your feature request related to a problem? Please describe.
Yes. The need is to only examine properties owned by the object, not properties found on Object.prototype. The C++ API in use before N-API had a GetOwnPropertyNames() method. That appears to be missing from N-API.
Describe the solution you'd like
Ideally, a method like this:
Describe alternatives you've considered
(1) call napi_get_property_names() and then call napi_has_own_property() on each entry as you iterate through the provided array. If you need to allocate memory for each entry, however, you either need to iterate through the array twice (once to get the number of owned properties and once to do stuff with the array) or you need to over-allocate memory.
(2) call "Object.getOwnPropertyNames()" directly. This requires calling napi_get_global(), napi_get_named_property() twice (once to get "Object" and the second to get "getOwnPropertyNames") and then call napi_call_function() -- which is a lot of calls to do one common operation.
Activity
devsnek commentedon Aug 2, 2019
@nodejs/n-api
himself65 commentedon Aug 2, 2019
I'm working on this
gabrielschulhof commentedon Jan 21, 2020
With #30006 having landed, we now have this functionality.