https://github.com/flash-oss/promisified-pipe
Converts readable and writable Node streams to an await-able Promise
https://github.com/flash-oss/promisified-pipe
Last synced: over 1 year ago
JSON representation
Converts readable and writable Node streams to an await-able Promise
- Host: GitHub
- URL: https://github.com/flash-oss/promisified-pipe
- Owner: flash-oss
- Created: 2020-06-04T00:39:10.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-17T10:26:32.000Z (almost 6 years ago)
- Last Synced: 2025-02-02T16:06:28.133Z (over 1 year ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# promisified-pipe
```shell script
npm i promisified-pipe
```
# API
```ts
function promisifiedPipe(input: stream.Readable, output: stream.Writable): Promise
```
# Example
Usage example in an Express.js request handler (middleware). This code will send the file from disk back to the browser.
```js
const fs = require("fs");
const promisifiedPipe = require("promisified-pipe");
function downloadFile(req, res, next) {
promisifiedPipe(fs.createReadStream(req.params.file), res).catch(next);
}
```