(method: string, buffer: Uint8Array)
| 220 | } |
| 221 | |
| 222 | private readChunk(method: string, buffer: Uint8Array) { |
| 223 | return Effect.suspend(() => { |
| 224 | const position = this.position |
| 225 | return Effect.map( |
| 226 | tryPromise( |
| 227 | method, |
| 228 | undefined, |
| 229 | async () => { |
| 230 | if (this.nativePosition !== position) { |
| 231 | this.file.seekSync(position, Deno.SeekMode.Start) |
| 232 | } |
| 233 | this.nativePosition = undefined |
| 234 | return await this.file.read(buffer) |
| 235 | } |
| 236 | ), |
| 237 | (bytesRead) => { |
| 238 | const sizeRead = FileSystem.Size(bytesRead ?? 0) |
| 239 | this.position = this.nativePosition = position + sizeRead |
| 240 | return sizeRead |
| 241 | } |
| 242 | ) |
| 243 | }) |
| 244 | } |
| 245 | |
| 246 | read(buffer: Uint8Array) { |
| 247 | return this.readChunk("read", buffer) |
no test coverage detected