Skip to main content
Module

std/streams/mod.ts>toArrayBuffer

Deno standard library
Go to Latest
function toArrayBuffer
import { toArrayBuffer } from "https://deno.land/std@0.221.0/streams/mod.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.221.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>