MCPcopy Index your code
hub / github.com/nodejs/node / readFileTest

Function readFileTest

test/parallel/test-fs-promises-readfile-with-fd.js:17–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15writeFileSync(fn, 'Hello World');
16
17async function readFileTest() {
18 const handle = await open(fn, 'r');
19
20 /* Read only five bytes, so that the position moves to five. */
21 const buf = Buffer.alloc(5);
22 const { bytesRead } = await handle.read(buf, 0, 5, null);
23 assert.strictEqual(bytesRead, 5);
24 assert.strictEqual(buf.toString(), 'Hello');
25
26 /* readFile() should read from position five, instead of zero. */
27 assert.strictEqual((await handle.readFile()).toString(), ' World');
28
29 await handle.close();
30}
31
32
33readFileTest()

Calls 6

allocMethod · 0.80
openFunction · 0.70
closeMethod · 0.65
readMethod · 0.45
toStringMethod · 0.45
readFileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…