Skip to content

Commit

Permalink
fix: restore old stream conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Jan 11, 2023
1 parent f70d49f commit d7495e4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,23 @@ const fromStream = (source) => {
}

if (isWebReadableStream(source)) {
return browserReableStreamToIt(source)
const reader = source.getReader()
return (async function * () {
try {
while (true) {
// Read from the stream
const { done, value } = await reader.read()
// Exit if we're done
if (done) return
// Else yield the chunk
if (value) {
yield value
}
}
} finally {
reader.releaseLock()
}
})()
}

throw new TypeError('Body can\'t be converted to AsyncIterable')
Expand Down

0 comments on commit d7495e4

Please sign in to comment.