Node-addon-api: Add Object::New() taking a list of properties

Created on 16 Nov 2019  路  5Comments  路  Source: nodejs/node-addon-api

Example:

static Object New(
    napi_env env, ///< N-API environment
    const std::initializer_list<PropertyDescriptor> &properties  ///< initial prperties
);
stale

All 5 comments

I don't know if we can do this because to create a Napi::PropertyDescriptor accessor we need the object on which the accessor will be defined. So the actual workaround is:

  • Create a Napi::Object object
  • Create Napi::PropertyDescriptor descriptors that you need
  • Use the Napi::Object::DefineProperties method that take a list of properties as parameters.

At moment I don't have a solution @gabrielschulhof do you have some idea about that?

With https://github.com/nodejs/node-addon-api/pull/610 we should be able to do it.

Great I want work on this after your PR will be landed.

Ok https://github.com/nodejs/node-addon-api/pull/610 has been landed, now I can start working on this.

This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

Was this page helpful?
0 / 5 - 0 ratings