--- name: Convert an ArrayBuffer to an array of numbers --- To retrieve the contents of an `ArrayBuffer` as an array of numbers, create a [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) over of the buffer. and use the [`Array.from()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) method to convert it to an array. ```ts const buf = new ArrayBuffer(64); const arr = new Uint8Array(buf); arr.length; // 64 arr[0]; // 0 (instantiated with all zeros) ``` --- The `Uint8Array` class supports array indexing and iteration. However if you wish to convert the instance to a regular `Array`, use `Array.from()`. (This will likely be slower than using the `Uint8Array` directly.) ```ts const buf = new ArrayBuffer(64); const uintArr = new Uint8Array(buf); const regularArr = Array.from(uintArr); // number[] ``` --- See [Docs > API > Binary Data](/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. e='bun-polyfills'>bun-polyfills Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/hash.test.js (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-03-30[Bun.js] fixup Bun.hashGravatar Jarred Sumner 1-4/+9
2022-03-30[bun-framework-next] Support Next 12.1.3 & React 18Gravatar Jarred Sumner 4-18/+86
2022-03-30[bun-framework-next] Remove unnecessary polyfillsGravatar Jarred Sumner 2-655/+0
2022-03-30Don't need to import react hereGravatar Jarred Sumner 1-1/+0
2022-03-28Delete url.zigGravatar Jarred Sumner 1-151/+0
2022-03-28[bun.js] Add `Bun.hash`Gravatar Jarred Sumner 2-0/+160
2022-03-28CustomEventGravatar Jarred Sumner 11-14/+738
2022-03-28ScriptExecutionContextGravatar Jarred Sumner 2-15/+14
2022-03-28[`bun.js`] Add `Event`, `EventTarget`, `AbortController`, `AbortSignal`Gravatar Jarred Sumner 111-21/+11463
2022-03-27Safer error handlingGravatar Jarred Sumner 2-13/+19
2022-03-27[Bun.js] Add `DOMException`Gravatar Jarred Sumner 1-7/+18
2022-03-27No to FormData for nowGravatar Jarred Sumner 3-272/+2
2022-03-27Update WebKitGravatar Jarred Sumner 1-0/+0
2022-03-27Update base.zigGravatar Jarred Sumner 1-1/+1
2022-03-27Update .clang-formatGravatar Jarred Sumner 1-1/+1
2022-03-27Update MakefileGravatar Jarred Sumner 1-7/+24
2022-03-27Begin adding WebCore classes to bunGravatar Jarred Sumner 123-1014/+12717
2022-03-27Add Bun.mmap exampleGravatar Jarred Sumner 3-0/+34