node_api_create_object_with_properties
typeexperimentaljs_native_api.hThis API creates a JavaScript Object with the specified prototype and properties.
Stability: 1 - Experimental
napi_status node_api_create_object_with_properties(napi_env env,
napi_value prototype_or_null,
const napi_value* property_names,
const napi_value* property_values,
size_t property_count,
napi_value* result)
[in] env: The environment that the API is invoked under.[in] prototype_or_null: The prototype object for the new object. Can be anapi_valuerepresenting a JavaScript object to use as the prototype, anapi_valuerepresenting JavaScriptnull, or anullptrthat will be converted tonull.[in] property_names: Array ofnapi_valuerepresenting the property names.[in] property_values: Array ofnapi_valuerepresenting the property values.[in] property_count: Number of properties in the arrays.[out] result: Anapi_valuerepresenting a JavaScriptObject.
Returns napi_ok if the API succeeded.
This API creates a JavaScript Object with the specified prototype and
properties. This is more efficient than calling napi_create_object followed
by multiple napi_set_property calls, as it can create the object with all
properties atomically, avoiding potential V8 map transitions.
The arrays property_names and property_values must have the same length
specified by property_count. The properties are added to the object in the
order they appear in the arrays.