1
1
# ArrayBuffer
2
2
3
- The ` ArrayBuffer ` class corresponds to the JavaScript ` ArrayBuffer ` class.
3
+ The ` ArrayBuffer ` class corresponds to the
4
+ [ JavaScript ` ArrayBuffer ` ] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer )
5
+ class.
4
6
5
7
## Methods
6
8
7
9
### New
8
10
9
- Allocates a new ` ArrayBuffer ` object with a given length.
11
+ Allocates a new ` ArrayBuffer ` instance with a given length.
10
12
11
13
``` cpp
12
14
static ArrayBuffer New (napi_env env, size_t byteLength);
13
15
```
14
16
15
- - `[in] env`: The environment in which to create the ArrayBuffer object .
17
+ - `[in] env`: The environment in which to create the ` ArrayBuffer` instance .
16
18
- `[in] byteLength`: The length to be allocated, in bytes.
17
19
18
- Returns a new `ArrayBuffer` object .
20
+ Returns a new `ArrayBuffer` instance .
19
21
20
22
### New
21
23
22
- Wraps the provided external data into a new `ArrayBuffer` object .
24
+ Wraps the provided external data into a new `ArrayBuffer` instance .
23
25
24
- The `ArrayBuffer` object does not assume ownership for the data and expects it
25
- to be valid for the lifetime of the object . Since the `ArrayBuffer` is subject
26
+ The `ArrayBuffer` instance does not assume ownership for the data and expects it
27
+ to be valid for the lifetime of the instance . Since the `ArrayBuffer` is subject
26
28
to garbage collection this overload is only suitable for data which is static
27
29
and never needs to be freed.
28
30
29
31
```cpp
30
32
static ArrayBuffer New(napi_env env, void* externalData, size_t byteLength);
31
33
```
32
34
33
- - ` [in] env ` : The environment in which to create the ` ArrayBuffer ` object .
35
+ - ` [in] env ` : The environment in which to create the ` ArrayBuffer ` instance .
34
36
- ` [in] externalData ` : The pointer to the external data to wrap.
35
37
- ` [in] byteLength ` : The length of the ` externalData ` , in bytes.
36
38
37
- Returns a new ` ArrayBuffer ` object .
39
+ Returns a new ` ArrayBuffer ` instance .
38
40
39
41
### New
40
42
41
- Wraps the provided external data into a new ` ArrayBuffer ` object .
43
+ Wraps the provided external data into a new ` ArrayBuffer ` instance .
42
44
43
- The ` ArrayBuffer ` object does not assume ownership for the data and expects it
44
- to be valid for the lifetime of the object . The data can only be freed once the
45
- ` finalizeCallback ` is invoked to indicate that the ` ArrayBuffer ` has been
45
+ The ` ArrayBuffer ` instance does not assume ownership for the data and expects it
46
+ to be valid for the lifetime of the instance . The data can only be freed once
47
+ the ` finalizeCallback ` is invoked to indicate that the ` ArrayBuffer ` has been
46
48
released.
47
49
48
50
``` cpp
@@ -53,22 +55,22 @@ static ArrayBuffer New(napi_env env,
53
55
Finalizer finalizeCallback);
54
56
```
55
57
56
- - `[in] env`: The environment in which to create the `ArrayBuffer` object .
58
+ - `[in] env`: The environment in which to create the `ArrayBuffer` instance .
57
59
- `[in] externalData`: The pointer to the external data to wrap.
58
60
- `[in] byteLength`: The length of the `externalData`, in bytes.
59
61
- `[in] finalizeCallback`: A function to be called when the `ArrayBuffer` is
60
62
destroyed. It must implement `operator()`, accept a `void*` (which is the
61
63
`externalData` pointer), and return `void`.
62
64
63
- Returns a new `ArrayBuffer` object .
65
+ Returns a new `ArrayBuffer` instance .
64
66
65
67
### New
66
68
67
- Wraps the provided external data into a new `ArrayBuffer` object .
69
+ Wraps the provided external data into a new `ArrayBuffer` instance .
68
70
69
- The `ArrayBuffer` object does not assume ownership for the data and expects it
70
- to be valid for the lifetime of the object . The data can only be freed once the
71
- `finalizeCallback` is invoked to indicate that the `ArrayBuffer` has been
71
+ The `ArrayBuffer` instance does not assume ownership for the data and expects it
72
+ to be valid for the lifetime of the instance . The data can only be freed once
73
+ the `finalizeCallback` is invoked to indicate that the `ArrayBuffer` has been
72
74
released.
73
75
74
76
```cpp
@@ -80,7 +82,7 @@ static ArrayBuffer New(napi_env env,
80
82
Hint* finalizeHint);
81
83
```
82
84
83
- - ` [in] env ` : The environment in which to create the ` ArrayBuffer ` object .
85
+ - ` [in] env ` : The environment in which to create the ` ArrayBuffer ` instance .
84
86
- ` [in] externalData ` : The pointer to the external data to wrap.
85
87
- ` [in] byteLength ` : The length of the ` externalData ` , in bytes.
86
88
- ` [in] finalizeCallback ` : The function to be called when the ` ArrayBuffer ` is
@@ -89,7 +91,7 @@ static ArrayBuffer New(napi_env env,
89
91
- ` [in] finalizeHint ` : The hint to be passed as the second parameter of the
90
92
finalize callback.
91
93
92
- Returns a new ` ArrayBuffer ` object .
94
+ Returns a new ` ArrayBuffer ` instance .
93
95
94
96
### Constructor
95
97
@@ -107,7 +109,7 @@ Initializes a wrapper instance of an existing `ArrayBuffer` object.
107
109
ArrayBuffer (napi_env env, napi_value value);
108
110
```
109
111
110
- - `[in] env`: The environment in which to create the `ArrayBuffer` object .
112
+ - `[in] env`: The environment in which to create the `ArrayBuffer` instance .
111
113
- `[in] value`: The `ArrayBuffer` reference to wrap.
112
114
113
115
### ByteLength
0 commit comments