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

Function testMixedWriteAndWritev

test/parallel/test-fs-promises-file-handle-writer.js:62–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60// =============================================================================
61
62async function testMixedWriteAndWritev() {
63 const filePath = path.join(tmpDir, 'writer-mixed.txt');
64 const fh = await open(filePath, 'w');
65 const w = fh.writer();
66 await w.write(Buffer.from('head-'));
67 await w.writev([Buffer.from('mid1-'), Buffer.from('mid2-')]);
68 await w.write(Buffer.from('tail'));
69 const totalBytes = await w.end();
70 await fh.close();
71
72 assert.strictEqual(totalBytes, 19);
73 assert.strictEqual(fs.readFileSync(filePath, 'utf8'), 'head-mid1-mid2-tail');
74}
75
76// =============================================================================
77// end() returns totalBytesWritten

Calls 9

writerMethod · 0.80
openFunction · 0.70
closeMethod · 0.65
joinMethod · 0.45
writeMethod · 0.45
fromMethod · 0.45
writevMethod · 0.45
endMethod · 0.45
readFileSyncMethod · 0.45

Tested by

no test coverage detected