@@ -2382,12 +2382,7 @@ is used to pass external data through JavaScript code, so it can be retrieved
23822382later by native code using [`napi_get_value_external`][].
23832383
23842384The API adds a `napi_finalize` callback which will be called when the JavaScript
2385- object just created is ready for garbage collection. It is similar to
2386- `napi_wrap()` except that:
2387-
2388- * the native data cannot be retrieved later using `napi_unwrap()`,
2389- * nor can it be removed later using `napi_remove_wrap()`, and
2390- * the object created by the API can be used with `napi_wrap()`.
2385+ object just created has been garbage collected.
23912386
23922387The created value is not an object, and therefore does not support additional
23932388properties. It is considered a distinct value type: calling `napi_typeof()` with
@@ -2441,12 +2436,7 @@ managed. The caller must ensure that the byte buffer remains valid until the
24412436finalize callback is called.
24422437
24432438The API adds a `napi_finalize` callback which will be called when the JavaScript
2444- object just created is ready for garbage collection. It is similar to
2445- `napi_wrap()` except that:
2446-
2447- * the native data cannot be retrieved later using `napi_unwrap()`,
2448- * nor can it be removed later using `napi_remove_wrap()`, and
2449- * the object created by the API can be used with `napi_wrap()`.
2439+ object just created has been garbage collected.
24502440
24512441JavaScript `ArrayBuffer`s are described in
24522442[Section 24.1][] of the ECMAScript Language Specification.
@@ -2497,12 +2487,7 @@ backed by the passed in buffer. While this is still a fully-supported data
24972487structure, in most cases using a `TypedArray` will suffice.
24982488
24992489The API adds a `napi_finalize` callback which will be called when the JavaScript
2500- object just created is ready for garbage collection. It is similar to
2501- `napi_wrap()` except that:
2502-
2503- * the native data cannot be retrieved later using `napi_unwrap()`,
2504- * nor can it be removed later using `napi_remove_wrap()`, and
2505- * the object created by the API can be used with `napi_wrap()`.
2490+ object just created has been garbage collected.
25062491
25072492For Node.js >=4 `Buffers` are `Uint8Array`s.
25082493
@@ -5139,7 +5124,7 @@ napi_status napi_wrap(napi_env env,
51395124* `[in] native_object`: The native instance that will be wrapped in the
51405125 JavaScript object.
51415126* `[in] finalize_cb`: Optional native callback that can be used to free the
5142- native instance when the JavaScript object is ready for garbage-collection .
5127+ native instance when the JavaScript object has been garbage-collected .
51435128 [`napi_finalize`][] provides more details.
51445129* `[in] finalize_hint`: Optional contextual hint that is passed to the
51455130 finalize callback.
@@ -5301,7 +5286,7 @@ napiVersion: 5
53015286```c
53025287napi_status napi_add_finalizer(napi_env env,
53035288 napi_value js_object,
5304- void* native_object ,
5289+ void* finalize_data ,
53055290 napi_finalize finalize_cb,
53065291 void* finalize_hint,
53075292 napi_ref* result);
@@ -5310,10 +5295,9 @@ napi_status napi_add_finalizer(napi_env env,
53105295* `[in] env`: The environment that the API is invoked under.
53115296* `[in] js_object`: The JavaScript object to which the native data will be
53125297 attached.
5313- * `[in] native_object`: The native data that will be attached to the JavaScript
5314- object.
5298+ * `[in] finalize_data`: Optional data to be passed to `finalize_cb`.
53155299* `[in] finalize_cb`: Native callback that will be used to free the
5316- native data when the JavaScript object is ready for garbage-collection .
5300+ native data when the JavaScript object has been garbage-collected .
53175301 [`napi_finalize`][] provides more details.
53185302* `[in] finalize_hint`: Optional contextual hint that is passed to the
53195303 finalize callback.
@@ -5322,14 +5306,9 @@ napi_status napi_add_finalizer(napi_env env,
53225306Returns `napi_ok` if the API succeeded.
53235307
53245308Adds a `napi_finalize` callback which will be called when the JavaScript object
5325- in `js_object` is ready for garbage collection. This API is similar to
5326- `napi_wrap()` except that:
5327-
5328- * the native data cannot be retrieved later using `napi_unwrap()`,
5329- * nor can it be removed later using `napi_remove_wrap()`, and
5330- * the API can be called multiple times with different data items in order to
5331- attach each of them to the JavaScript object, and
5332- * the object manipulated by the API can be used with `napi_wrap()`.
5309+ in `js_object` has been garbage-collected.
5310+
5311+ This API can be called multiple times on a single JavaScript object.
53335312
53345313_Caution_: The optional returned reference (if obtained) should be deleted via
53355314[`napi_delete_reference`][] ONLY in response to the finalize callback
0 commit comments