Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/notwoods/promise-stream-utils
Various functions for working with streams inside async functions
https://github.com/notwoods/promise-stream-utils
promise promisify stream
Last synced: 29 days ago
JSON representation
Various functions for working with streams inside async functions
- Host: GitHub
- URL: https://github.com/notwoods/promise-stream-utils
- Owner: NotWoods
- License: mit
- Created: 2017-05-17T19:40:16.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2023-01-06T01:37:33.000Z (almost 2 years ago)
- Last Synced: 2024-04-15T00:01:54.523Z (7 months ago)
- Topics: promise, promisify, stream
- Language: JavaScript
- Homepage:
- Size: 907 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# promise-stream-utils [![Build Status](https://img.shields.io/travis/com/NotWoods/promise-stream-utils.svg)](https://travis-ci.com/NotWoods/promise-stream-utils) [![npm](https://img.shields.io/npm/v/promise-stream-utils.svg)](https://www.npmjs.com/package/promise-stream-utils) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)
Various functions for working with streams inside async functions.
## Awaiting stream events
Creates promises that resolve once the event has fired, and reject if an error
event is fired.### ended
Resolves when the `'end'` event fires, rejects when the `'error'` event fires
```ts
function ended(stream: NodeJS.ReadableStream): Promise;
```### finished
Resolves when the `'finish'` event fires, rejects when the `'error'` event fires
```ts
function finished(stream: NodeJS.WritableStream): Promise;
```## Special stream classes
Special versions of the Readable, Writable, Duplex, and Transform stream classes
where async functions are used rather than functions with a callback.Exported as:
- `PromiseReadable`
- `PromiseWritable`
- `PromiseDuplex`
- `PromiseTransform`Create a stream using these classes by calling `new PromiseReadable(opts)`, and
set the stream function inside options.## Other utility functions
### toBuffer
Loads an entire stream's contents into a buffer in memory
```ts
function toBuffer(stream: NodeJS.ReadableStream): Promise;
```