Skip to content

Commit f2adc92

Browse files
authored
fix(client): Conversion to async iterable from Response.body (#114)
1 parent a03486c commit f2adc92

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ async function connect<SingleConnection extends boolean>(
919919
const parse = createParser<SingleConnection>();
920920

921921
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
922-
for await (const chunk of toAsyncIterator(res.body!)) {
922+
for await (const chunk of toAsyncIterable(res.body!)) {
923923
if (typeof chunk === 'string')
924924
throw (error = new Error(`Unexpected string chunk "${chunk}"`)); // set error as fatal indicator
925925

@@ -1031,13 +1031,13 @@ async function connect<SingleConnection extends boolean>(
10311031
}
10321032

10331033
/** Isomorphic ReadableStream to AsyncIterator converter. */
1034-
function toAsyncIterator(
1034+
function toAsyncIterable(
10351035
val: ReadableStream | NodeJS.ReadableStream,
10361036
): AsyncIterable<string | Buffer | Uint8Array> {
10371037
// node stream is already async iterable
10381038
if (typeof Object(val)[Symbol.asyncIterator] === 'function') {
10391039
val = val as NodeJS.ReadableStream;
1040-
return val[Symbol.asyncIterator]();
1040+
return val;
10411041
}
10421042

10431043
// convert web stream to async iterable

0 commit comments

Comments
 (0)