3 ms·
Firefox is the only browser that implements it. For all the others you need this sort of machinery: async function* AsAsyncIterable<T>( readable: Readabl
by explaininjs 3y ago
Firefox is the only browser that implements it. For all the others you need this sort of machinery:
async function* AsAsyncIterable<T>(
readable: ReadableStream<T>,
): AsyncIterable<T> {
const reader = readable.getReader()
try {
while (true) {
const { done, value } = await reader.read()
if (done) return
yield value
}
} finally {
reader.releaseLock()
}
}