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] env: The environment that the API is invoked under.

  • [in] scopenapi_value 代表当前范围。

    ¥[in] scope: napi_value representing the current scope.

  • [in] escapeenapi_value 表示要转义的 JavaScript Object

    ¥[in] escapee: napi_value representing the JavaScript Object to be escaped.

  • [out] resultnapi_value 表示外部作用域中转义的 Object 的句柄。

    ¥[out] result: napi_value representing the handle to the escaped Object in the outer scope.

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