%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
'use strict'; // This test makes sure that `writeFile()` always writes from the current // position of the file, instead of truncating the file. const common = require('../common'); const assert = require('assert'); const path = require('path'); const { readFileSync } = require('fs'); const { open } = require('fs').promises; const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); const fn = path.join(tmpdir.path, 'test.txt'); async function writeFileTest() { const handle = await open(fn, 'w'); /* Write only five bytes, so that the position moves to five. */ const buf = Buffer.from('Hello'); const { bytesWritten } = await handle.write(buf, 0, 5, null); assert.strictEqual(bytesWritten, 5); /* Write some more with writeFile(). */ await handle.writeFile('World'); /* New content should be written at position five, instead of zero. */ assert.strictEqual(readFileSync(fn).toString(), 'HelloWorld'); await handle.close(); } writeFileTest() .then(common.mustCall());