@sovpro/delimited-stream
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Delimited Stream

A Node.js Transform stream emitting buffered data at each delimiter instance.

Build status for Node.js 8.x and newer

Constructor

The constructor requires a Buffer instance or string value representing the delimiter.

const stream = new DelimitedStream (delimiter)

Buffered data is emitted without the delimiter by default. To keep the delimiter, pass a truthy value as the second parameter.

// include delimiter in data
const stream = new DelimitedStream (delimiter, true)

Example

Instantiate a stream with a newline sequence as the delimiter.

const delimiter = Buffer.from ("\r\n")
const stream = new DelimitedStream (delimiter)
stream.on ('data', (data) => {
  const line = data.toString ('utf8')
  // do stuff
})

Package Sidebar

Install

npm i @sovpro/delimited-stream

Weekly Downloads

7,630

Version

1.1.0

License

MIT

Unpacked Size

7.18 kB

Total Files

6

Last publish

Collaborators

  • sovpro