Skip to content

Write an empty file asynchronously

License

Notifications You must be signed in to change notification settings

shinnn/empty-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Write an empty file asynchronously

Resources

License

Stars

Watchers

Forks

Packages

No packages published