Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

readable-stream-clone

0.0.7 • Public • Published

Readable Stream Clone

npm install readable-stream-clone

with this utility you can pipe readable stream into multiple writable streams

Node

const fs = require("fs");
const ReadableStreamClone = require("readable-stream-clone");
 
const readStream = fs.createReadStream('text.txt');
 
const readStream1 = new ReadableStreamClone(readStream);
const readStream2 = new ReadableStreamClone(readStream);
 
const writeStream1 = fs.createWriteStream('sample1.txt');
const writeStream2 = fs.createWriteStream('sample2.txt');
 
readStream1.pipe(writeStream1)
readStream2.pipe(writeStream2)

Typescript

import * as fs from 'fs';
import ReadableStreamClone from 'readable-stream-clone'
 
const readStream = fs.createReadStream('text.txt');
 
const readClone1 = new ReadableStreamClone(readStream);
const readClone2 = new ReadableStreamClone(readStream);
 
const writeStream1 = fs.createWriteStream("text1.txt");
const writeStream2 = fs.createWriteStream("text2.txt");
 
readClone1.pipe(writeStream1);
readClone2.pipe(writeStream2);

Install

npm i readable-stream-clone

DownloadsWeekly Downloads

551

Version

0.0.7

License

none

Unpacked Size

8.32 kB

Total Files

5

Last publish

Collaborators

  • avatar