(
fd: number,
buffer: Buffer | Uint8Array,
offset: number,
length: number,
position: number | null,
)
| 566 | } |
| 567 | |
| 568 | readSync( |
| 569 | fd: number, |
| 570 | buffer: Buffer | Uint8Array, |
| 571 | offset: number, |
| 572 | length: number, |
| 573 | position: number | null, |
| 574 | ): number { |
| 575 | const state = this.#fdOrThrow(fd); |
| 576 | if (!state.readable) { |
| 577 | throw createWorkspaceError("EBADF", `fd ${fd} is not readable`); |
| 578 | } |
| 579 | const startAt = position ?? state.position; |
| 580 | const slice = readRangeSyncImpl(this.db, state.path, startAt, length); |
| 581 | const view = |
| 582 | buffer instanceof Buffer |
| 583 | ? buffer |
| 584 | : Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength); |
| 585 | view.set(slice, offset); |
| 586 | if (position === null || position === undefined) { |
| 587 | state.position = startAt + slice.byteLength; |
| 588 | } |
| 589 | return slice.byteLength; |
| 590 | } |
| 591 | |
| 592 | readRangeSync(path: string, offset: number, length: number): Buffer { |
| 593 | const slice = readRangeSyncImpl(this.db, path, offset, length); |
no test coverage detected