1. typedef struct {
    2. // One of utf8name or name should be NULL.
    3. const char* utf8name;
    4. napi_value name;
    5. napi_callback method;
    6. napi_callback getter;
    7. napi_callback setter;
    8. napi_value value;
    9. napi_property_attributes attributes;
    10. void* data;
    11. } napi_property_descriptor;
    • utf8name: Optional String describing the key for the property, encoded as UTF8. One of utf8name or name must be provided for the property.
    • name: Optional napi_value that points to a JavaScript string or symbol to be used as the key for the property. One of utf8name or name must be provided for the property.
    • value: The value that’s retrieved by a get access of the property if the property is a data property. If this is passed in, set getter, setter, method and data to NULL (since these members won’t be used).
    • getter: A function to call when a get access of the property is performed. If this is passed in, set value and method to NULL (since these members won’t be used). The given function is called implicitly by the runtime when the property is accessed from JavaScript code (or if a get on the property is performed using a N-API call). [napi_callback][] provides more details.
    • setter: A function to call when a set access of the property is performed. If this is passed in, set value and method to NULL (since these members won’t be used). The given function is called implicitly by the runtime when the property is set from JavaScript code (or if a set on the property is performed using a N-API call). [napi_callback][] provides more details.
    • method: Set this to make the property descriptor object’s value property to be a JavaScript function represented by method. If this is passed in, set value, getter and setter to NULL (since these members won’t be used). [napi_callback][] provides more details.
    • attributes: The attributes associated with the particular property. See [napi_property_attributes][].
    • data: The callback data passed into method, getter and setter if this function is invoked.