1.0.1 • Published 4 years ago

delimited-stream v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Delimited Stream

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

By default buffered data is emitted without the delimiter each time the delimiter is encountered. Optionally, the delimiter can be included by passing a value that evaluates to true as the second parameter to the constructor.

Constructor

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

const stream = new DelimitedStream (delimiter)

Optionally a second parameter may be specified, representing whether to include the delimiter in the data. By default, the delimiter is excluded.

// 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
})
1.0.1

4 years ago

1.0.0

4 years ago

0.2.0

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago