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:要为其创建引用的 napi_value
  • [in] initial_refcount:新引用的初始引用计数。
  • [out] result:指向新引用的 napi_ref

如果 API 成功,则返回 napi_ok

【Returns napi_ok if the API succeeded.】

此 API 会使用指定的引用计数创建一个指向传入值的新引用。

【This API creates a new reference with the specified reference count to the value passed in.】