Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 510 Bytes

README.md

File metadata and controls

24 lines (17 loc) · 510 Bytes

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);
}