We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9e8da14 commit f8e2997Copy full SHA for f8e2997
src/files/deno.ts
@@ -93,14 +93,17 @@ export class BIDSFileDeno implements BIDSFile {
93
94
/**
95
* Read bytes in a range efficiently from a given file
96
+ *
97
+ * Reads up to size bytes, starting at offset.
98
+ * If EOF is encountered, the resulting array may be smaller.
99
*/
100
async readBytes(size: number, offset = 0): Promise<Uint8Array> {
101
const handle = this.#openHandle()
102
const buf = new Uint8Array(size)
103
await handle.seek(offset, Deno.SeekMode.Start)
- await handle.read(buf)
104
+ const nbytes = await handle.read(buf) ?? 0
105
handle.close()
- return buf
106
+ return buf.subarray(0, nbytes)
107
}
108
109
0 commit comments