-
-
Notifications
You must be signed in to change notification settings - Fork 32
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 support for ReadableStream
#82
Conversation
```js | ||
const {body: readableStream} = await fetch('https://example.com'); | ||
console.log(await getStream(readableStream)); | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add this to the TS docs too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 80ac07e. 👍
index.d.ts
Outdated
@@ -6,6 +6,9 @@ export class MaxBufferError extends Error { | |||
constructor(); | |||
} | |||
|
|||
type StreamItem = string | Buffer | ArrayBuffer | ArrayBufferView; | |||
type AnyStream = Readable | ReadableStream<StreamItem> | AsyncIterable<StreamItem>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would export this, in case the user needs to refer to the input without passing it directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 6990861. 👍
This adds support for web/Node.js
ReadableStream
s.This also adds support for any async iterable as input, since this is the common denominator between Node.js streams and web
ReadableStream
(which we just consume with afor await
loop).