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] value:表示我们希望引用的 Objectnapi_value
  • [in] initial_refcount:新引用的初始引用计数。
  • [out] result:指向新引用的 napi_ref

如果 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.