MCPcopy Create free account
hub / github.com/nodejs/node / validateWrite

Function validateWrite

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

Source from the content-addressed store, hash-verified

17tmpdir.refresh();
18
19async function validateWrite() {
20 const filePathForHandle = path.resolve(tmpDir, 'tmp-write.txt');
21 const fileHandle = await open(filePathForHandle, 'w');
22 const buffer = Buffer.from('Hello world'.repeat(100), 'utf8');
23
24 const stream = fileHandle.createWriteStream();
25 stream.end(buffer);
26 await finished(stream);
27
28 const readFileData = fs.readFileSync(filePathForHandle);
29 assert.deepStrictEqual(buffer, readFileData);
30}
31
32async function validateRead() {
33 const filePathForHandle = path.resolve(tmpDir, 'tmp-read.txt');

Calls 7

openFunction · 0.70
finishedFunction · 0.70
createWriteStreamMethod · 0.65
resolveMethod · 0.45
fromMethod · 0.45
endMethod · 0.45
readFileSyncMethod · 0.45

Tested by

no test coverage detected