promisified-pipe
v1.0.0
Published
Converts readable and writable Node streams to await-able Promise
Downloads
1,630
Maintainers
Readme
promisified-pipe
npm i promisified-pipe
API
function promisifiedPipe(input: stream.Readable, output: stream.Writable): Promise<void>
Example
Usage example in an Express.js request handler (middleware). This code will send the file from disk back to the browser.
const fs = require("fs");
const promisifiedPipe = require("promisified-pipe");
function downloadFile(req, res, next) {
promisifiedPipe(fs.createReadStream(req.params.file), res).catch(next);
}