Skip to content

Converts readable and writable Node streams to an await-able Promise

Notifications You must be signed in to change notification settings

flash-oss/promisified-pipe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

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

About

Converts readable and writable Node streams to an await-able Promise

Resources

Stars

Watchers

Forks

Packages

No packages published