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

Version Path
immosquare-cleaner-0.1.60 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.59 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.58 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.57 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.56 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.55 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.54 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.53 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.52 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.51 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.50 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.49 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.48 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.47 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.46 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.45 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.44 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.43 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.42 node_modules/form-data-encoder/lib/util/getStreamIterator.js
immosquare-cleaner-0.1.41 node_modules/form-data-encoder/lib/util/getStreamIterator.js