Skip to main content
Module

std/streams/mod.ts>toArrayBuffer

The Deno Standard Library
Latest
function toArrayBuffer
import { toArrayBuffer } from "https://deno.land/std@0.222.1/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.222.1/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>