napi_define_properties
napi_status napi_define_properties(napi_env env,
napi_value object,
size_t property_count,
const napi_property_descriptor* properties);
-
[in] env
:调用 Node-API 调用的环境。¥
[in] env
: The environment that the Node-API call is invoked under. -
[in] object
:从中检索属性的对象。¥
[in] object
: The object from which to retrieve the properties. -
[in] property_count
:properties
数组中的元素数。¥
[in] property_count
: The number of elements in theproperties
array. -
[in] properties
:属性描述符数组。¥
[in] properties
: The array of property descriptors.
如果 API 成功,则返回 napi_ok
。
¥Returns napi_ok
if the API succeeded.
此方法允许在给定对象上高效定义多个属性。属性是使用属性描述符定义的(参见 napi_property_descriptor
)。给定一组此类属性描述符,此 API 将一次设置一个对象的属性,如 DefineOwnProperty()
所定义(在 ECMA-262 规范的 第 9.1.6 节 中描述)。
¥This method allows the efficient definition of multiple properties on a given
object. The properties are defined using property descriptors (see
napi_property_descriptor
). Given an array of such property descriptors,
this API will set the properties on the object one at a time, as defined by
DefineOwnProperty()
(described in Section 9.1.6 of the ECMA-262
specification).