Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/empty-file
Write an empty file asynchronously
https://github.com/shinnn/empty-file
Last synced: 27 days 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 (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-10T15:35:09.000Z (almost 6 years ago)
- Last Synced: 2024-09-17T16:41:37.785Z (about 2 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
[![npm version](https://img.shields.io/npm/v/empty-file.svg)](https://www.npmjs.com/package/empty-file)
[![Build Status](https://travis-ci.com/shinnn/empty-file.svg?branch=master)](https://travis-ci.com/shinnn/empty-file)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/empty-file.svg)](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