mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(ext/node): internal buffer length in readSync (#26064)
Closes https://github.com/denoland/deno/issues/26054
This commit is contained in:
parent
2d488e4bfb
commit
ff4e682ff9
2 changed files with 12 additions and 1 deletions
|
@ -173,7 +173,7 @@ export function readSync(
|
|||
validateBuffer(buffer);
|
||||
|
||||
if (length == null) {
|
||||
length = 0;
|
||||
length = buffer.byteLength;
|
||||
}
|
||||
|
||||
if (typeof offsetOrOpt === "number") {
|
||||
|
|
|
@ -4,13 +4,16 @@ import { assert, assertEquals, assertThrows } from "@std/assert";
|
|||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import {
|
||||
closeSync,
|
||||
constants,
|
||||
createWriteStream,
|
||||
existsSync,
|
||||
lstatSync,
|
||||
mkdtempSync,
|
||||
openSync,
|
||||
promises,
|
||||
readFileSync,
|
||||
readSync,
|
||||
Stats,
|
||||
statSync,
|
||||
writeFileSync,
|
||||
|
@ -201,3 +204,11 @@ Deno.test(
|
|||
assertEquals(res, [0, 1, 2, 3, 4, 5]);
|
||||
},
|
||||
);
|
||||
|
||||
Deno.test("[node/fs] readSync works", () => {
|
||||
const fd = openSync("tests/testdata/assets/hello.txt", "r");
|
||||
const buf = new Uint8Array(256);
|
||||
const bytesRead = readSync(fd!, buf);
|
||||
assertEquals(bytesRead, 12);
|
||||
closeSync(fd!);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue