@serialpilot/parser-readline
v1.0.1
Published
A transform stream that emits a chunk of data each time a newline is received.
Maintainers
Readme
A Transform stream that emits each line of text from the serial port. Built on top of @serialpilot/parser-delimiter with sensible defaults for line-oriented protocols.
npm install @serialpilot/parser-readlineUsage
const { SerialPilot, ReadlineParser } = require('serialpilot')
const port = new SerialPilot({ path: '/dev/ttyUSB0', baudRate: 9600 })
const parser = port.pipe(new ReadlineParser({ delimiter: '\r\n' }))
parser.on('data', line => console.log(line))API
new ReadlineParser({ delimiter, encoding, includeDelimiter })
| Option | Type | Default | Description |
| ------------------ | ---------------------- | ----------- | -------------------------------------- |
| delimiter | string \| Buffer | '\n' | Line terminator. |
| encoding | string | 'utf8' | Text encoding for emitted strings. |
| includeDelimiter | boolean | false | Whether emitted lines include the delimiter. |
Strings are emitted; pipe through another stream if you need raw buffers.
See the SerialPilot README for the full set of parsers.
