napi_create_reference


NAPI_EXTERN napi_status napi_create_reference(napi_env env,
                                              napi_value value,
                                              uint32_t initial_refcount,
                                              napi_ref* result); 
  • [in] env:调用 API 的环境。

    ¥[in] env: The environment that the API is invoked under.

  • [in] valuenapi_value 表示我们要引用的 Object

    ¥[in] value: napi_value representing the Object to which we want a reference.

  • [in] initial_refcount:新引用的初始引用计数。

    ¥[in] initial_refcount: Initial reference count for the new reference.

  • [out] resultnapi_ref 指向新的引用。

    ¥[out] result: napi_ref pointing to the new reference.

如果 API 成功,则返回 napi_ok

¥Returns napi_ok if the API succeeded.

此 API 对传入的 Object 创建具有指定引用计数的新引用。

¥This API creates a new reference with the specified reference count to the Object passed in.