(it: AsyncIterable<T>)
| 361 | } |
| 362 | |
| 363 | function iterableToReadableStream<T>(it: AsyncIterable<T>): ReadableStream<T> { |
| 364 | const iterator = it[Symbol.asyncIterator](); |
| 365 | return new ReadableStream<T>({ |
| 366 | async pull(controller) { |
| 367 | const { value, done } = await iterator.next(); |
| 368 | if (done) controller.close(); |
| 369 | else controller.enqueue(value); |
| 370 | }, |
| 371 | async cancel(reason) { |
| 372 | if (iterator.return) await iterator.return(reason as undefined); |
| 373 | }, |
| 374 | }); |
| 375 | } |
no outgoing calls
no test coverage detected