@serialpilot/parser-regex
v1.0.1
Published
A transform stream that splits incoming text on a regular expression.
Maintainers
Readme
A Transform stream that splits incoming data on a regular expression rather than a fixed delimiter. Handy for protocols whose record separators vary (e.g. one of \r, \n, or \r\n).
npm install @serialpilot/parser-regexUsage
const { SerialPilot, RegexParser } = require('serialpilot')
const port = new SerialPilot({ path: '/dev/ttyUSB0', baudRate: 9600 })
const parser = port.pipe(new RegexParser({ regex: /\r?\n/ }))
parser.on('data', console.log)API
new RegexParser({ regex, encoding })
| Option | Type | Default | Description |
| ---------- | -------- | -------- | ---------------------------------------- |
| regex | RegExp | — | Required. Pattern to split records on. |
| encoding | string | 'utf8' | Text encoding for emitted strings. |
See the SerialPilot README for the full set of parsers.
