Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

std/io/multi_reader.ts

Deno standard library
Go to Latest
File
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.
import type { Reader } from "../types.d.ts";
/** * Reader utility for combining multiple readers * * @deprecated (will be removed after 1.0.0) Use Web Streams instead. */export class MultiReader implements Reader { readonly #readers: Reader[]; #currentIndex = 0;
constructor(readers: Reader[]) { this.#readers = [...readers]; }
async read(p: Uint8Array): Promise<number | null> { const r = this.#readers[this.#currentIndex]; if (!r) return null; const result = await r.read(p); if (result === null) { this.#currentIndex++; return 0; } return result; }}