Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add streams into yieldable list #325

Open
andreytkachenko opened this issue Apr 26, 2018 · 2 comments
Open

Add streams into yieldable list #325

andreytkachenko opened this issue Apr 26, 2018 · 2 comments

Comments

@andreytkachenko
Copy link

Hi,
I think it will be nice to be able yielding the streams (it will be waiting the stream "end" event) as well.

@IdpugantiSanjay
Copy link

@andreytkachenko Can you elaborate more ?

@andreytkachenko
Copy link
Author

Current yieldable list are:

  • promises
  • thunks (functions)
  • array (parallel execution)
  • objects (parallel execution)
  • generators (delegation)
  • generator functions (delegation)
    I am suggesting add streams in that list as well. It is possible to promisify stream like that:
const promisify = (readable) => {
  const result = []
  const w = new Writable({
    write(chunk, encoding, callback) {·
      result.push(chunk)
      callback()
    }
  })
  readable.pipe(w)
  return new Promise((resolve, reject) => {
    w.on('finish', resolve)
    w.on('error', reject)
  }).then(() => result.join(''))
}

and then yield them, but it would be great to just yield them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants