Skip to main content
Deno 2 is finally here 🎉️
Learn more
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function toArrayBuffer
import { toArrayBuffer } from "https://deno.land/std@0.220.0/streams/to_array_buffer.ts";

Converts a ReadableStream of Uint8Arrays to an ArrayBuffer. Works the same asResponse.arrayBuffer.

Examples

Example 1

import { toArrayBuffer } from "https://deno.land/std@0.220.0/streams/to_array_buffer.ts";

const stream = ReadableStream.from([
  new Uint8Array([1, 2]),
  new Uint8Array([3, 4]),
]);
await toArrayBuffer(stream); // ArrayBuffer { [Uint8Contents]: <01 02 03 04>, byteLength: 4 }

Parameters

readableStream: ReadableStream<Uint8Array>

Returns

Promise<ArrayBuffer>