1.0.2 • Published 7 years ago
p-temp-stream v1.0.2
p-temp-stream
A Writable stream that writes to a teporary file. That tmpfile can then be used in one of 2 ways.
- Move the file to another location
- Get a Readable stream to retrieve the data
Whatever the case, the tempfile is cleaned up once the data is consumed or by calling
cleanup()
explicitly.
const tmpstream = TempFileStream();
tmpstream.moveFile(Path.join(__dirname, 'archive')).then(()=>console.log('file moved'));
process.stdin.pipe(tmpstream);
const tmpstream = TempFileStream();
tmpstream.readStream().then((stream)=>stream.pipe(process.stderr));
process.stdin.pipe(tmpstream);