diff --git a/tools/fs/files.ts b/tools/fs/files.ts index d5538b0ba3..f8f9d7c891 100644 --- a/tools/fs/files.ts +++ b/tools/fs/files.ts @@ -1538,13 +1538,13 @@ export function readBufferWithLengthAndOffset( if (length > 0) { const fd = open(filename, "r"); try { - var count = read(fd, data, 0, length, offset); + const count = read(fd, data, { position: 0, length, offset }); + if (count !== length) { + throw new Error("couldn't read entire resource"); + } } finally { close(fd); } - if (count !== length) { - throw new Error("couldn't read entire resource"); - } } return data; }