All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist-es.splitStream.js Maven / Gradle / Ivy

Go to download

[![NPM version](https://img.shields.io/npm/v/@smithy/util-stream/latest.svg)](https://www.npmjs.com/package/@smithy/util-stream) [![NPM downloads](https://img.shields.io/npm/dm/@smithy/util-stream.svg)](https://www.npmjs.com/package/@smithy/util-stream)

The newest version!
import { PassThrough } from "stream";
import { splitStream as splitWebStream } from "./splitStream.browser";
import { isReadableStream } from "./stream-type-check";
export async function splitStream(stream) {
    if (isReadableStream(stream)) {
        return splitWebStream(stream);
    }
    const stream1 = new PassThrough();
    const stream2 = new PassThrough();
    stream.pipe(stream1);
    stream.pipe(stream2);
    return [stream1, stream2];
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy