stream-now
v1.1.1
Published
Convert a promised stream into a real stream.
Downloads
3
Readme
In those rare cases that your method returns promise with a stream (which it really shouldn't), this little utility will convert it into a regular stream, the way it should be.
✨ Now with full support for TypeScript!
🔍 Found an issue? Please report it in the issue tracker so we can take care of it!
const fs = require('fs')
const streamNow = require('stream-now')
async function init() {
await doSomethingSpecial();
return createReadableStreamSomehow();
}
const stream = streamNow.readable(init());
// this will only start emitting when the promise is resolved
stream.on('data', (chunk, enc) => {
})
API
streamNow.readable(promise, opts?)
Create a new readable stream out of the promised readable stream.
You must pass in { objectMode: true }
if your promised stream works with
objects instead of string data. There is no simple way to circumvent this
limitation.
streamNow.writable(promise, opts?)
Create a new writable stream out of the promised writable stream.
You must pass in { objectMode: true }
if your promised stream works with
objects instead of string data. There is no simple way to circumvent this
limitation.
License
The MIT license