Skip to content

Commit 282a45d

Browse files
Gabriel Schulhoftargos
Gabriel Schulhof
authored andcommitted
doc: update wrapping-related documentation
Update the N-API documentation to reflect that wrapping no longer affects the object's prototype chain. PR-URL: #22363 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 611f423 commit 282a45d

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

doc/api/n-api.md

+7-13
Original file line numberDiff line numberDiff line change
@@ -3569,8 +3569,7 @@ napi_status napi_wrap(napi_env env,
35693569

35703570
- `[in] env`: The environment that the API is invoked under.
35713571
- `[in] js_object`: The JavaScript object that will be the wrapper for the
3572-
native object. This object _must_ have been created from the `prototype` of
3573-
a constructor that was created using `napi_define_class()`.
3572+
native object.
35743573
- `[in] native_object`: The native instance that will be wrapped in the
35753574
JavaScript object.
35763575
- `[in] finalize_cb`: Optional native callback that can be used to free the
@@ -3602,13 +3601,9 @@ temporarily during async operations that require the instance to remain valid.
36023601

36033602
*Caution*: The optional returned reference (if obtained) should be deleted via
36043603
[`napi_delete_reference`][] ONLY in response to the finalize callback
3605-
invocation. (If it is deleted before then, then the finalize callback may never
3606-
be invoked.) Therefore, when obtaining a reference a finalize callback is also
3607-
required in order to enable correct proper of the reference.
3608-
3609-
This API may modify the prototype chain of the wrapper object. Afterward,
3610-
additional manipulation of the wrapper's prototype chain may cause
3611-
`napi_unwrap()` to fail.
3604+
invocation. If it is deleted before then, then the finalize callback may never
3605+
be invoked. Therefore, when obtaining a reference a finalize callback is also
3606+
required in order to enable correct disposal of the reference.
36123607

36133608
Calling `napi_wrap()` a second time on an object will return an error. To
36143609
associate another native instance with the object, use `napi_remove_wrap()`
@@ -3658,10 +3653,9 @@ napi_status napi_remove_wrap(napi_env env,
36583653
Returns `napi_ok` if the API succeeded.
36593654

36603655
Retrieves a native instance that was previously wrapped in the JavaScript
3661-
object `js_object` using `napi_wrap()` and removes the wrapping, thereby
3662-
restoring the JavaScript object's prototype chain. If a finalize callback was
3663-
associated with the wrapping, it will no longer be called when the JavaScript
3664-
object becomes garbage-collected.
3656+
object `js_object` using `napi_wrap()` and removes the wrapping. If a finalize
3657+
callback was associated with the wrapping, it will no longer be called when the
3658+
JavaScript object becomes garbage-collected.
36653659

36663660
## Simple Asynchronous Operations
36673661

0 commit comments

Comments
 (0)