(
bytes: number,
expectMore: boolean,
)
| 143 | expectMore: false, |
| 144 | ): Promise<Uint8Array | undefined>; |
| 145 | async #read( |
| 146 | bytes: number, |
| 147 | expectMore: boolean, |
| 148 | ): Promise<Uint8Array | undefined> { |
| 149 | if (bytes === 0) return new Uint8Array(0); |
| 150 | const { done, value } = await this.#source.read(new Uint8Array(bytes), { |
| 151 | min: bytes, |
| 152 | }); |
| 153 | if (done) { |
| 154 | if (expectMore) throw new RangeError("More bytes were expected"); |
| 155 | else return undefined; |
| 156 | } |
| 157 | if (value.length < bytes) throw new RangeError("More bytes were expected"); |
| 158 | return value; |
| 159 | } |
| 160 | |
| 161 | async *#readGen(bytes: bigint): AsyncGenerator<Uint8Array> { |
| 162 | for (let i = 0n; i < bytes; i += 2n ** 16n) { |
no test coverage detected