1.0.0 • Published 10 years ago
empty-file-callback v1.0.0
empty-file-callback
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'); //=> ''
});Installation
npm install empty-file-callbackAPI
const emptyFileCallback = require('empty-file-callback');emptyFileCallback(filePath , options, 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 encodingoption.
Related project
- empty-file (Promises/A+ version)