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

Function validateWriteFile

test/parallel/test-fs-promises-file-handle-writeFile.js:18–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16tmpdir.refresh();
17
18async function validateWriteFile() {
19 const filePathForHandle = path.resolve(tmpDir, 'tmp-write-file2.txt');
20 const fileHandle = await open(filePathForHandle, 'w+');
21 try {
22 const buffer = Buffer.from('Hello world'.repeat(100), 'utf8');
23
24 await fileHandle.writeFile(buffer);
25 const readFileData = fs.readFileSync(filePathForHandle);
26 assert.deepStrictEqual(buffer, readFileData);
27 } finally {
28 await fileHandle.close();
29 }
30}
31
32// Signal aborted while writing file
33async function doWriteAndCancel() {

Calls 6

openFunction · 0.70
closeMethod · 0.65
resolveMethod · 0.45
fromMethod · 0.45
writeFileMethod · 0.45
readFileSyncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…