deno.land / std@0.177.1 / io / multi_reader.ts

multi_reader.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import type { Reader } from "../types.d.ts";
/** Reader utility for combining multiple readers */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; }}
std

Version Info

Tagged at
11 months ago