Skip to content

Commit f3ece18

Browse files
authored
Simplify native StreamSource reads (#14)
1 parent 7c7c8e7 commit f3ece18

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

src/createSourceInfo.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,9 @@ function createFileSystemSourceInfo(file: File): SourceInfo {
1818
source: new StreamSource({
1919
getSize: () => fileSize,
2020
read: (start, end) => {
21-
const readStart = Math.max(0, Math.min(start, fileSize));
22-
const readEnd = Math.max(readStart, Math.min(end, fileSize));
23-
const length = readEnd - readStart;
24-
25-
if (length === 0) {
26-
return new Uint8Array();
27-
}
28-
2921
const currentHandle = getHandle();
30-
currentHandle.offset = readStart;
31-
return currentHandle.readBytes(length);
22+
currentHandle.offset = start;
23+
return currentHandle.readBytes(end - start);
3224
},
3325
dispose: () => {
3426
handle?.close();

0 commit comments

Comments
 (0)