@@ -2382,12 +2382,7 @@ is used to pass external data through JavaScript code, so it can be retrieved
2382
2382
later by native code using [`napi_get_value_external`][].
2383
2383
2384
2384
The 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.
2391
2386
2392
2387
The created value is not an object, and therefore does not support additional
2393
2388
properties. 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
2441
2436
finalize callback is called.
2442
2437
2443
2438
The 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.
2450
2440
2451
2441
JavaScript `ArrayBuffer`s are described in
2452
2442
[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
2497
2487
structure, in most cases using a `TypedArray` will suffice.
2498
2488
2499
2489
The 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.
2506
2491
2507
2492
For Node.js >=4 `Buffers` are `Uint8Array`s.
2508
2493
@@ -5141,7 +5126,7 @@ napi_status napi_wrap(napi_env env,
5141
5126
* `[in] native_object`: The native instance that will be wrapped in the
5142
5127
JavaScript object.
5143
5128
* `[in] finalize_cb`: Optional native callback that can be used to free the
5144
- native instance when the JavaScript object is ready for garbage-collection .
5129
+ native instance when the JavaScript object has been garbage-collected .
5145
5130
[`napi_finalize`][] provides more details.
5146
5131
* `[in] finalize_hint`: Optional contextual hint that is passed to the
5147
5132
finalize callback.
@@ -5303,7 +5288,7 @@ napiVersion: 5
5303
5288
```c
5304
5289
napi_status napi_add_finalizer(napi_env env,
5305
5290
napi_value js_object,
5306
- void* native_object ,
5291
+ void* finalize_data ,
5307
5292
napi_finalize finalize_cb,
5308
5293
void* finalize_hint,
5309
5294
napi_ref* result);
@@ -5312,10 +5297,9 @@ napi_status napi_add_finalizer(napi_env env,
5312
5297
* `[in] env`: The environment that the API is invoked under.
5313
5298
* `[in] js_object`: The JavaScript object to which the native data will be
5314
5299
attached.
5315
- * `[in] native_object`: The native data that will be attached to the JavaScript
5316
- object.
5300
+ * `[in] finalize_data`: Optional data to be passed to `finalize_cb`.
5317
5301
* `[in] finalize_cb`: Native callback that will be used to free the
5318
- native data when the JavaScript object is ready for garbage-collection .
5302
+ native data when the JavaScript object has been garbage-collected .
5319
5303
[`napi_finalize`][] provides more details.
5320
5304
* `[in] finalize_hint`: Optional contextual hint that is passed to the
5321
5305
finalize callback.
@@ -5324,14 +5308,9 @@ napi_status napi_add_finalizer(napi_env env,
5324
5308
Returns `napi_ok` if the API succeeded.
5325
5309
5326
5310
Adds a `napi_finalize` callback which will be called when the JavaScript object
5327
- in `js_object` is ready for garbage collection. This API is similar to
5328
- `napi_wrap()` except that:
5329
-
5330
- * the native data cannot be retrieved later using `napi_unwrap()`,
5331
- * nor can it be removed later using `napi_remove_wrap()`, and
5332
- * the API can be called multiple times with different data items in order to
5333
- attach each of them to the JavaScript object, and
5334
- * the object manipulated by the API can be used with `napi_wrap()`.
5311
+ in `js_object` has been garbage-collected.
5312
+
5313
+ This API can be called multiple times on a single JavaScript object.
5335
5314
5336
5315
_Caution_: The optional returned reference (if obtained) should be deleted via
5337
5316
[`napi_delete_reference`][] ONLY in response to the finalize callback
0 commit comments