@janvanbouwel/chunked-stream

0.2.2 • Public • Published

Chunked Stream

Transforms a binary stream into an Object mode stream.

Usage

// original duplex stream, for example a TCP connection
const duplex = new PassThrough();

// wrap duplex
const chunked = createChunkedStream(duplex);

// handle messages, object mode
chunked.on("data", (data) => {
  console.log(data);
});

// write data as either a Buffer or an array of Buffers.
duplex.write(Buffer.from("abc"));
duplex.write([Buffer.from("abc"), Buffer.from("def")]);

Dependents (1)

Package Sidebar

Install

npm i @janvanbouwel/chunked-stream

Weekly Downloads

0

Version

0.2.2

License

ISC

Unpacked Size

9.84 kB

Total Files

14

Last publish

Collaborators

  • janvanbouwel