promise-stream-utils
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

promise-stream-utils Build Status npm PRs Welcome

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

function ended(stream: NodeJS.ReadableStream): Promise<void>;

finished

Resolves when the 'finish' event fires, rejects when the 'error' event fires

function finished(stream: NodeJS.WritableStream): Promise<void>;

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

function toBuffer(stream: NodeJS.ReadableStream): Promise<Buffer>;

Readme

Keywords

none

Package Sidebar

Install

npm i promise-stream-utils

Weekly Downloads

10

Version

1.1.0

License

MIT

Unpacked Size

34.4 kB

Total Files

8

Last publish

Collaborators

  • notwoods