stream-now

1.1.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i stream-now

Weekly Downloads

2

Version

1.1.1

License

MIT

Unpacked Size

6.22 kB

Total Files

8

Last publish

Collaborators

  • samvv