thenstream
Construct a Readable stream from a thenable. Useful if you don't have the actual stream yet.
Installation
npm install thenstream
Usage
With Legendary installed:
var Thenstream = ;var Promise = Promise; var p = { ;}; var readable = preadable;
API
thenstream
exports a single class, Thenstream
.
new thenstream.Thenstream(thenable)
Subclass of stream.Readable
. Can be called without new
.
The returned stream is immediately readable, but no data will be available until
thenable
fulfils with a readable stream. The thenable is assimilated along the
lines of the Promise Resolution Procedure.
Any error in assimilation will be emitted (after the constructor has returned)
as an error
event. Similarly an error
event will be emitted if the thenable
does not fulfil with something that looks like a readable stream.
Note: thenables-for-thenables are not supported. If you need to handle such thenables you should wrap them using your promise library of choice, prior to creating the thenstream. Legendary would be a great choice.