aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/binary/typedarray-to-dataview.md
blob: dfef2166bde9d440d2cf4afd198f662913004790 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
---
name: Convert a Uint8Array to a DataView
---

A [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) is a _typed array_ class, meaning it is a mechanism for viewing data in an underlying `ArrayBuffer`. The following snippet creates a [`DataView`] instance over the same range of data as the `Uint8Array`.

```ts
const arr: Uint8Array = ...
const dv = new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
```

---

See [Docs > API > Binary Data](/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.