File: typed_array.md

package info (click to toggle)
node-addon-api 8.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,248 kB
  • sloc: cpp: 15,431; javascript: 5,631; ansic: 157; makefile: 7
file content (78 lines) | stat: -rw-r--r-- 1,487 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# TypedArray

Class `Napi::TypedArray` inherits from class [`Napi::Object`][].

The `Napi::TypedArray` class corresponds to the
[JavaScript `TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)
class.

## Methods

### Constructor

Initializes an empty instance of the `Napi::TypedArray` class.

```cpp
Napi::TypedArray::TypedArray();
```

### Constructor

Initializes a wrapper instance of an existing `Napi::TypedArray` instance.

```cpp
Napi::TypedArray::TypedArray(napi_env env, napi_value value);
```

- `[in] env`: The environment in which to create the `Napi::TypedArray` instance.
- `[in] value`: The `Napi::TypedArray` reference to wrap.

### TypedArrayType

```cpp
napi_typedarray_type Napi::TypedArray::TypedArrayType() const;
```

Returns the type of this instance.

### ArrayBuffer

```cpp
Napi::ArrayBuffer Napi::TypedArray::ArrayBuffer() const;
```

Returns the backing array buffer.

### ElementSize

```cpp
uint8_t Napi::TypedArray::ElementSize() const;
```

Returns the size of one element, in bytes.

### ElementLength

```cpp
size_t Napi::TypedArray::ElementLength() const;
```

Returns the number of elements.

### ByteOffset

```cpp
size_t Napi::TypedArray::ByteOffset() const;
```

Returns the offset into the `Napi::ArrayBuffer` where the array starts, in bytes.

### ByteLength

```cpp
size_t Napi::TypedArray::ByteLength() const;
```

Returns the length of the array, in bytes.

[`Napi::Object`]: ./object.md