A Node.js module to write an empty file asynchronously
const emptyFile = require('empty-file');
const {readFile} = require('fs').promises;
(async () => {
await emptyFile('file/path');
(await readFile('file/path')).length; //=> 0
})();
npm install empty-file
const emptyFile = require('empty-file');
path: string
options: Object
(fs.writeFile
options except for encoding
)
Return: Promise
It writes Buffer.alloc(0)
to a file, replacing the file if it already exists.
- empty-file-callback (callback-style version)
ISC License © 2018 Shinnosuke Watanabe