@@ -1809,9 +1809,15 @@ Returns `napi_ok` if the API succeeded.
1809
1809
1810
1810
This API allocates a JavaScript value with external data attached to it. This
1811
1811
is used to pass external data through JavaScript code, so it can be retrieved
1812
- later by native code. The API allows the caller to pass in a finalize callback,
1813
- in case the underlying native resource needs to be cleaned up when the external
1814
- JavaScript value gets collected.
1812
+ later by native code using [`napi_get_value_external`].
1813
+
1814
+ The API adds a `napi_finalize` callback which will be called when the JavaScript
1815
+ object just created is ready for garbage collection. It is similar to
1816
+ `napi_wrap()` except that:
1817
+
1818
+ * the native data cannot be retrieved later using `napi_unwrap()`,
1819
+ * nor can it be removed later using `napi_remove_wrap()`, and
1820
+ * the object created by the API can be used with `napi_wrap()`.
1815
1821
1816
1822
The created value is not an object, and therefore does not support additional
1817
1823
properties. It is considered a distinct value type: calling `napi_typeof()` with
@@ -1850,6 +1856,14 @@ The underlying byte buffer of the `ArrayBuffer` is externally allocated and
1850
1856
managed. The caller must ensure that the byte buffer remains valid until the
1851
1857
finalize callback is called.
1852
1858
1859
+ The API adds a `napi_finalize` callback which will be called when the JavaScript
1860
+ object just created is ready for garbage collection. It is similar to
1861
+ `napi_wrap()` except that:
1862
+
1863
+ * the native data cannot be retrieved later using `napi_unwrap()`,
1864
+ * nor can it be removed later using `napi_remove_wrap()`, and
1865
+ * the object created by the API can be used with `napi_wrap()`.
1866
+
1853
1867
JavaScript `ArrayBuffer`s are described in
1854
1868
[Section 24.1][] of the ECMAScript Language Specification.
1855
1869
@@ -1884,6 +1898,14 @@ This API allocates a `node::Buffer` object and initializes it with data
1884
1898
backed by the passed in buffer. While this is still a fully-supported data
1885
1899
structure, in most cases using a `TypedArray` will suffice.
1886
1900
1901
+ The API adds a `napi_finalize` callback which will be called when the JavaScript
1902
+ object just created is ready for garbage collection. It is similar to
1903
+ `napi_wrap()` except that:
1904
+
1905
+ * the native data cannot be retrieved later using `napi_unwrap()`,
1906
+ * nor can it be removed later using `napi_remove_wrap()`, and
1907
+ * the object created by the API can be used with `napi_wrap()`.
1908
+
1887
1909
For Node.js >=4 `Buffers` are `Uint8Array`s.
1888
1910
1889
1911
#### napi_create_object
@@ -4228,7 +4250,8 @@ in `js_object` is ready for garbage collection. This API is similar to
4228
4250
* the native data cannot be retrieved later using `napi_unwrap()`,
4229
4251
* nor can it be removed later using `napi_remove_wrap()`, and
4230
4252
* the API can be called multiple times with different data items in order to
4231
- attach each of them to the JavaScript object.
4253
+ attach each of them to the JavaScript object, and
4254
+ * the object manipulated by the API can be used with `napi_wrap()`.
4232
4255
4233
4256
*Caution*: The optional returned reference (if obtained) should be deleted via
4234
4257
[`napi_delete_reference`][] ONLY in response to the finalize callback
@@ -5164,6 +5187,7 @@ This API may only be called from the main thread.
5164
5187
[`napi_get_last_error_info`]: #n_api_napi_get_last_error_info
5165
5188
[`napi_get_property`]: #n_api_napi_get_property
5166
5189
[`napi_get_reference_value`]: #n_api_napi_get_reference_value
5190
+ [`napi_get_value_external`]: #n_api_napi_get_value_external
5167
5191
[`napi_has_own_property`]: #n_api_napi_has_own_property
5168
5192
[`napi_has_property`]: #n_api_napi_has_property
5169
5193
[`napi_is_error`]: #n_api_napi_is_error
0 commit comments