https://github.com/shinnn/empty-file
Write an empty file asynchronously
https://github.com/shinnn/empty-file
Last synced: 3 months ago
JSON representation
Write an empty file asynchronously
- Host: GitHub
- URL: https://github.com/shinnn/empty-file
- Owner: shinnn
- License: isc
- Created: 2015-10-26T09:05:12.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-10T15:35:09.000Z (over 6 years ago)
- Last Synced: 2025-03-02T23:35:11.240Z (4 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# empty-file
[](https://www.npmjs.com/package/empty-file)
[](https://travis-ci.com/shinnn/empty-file)
[](https://coveralls.io/github/shinnn/empty-file)A [Node.js](https://nodejs.org/) module to write an empty file asynchronously
```javascript
const emptyFile = require('empty-file');
const {readFile} = require('fs').promises;(async () => {
await emptyFile('file/path');
(await readFile('file/path')).length; //=> 0
})();
```## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).
```
npm install empty-file
```## API
```javascript
const emptyFile = require('empty-file');
```### emptyFile(*path*[, *options*])
*path*: `string`
*options*: `Object` ([`fs.writeFile`](https://nodejs.org/api/fs.html#fs_fspromises_writefile_file_data_options) options except for `encoding`)
Return: `Promise`It writes `Buffer.alloc(0)` to a file, replacing the file if it already exists.
## Related project
* [empty-file-callback](https://github.com/shinnn/empty-file-callback) (callback-style version)
## License
[ISC License](./LICENSE) © 2018 Shinnosuke Watanabe