Callback style version of empty-file
const emptyFileCallback = require('empty-file-callback');
const fs = require('fs');
emptyFileCallback('file/path', err => {
if (err) {
throw err;
}
fs.readFileSync('file/path', 'utf8'); //=> ''
});
npm install empty-file-callback
const emptyFileCallback = require('empty-file-callback');
filePath: String
options: Object
(fs.writeFile
options except for encoding
)
callback: Function
The API is almost the same as fs.writeFile
's, execpt for:
- It only writes
new Buffer(0)
to the file. The data is unchangable. - It doesn't support
encoding
option.
- empty-file (Promises/A+ version)