Skip to content

Commit

Permalink
assertNonNull for async iterator result is no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
gfx committed Feb 12, 2025
1 parent d02b9c3 commit 1fe0b5b
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/utils/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ export function isAsyncIterable<T>(object: ReadableStreamLike<T>): object is Asy
return (object as any)[Symbol.asyncIterator] != null;
}

function assertNonNull<T>(value: T | null | undefined): asserts value is T {
if (value == null) {
throw new Error("Assertion Failure: value must not be null nor undefined");
}
}

export async function* asyncIterableFromStream<T>(stream: ReadableStream<T>): AsyncIterable<T> {
const reader = stream.getReader();

Expand All @@ -25,7 +19,6 @@ export async function* asyncIterableFromStream<T>(stream: ReadableStream<T>): As
if (done) {
return;
}
assertNonNull(value);
yield value;
}
} finally {
Expand Down

0 comments on commit 1fe0b5b

Please sign in to comment.