Buckets:
| import { ReadableStreamLike } from '../types'; | |
| import { isFunction } from './isFunction'; | |
| export async function* readableStreamLikeToAsyncGenerator<T>(readableStream: ReadableStreamLike<T>): AsyncGenerator<T> { | |
| const reader = readableStream.getReader(); | |
| try { | |
| while (true) { | |
| const { value, done } = await reader.read(); | |
| if (done) { | |
| return; | |
| } | |
| yield value!; | |
| } | |
| } finally { | |
| reader.releaseLock(); | |
| } | |
| } | |
| export function isReadableStreamLike<T>(obj: any): obj is ReadableStreamLike<T> { | |
| // We don't want to use instanceof checks because they would return | |
| // false for instances from another Realm, like an <iframe>. | |
| return isFunction(obj?.getReader); | |
| } | |
Xet Storage Details
- Size:
- 704 Bytes
- Xet hash:
- bfeec2117e3e5c25297d5822c72fe691d144eb3517ade218b214a1921c327293
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.