• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# TypedArray
2
3Class `Napi::TypedArray` inherits from class [`Napi::Object`][].
4
5The `Napi::TypedArray` class corresponds to the
6[JavaScript `TypedArray`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)
7class.
8
9## Methods
10
11### Constructor
12
13Initializes an empty instance of the `Napi::TypedArray` class.
14
15```cpp
16Napi::TypedArray::TypedArray();
17```
18
19### Constructor
20
21Initializes a wrapper instance of an existing `Napi::TypedArray` instance.
22
23```cpp
24Napi::TypedArray::TypedArray(napi_env env, napi_value value);
25```
26
27- `[in] env`: The environment in which to create the `Napi::TypedArray` instance.
28- `[in] value`: The `Napi::TypedArray` reference to wrap.
29
30### TypedArrayType
31
32```cpp
33napi_typedarray_type Napi::TypedArray::TypedArrayType() const;
34```
35
36Returns the type of this instance.
37
38### ArrayBuffer
39
40```cpp
41Napi::ArrayBuffer Napi::TypedArray::ArrayBuffer() const;
42```
43
44Returns the backing array buffer.
45
46### ElementSize
47
48```cpp
49uint8_t Napi::TypedArray::ElementSize() const;
50```
51
52Returns the size of one element, in bytes.
53
54### ElementLength
55
56```cpp
57size_t Napi::TypedArray::ElementLength() const;
58```
59
60Returns the number of elements.
61
62### ByteOffset
63
64```cpp
65size_t Napi::TypedArray::ByteOffset() const;
66```
67
68Returns the offset into the `Napi::ArrayBuffer` where the array starts, in bytes.
69
70### ByteLength
71
72```cpp
73size_t Napi::TypedArray::ByteLength() const;
74```
75
76Returns the length of the array, in bytes.
77
78[`Napi::Object`]: ./object.md
79