Promise that shares Node.js Stream interface
Last updated a year ago by medikoo .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install stream-promise 
SYNC missed versions from official npm registry.

*nix build status Windows build status Tests coverage Transpilation status npm version


Convert any Stream instance to thenable

So it can be consumed both as a promise and as a stream


npm install stream-promise


Stream must be either readable or writable.

In case of readable streams, promise resolves with concatenated output, in case of writable streams resolve with undefined

To achieve expected result stream should be converted immediately after initialization.

const streamPromise = require("stream-promise");


someReadableStream.then(result => { console.log("Concatenated stream output", result); });


someReadableStream.then(result => { console.log("Cumulated stream output", result); });

Already emitted data is accessible at emittedData property

Non-destructive way

Sepearate promise (without touching stream object) can be created with to-promise util:

const streamToPromise = require("stream-promise/to-promise");

const someReadableStreamPromise = streamPromiseTo(someReadableStream);

someReadableStreamPromise.then(result => { console.log("Concatenated stream output", result); });

Supported options

noCollect boolean (default: false)

Applicable to readable streams. Set to true, if it's not intended to gather stream result and resolve with it.

Then the only purpose of promise would be to indicate a moment when data stream is finalized


npm test

Current Tags

  • 3.2.0                                ...           latest (a year ago)

5 Versions

  • 3.2.0                                ...           a year ago
  • 3.1.0                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Today 4
This Week 180
This Month 1,035
Last Day 26
Last Week 265
Last Month 1,064
Dependencies (3)
Dev Dependencies (9)

Copyright 2014 - 2016 © |