@serialpilot/parser-byte-length
v1.0.1
Published
A transform stream that emits data as a buffer of fixed byte length.
Downloads
13,995
Maintainers
Readme
A Transform stream that emits data every time a fixed number of bytes have been received.
npm install @serialpilot/parser-byte-lengthUsage
const { SerialPilot, ByteLengthParser } = require('serialpilot')
const port = new SerialPilot({ path: '/dev/ttyUSB0', baudRate: 9600 })
const parser = port.pipe(new ByteLengthParser({ length: 8 }))
parser.on('data', console.log) // emits an 8-byte Buffer each timeAPI
new ByteLengthParser({ length })
| Option | Type | Description |
| -------- | ------ | --------------------------------------------------- |
| length | number | Required. Number of bytes per emitted chunk (>= 1). |
Throws if length is missing, zero, negative, or non-numeric.
See the SerialPilot README for the full set of parsers.
