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

Function testBasicWrite

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

Source from the content-addressed store, hash-verified

23// =============================================================================
24
25async function testBasicWrite() {
26 const filePath = path.join(tmpDir, 'writer-basic.txt');
27 const fh = await open(filePath, 'w');
28 const w = fh.writer();
29 await w.write(Buffer.from('Hello '));
30 await w.write(Buffer.from('World!'));
31 const totalBytes = await w.end();
32 await fh.close();
33
34 assert.strictEqual(totalBytes, 12);
35 assert.strictEqual(fs.readFileSync(filePath, 'utf8'), 'Hello World!');
36}
37
38// =============================================================================
39// Basic writev()

Calls 8

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

Tested by

no test coverage detected