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

Function testStartOption

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

Source from the content-addressed store, hash-verified

135// =============================================================================
136
137async function testStartOption() {
138 const filePath = path.join(tmpDir, 'writer-start.txt');
139 // Pre-fill with 10 A's
140 fs.writeFileSync(filePath, 'AAAAAAAAAA');
141
142 const fh = await open(filePath, 'r+');
143 const w = fh.writer({ start: 3 });
144 await w.write(Buffer.from('BBB'));
145 await w.end();
146 await fh.close();
147
148 assert.strictEqual(fs.readFileSync(filePath, 'utf8'), 'AAABBBAAAA');
149}
150
151// =============================================================================
152// start option - sequential writes advance position

Calls 9

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

Tested by

no test coverage detected