Skip to content

n-api: Use get_all_property_names for Object::get_own_property_names impl #511

@goto-bus-stop

Description

@goto-bus-stop

Object::get_own_property_names should act like Object.getOwnPropertyNames does in JS, but there was no n-api function available to do exactly that. Instead, we're using napi_get_property_names, which acts more like for (var key in object), including properties from the prototype and the like.

Right now, we're doing this load of work to paper over that: https://github.com/goto-bus-stop/neon/blob/9b338f9ed0a8dcb781566b61bc06b67f07ca23a1/crates/neon-runtime/src/napi/object.rs#L17-L84

But it's still not accurate.

There is an napi_get_all_property_names API that would allow implementing Object::get_own_property_names correctly, and with a lot less code to boot. At the time of the PR, it was still in the process of being backported. Once it is available in all release lines (Node.js 10/12/13/14), we can switch to napi_get_all_property_names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions