Skip to content

Latest commit

 

History

History
47 lines (31 loc) · 1.3 KB

README.md

File metadata and controls

47 lines (31 loc) · 1.3 KB

empty-file

npm version Build Status Coverage Status

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
})();

Installation

Use npm.

npm install empty-file

API

const emptyFile = require('empty-file');

emptyFile(path[, options])

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.

Related project

License

ISC License © 2018 Shinnosuke Watanabe