napi_escape_handle
napi_status napi_escape_handle(napi_env env,
napi_escapable_handle_scope scope,
napi_value escapee,
napi_value* result); [in] env:调用该 API 时所处的环境。[in] scope:表示当前作用域的napi_value。[in] escapee:表示要被转义的 JavaScriptObject的napi_value。[out] result:表示外部作用域中被转义Object的句柄的napi_value。
如果 API 成功,则返回 napi_ok。
【Returns napi_ok if the API succeeded.】
该 API 会将句柄提升到 JavaScript 对象,使其在外部作用域的整个生命周期内有效。每个作用域只能调用一次。如果调用超过一次,将返回错误。
【This API promotes the handle to the JavaScript object so that it is valid for the lifetime of the outer scope. It can only be called once per scope. If it is called more than once an error will be returned.】
即使存在挂起的 JavaScript 异常,也可以调用此 API。
【This API can be called even if there is a pending JavaScript exception.】