Skip to main content
Deno 2 is finally here 🎉️
Learn more
Go to Latest
function toArrayBuffer
import { toArrayBuffer } from "https://deno.land/x/fathym_eac_runtime@v0.0.140/src/src.deps.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.224.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>