@stream-toolbox/join
v1.0.0
Published
Join multiple readable streams (or Buffers) into one readable stream.
Downloads
6
Maintainers
Readme
@stream-toolbox/join
🔗 Join multiple readable streams (or Buffers) into one readable stream.
Installation
npm i @stream-toolbox/join
Quick Start
const join = require("@stream-toolbox/join");
const { createReadStream, createWriteStream } = require("fs");
const readable = join([
createReadStream("a_file"),
createReadStream("b_file"),
createReadStream("c_file")
]);
readable.pipe(createWriteStream("joined_file"));
API
join(sources: (Buffer | string | Readable)[], separator?: Buffer | string): Readable;
sources
: An Array contiansBuffer
,string
orReadable
,string
will be treated asutf-8
encoded.separator
: Optional, can beBuffer
orstring
,string
will be treated asutf-8
encoded.join(["foo", "bar", "baz"], "_"); // foo_bar_baz
安装
npm i @stream-toolbox/join
快速开始
const join = require("@stream-toolbox/join");
const { createReadStream, createWriteStream } = require("fs");
const readable = join([
createReadStream("a_file"),
createReadStream("b_file"),
createReadStream("c_file")
]);
readable.pipe(createWriteStream("joined_file"));
API
join(sources: (Buffer | string | Readable)[], separator?: Buffer | string): Readable;
sources
: 一个包含了Buffer
,string
或Readable
的数组,string
按照utf-8
编码处理.separator
: 可选, 类型是Buffer
或string
,string
按照utf-8
编码处理.join(["foo", "bar", "baz"], "_"); // foo_bar_baz