An open API service indexing awesome lists of open source software.

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

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