1.0.1 • Published 10 months ago

streamx-clone v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

streamx-clone

Clone the readable component of a streamx stream.

Installation

npm install streamx-clone --save

Example

import { clone } from "streamx-clone";
import { Readable } from "streamx";

const messages = ["Hello, ", "World!"];
const readable = new Readable({
    read(cb) {
        let msg;
        while (msg = messages.shift()) {
            this.push(msg);
        }
        this.push(null);
        cb();
    },
});

const cloneStream = clone(readable);

let data = "";
cloneStream.on("data", (chunk) => {
    data += chunk.toString();
});

cloneStream.once("end", () => {
    data === "Hello, World!";
});

Distributed under the MIT license. See LICENSE for more information.

1.0.1

10 months ago

1.0.0

10 months ago