Sha256: db697270e4965d8ae9c3d774c0aa773509df7d284aa3ae570c5041073fb0a932
Contents?: true
Size: 652 Bytes
Versions: 33
Compression:
Stored size: 652 Bytes
Contents
import { isFunction } from "./isFunction.js"; const isAsyncIterable = (value) => (isFunction(value[Symbol.asyncIterator])); async function* readStream(readable) { const reader = readable.getReader(); while (true) { const { done, value } = await reader.read(); if (done) { break; } yield value; } } export const getStreamIterator = (source) => { if (isAsyncIterable(source)) { return source; } if (isFunction(source.getReader)) { return readStream(source); } throw new TypeError("Unsupported data source: Expected either ReadableStream or async iterable."); };
Version data entries
33 entries across 33 versions & 1 rubygems