Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/node-read-remove-file
Read a file, then remove it
https://github.com/shinnn/node-read-remove-file
Last synced: 26 days ago
JSON representation
Read a file, then remove it
- Host: GitHub
- URL: https://github.com/shinnn/node-read-remove-file
- Owner: shinnn
- License: isc
- Created: 2014-11-17T01:37:52.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-11-04T20:41:40.000Z (about 6 years ago)
- Last Synced: 2024-09-23T07:37:52.902Z (about 2 months ago)
- Language: JavaScript
- Size: 88.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# read-remove-file
[![npm version](https://img.shields.io/npm/v/read-remove-file.svg)](https://www.npmjs.com/package/read-remove-file)
[![Build Status](https://travis-ci.org/shinnn/node-read-remove-file.svg?branch=master)](https://travis-ci.org/shinnn/node-read-remove-file)
[![Coverage Status](https://coveralls.io/repos/github/shinnn/node-read-remove-file/badge.svg?branch=master)](https://coveralls.io/github/shinnn/node-read-remove-file?branch=master)Read a file, then remove it
```javascript
const {access} = require('fs').promises;
const readRemoveFile = require('read-remove-file');(async () => {
const buf = await readRemoveFile('path/to/a/file'); //=>
await access('path/to/a/file'); // Error: ENOENT
})();
```## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).
```
npm install read-remove-file
```## API
```javascript
const readRemoveFile = require('read-remove-file');
```### readRemoveFile(*path* [, *options*])
*path*: `string` `Buffer` `Uint8Array` `URL` (a file path) or `integer` (a file descriptor)
*options*: `Object` or `string` ([`fs.readFile`][readFile] options)
Return: `Promise`It [reads a file][readFile], [removes it](https://nodejs.org/api/fs.html#fs_fs_unlink_path_callback) and returns a `Promise` of the file contents.
## License
[ISC License](./LICENSE) © 2018 Shinnosuke Watanabe
[readFile]: https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback