MCPcopy
hub / github.com/yume-chan/ya-webadb / Uint8ArrayExactReadable

Class Uint8ArrayExactReadable

libraries/struct/src/readable.ts:23–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23export class Uint8ArrayExactReadable implements ExactReadable {
24 #data: Uint8Array;
25 #position: number;
26
27 get position() {
28 return this.#position;
29 }
30
31 constructor(data: Uint8Array) {
32 this.#data = data;
33 this.#position = 0;
34 }
35
36 readExactly(length: number): Uint8Array {
37 if (this.#position + length > this.#data.length) {
38 throw new ExactReadableEndedError();
39 }
40
41 const result = this.#data.subarray(
42 this.#position,
43 this.#position + length,
44 );
45
46 this.#position += length;
47 return result;
48 }
49}
50
51export interface AsyncExactReadable {
52 readonly position: number;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected