node-serialport-bindings-cpp/docs/api-parser-byte-length.md
Francis Gulotta 4318c25383
docs: New docs system (#1647)
- remove old docs
- docusaurus docs
- guides
- api docs
- basic homepage
2018-09-09 05:12:19 -04:00

637 B

id title
api-parser-byte-length ByteLength Parser
new ByteLength(options)

Emit data every number of bytes.

A transform stream that emits data as a buffer after a specific number of bytes are received. Runs in O(n) time.

Arguments

  • options.length: number the number of bytes to be emitted on each data event

Example

const SerialPort = require('serialport')
const ByteLength = require('@serialport/parser-byte-length')
const port = new SerialPort('/dev/tty-usbserial1')

const parser = port.pipe(new ByteLength({length: 8}))
parser.on('data', console.log) // will have 8 bytes per data event