Skip to main content
Home
This release is 47 versions behind 1.0.16 — the latest version of @std/streams. Jump to latest

Utilities for working with the Web Streams API

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
2 years ago (0.203.0)
Package root>to_array_buffer.ts
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. import { concat } from "jsr:/@std/bytes@^0.203.0/concat"; export async function toArrayBuffer( readableStream: ReadableStream<Uint8Array>, ): Promise<ArrayBuffer> { const reader = readableStream.getReader(); const chunks: Uint8Array[] = []; while (true) { const { done, value } = await reader.read(); if (done) { break; } chunks.push(value); } return concat(...chunks).buffer; }