npm i promisified-pipe
function promisifiedPipe(input: stream.Readable, output: stream.Writable): Promise<void>
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);
}