read-remove-file
v5.0.1 file fs read remove removal rm delete clean tmp and 5 more...
read-remove-file
Read a file, then remove it
const readRemoveFile = require('read-remove-file');
readRemoveFile('path/to/file').then(buf => {
buf; //=> <Buffer ... >
fs.accessSync('path/to/file'); // Error: ENOENT
});
Installation
npm install read-remove-file
API
const readRemoveFile = require('read-remove-file');
readRemoveFile(filePath [, options])
filePath: String
options: Object
or String
(fs.readFile
options)
Return: Promise
It reads a file, removes the file and returns a promise of the file contents.
readRemoveFile('path/to/file', 'utf8').then(str => {
str; //=> 'file contents'
fs.accessSync('path/to/file'); // Error: ENOENT
});
License
ISC License © 2018 Shinnosuke Watanabe
npm i read-remove-file
Metadata
- ISC
- Whatever
- Shinnosuke Watanabe
- released 5/7/2018