MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / ThrowingReadable

Class ThrowingReadable

packages/alphatab/src/io/IReadable.ts:76–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74 * @internal
75 */
76export class ThrowingReadable implements IReadable {
77 private _readable: IReadable;
78 public constructor(readable: IReadable) {
79 this._readable = readable;
80 }
81 public get position(): number {
82 return this._readable.position;
83 }
84
85 public set position(value: number) {
86 this._readable.position = value;
87 }
88
89 public get length(): number {
90 return this._readable.length;
91 }
92
93 public reset(): void {
94 this._readable.reset();
95 }
96
97 public skip(offset: number): void {
98 this._readable.skip(offset);
99 }
100
101 private _requireBytes(bytes: number) {
102 const remaining = this.length - this.position;
103 if (remaining < bytes) {
104 throw new EndOfReaderError();
105 }
106 }
107
108 public readByte(): number {
109 this._requireBytes(1);
110 return this._readable.readByte();
111 }
112
113 public read(buffer: Uint8Array, offset: number, count: number): number {
114 this._requireBytes(count);
115 return this._readable.read(buffer, offset, count);
116 }
117
118 public readAll(): Uint8Array {
119 return this._readable.readAll();
120 }
121}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected