Skip to content

shinnn/empty-file-callback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

empty-file-callback

NPM version Build Status Coverage Status Dependency Status devDependency Status

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

Use npm.

npm install empty-file-callback

API

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 encoding option.

Related project

License

The Unlicense.

About

Callback style version of empty-file

Resources

License

Stars

Watchers

Forks

Packages

No packages published