Skip to content

Commit 0334473

Browse files
oleiadecodebien
andauthored
Apply suggestions from code review
Co-authored-by: Ivan <[email protected]>
1 parent 0f72a0b commit 0334473

File tree

1 file changed

+0
-27
lines changed
  • docs/sources/next/javascript-api/k6-experimental/fs

1 file changed

+0
-27
lines changed

docs/sources/next/javascript-api/k6-experimental/fs/FileInfo.md

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,6 @@ export default async function () {
3434
throw new Error('Unexpected file name');
3535
}
3636

37-
const buffer = new Uint8Array(4);
38-
39-
let totalBytesRead = 0;
40-
while (true) {
41-
// Read into the buffer
42-
const bytesRead = await file.read(buffer);
43-
if (bytesRead == null) {
44-
// EOF
45-
break;
46-
}
47-
48-
// Do something useful with the content of the buffer
49-
totalBytesRead += bytesRead;
50-
51-
// If bytesRead is less than the buffer size, we've read the whole file
52-
if (bytesRead < buffer.byteLength) {
53-
break;
54-
}
55-
}
56-
57-
// Check that we read the expected number of bytes
58-
if (totalBytesRead != fileinfo.size) {
59-
throw new Error('Unexpected number of bytes read');
60-
}
61-
62-
// Seek back to the beginning of the file
63-
await file.seek(0, SeekMode.Start);
6437
}
6538
```
6639

0 commit comments

Comments
 (0)