Bun Convert a Uint8Array to a DataView

Convert a Uint8Array to a DataView

jarle Updated

File contents

Convert a Uint8Array to a DataView

A 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.

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

See Docs > API > Binary Data for complete documentation on manipulating binary data with Bun.

jarle/bun-skills/tree/main/skills/bun-guides-binary-typedarray-to-dataview commit 9abd8fb3f1

Frequently asked questions

npx skillmds@latest add jarle/bun-convert-a-uint8array-to-a-dataview