sindresorhus / get-stream

Get a stream as a string, Buffer, ArrayBuffer or array
MIT License
341 stars 33 forks source link

Use for-await #21

Closed sindresorhus closed 1 year ago

sindresorhus commented 6 years ago

When it's in a Node.js version we can target: https://github.com/nodejs/node/commit/61b4d60c5d9694e79069b1680b3736c96a5de501

sindresorhus commented 6 years ago

It's in Node.js now.

mjswensen commented 5 years ago

Hi @sindresorhus ,

Would you still like this issue worked on? If so, what is your goal for updating the implementation to use for-await? Remove the dependency on pump?

sindresorhus commented 5 years ago

Yes, it can be worked on, but we can’t release it until after December when Node.js 8 is no longer LTS, since we need to target Node.js 10 for this. https://github.com/nodejs/Release The goal is to remove the pump dependency and simplify the code.

sindresorhus commented 4 years ago

This can be worked on now.

tiagonapoli commented 4 years ago

I tried to migrate to use for-await here. It worked for PassThrough and fs streams inputs, however for every test that used into-stream it didn't work - the error thrown was:

inputStream is not async iterable
  ✖ get object stream as an array Rejected promise returned by test
  ✖ get non-object stream as an array of strings Rejected promise returned by test
  ✖ get non-object stream as an array of Buffers Rejected promise returned by test
  ✖ getStream should not affect additional listeners attached to the stream Rejected promise returned by test
  ✖ maxBuffer throws a MaxBufferError 
  ✖ maxBuffer applies to length of arrays when in objectMode 
  ✖ maxBuffer throws when size is exceeded 
  ✖ maxBuffer applies to length of data when not in objectMode 
  ✔ Promise rejects when input stream emits an error
  ✔ get stream as a buffer
  ✔ get stream as an array

I didn't investigated it further though to discover why the into-stream streams weren't async iterables.

sindresorhus commented 1 year ago

Fixed in https://github.com/sindresorhus/get-stream/releases/tag/v7.0.0