Found this in the docs for node serialport:
Event: "data"
The data event puts the port in flowing mode. Data is emitted as soon as it's received. Data is a Buffer object with a varying amount of data in it. The readLine parser converts the data into string lines. See the parsers section for more information on parsers, and the Node.js stream documentation for more information on the data event.
Kind: event emitted by SerialPort
(https://github.com/EmergingTechnologyAdvisors/node-serialport/blob/5.0.0-beta8/README.md#module_serialport--SerialPort+event_data)
Which points you to this:
(https://github.com/EmergingTechnologyAdvisors/node-serialport/blob/5.0.0-beta8/README.md#module_serialport--SerialPort.parsers)
SerialPort.parsers : object
The default Parsers are Transform streams that parse data in different ways to transform incoming data.
To use the parsers, you must create them and then pipe the Serialport to the parser. Be careful to only write to the SerialPort object and not the parser.
Examples from the docs:
Example
var SerialPort = require('serialport');
var Readline = SerialPort.parsers.Readline;
var port = new SerialPort('/dev/tty-usbserial1');
var parser = new Readline();
port.pipe(parser);
parser.on('data', console.log);
port.write('ROBOT PLEASE RESPOND\n');
// Creating the parser and piping can be shortened to
var parser = port.pipe(new Readline());
To use the ByteLength parser, provide the length of the number of bytes:
var SerialPort = require('serialport');
var ByteLength = SerialPort.parsers.ByteLength
var port = new SerialPort('/dev/tty-usbserial1');
var parser = port.pipe(new ByteLength({length: 8}));
parser.on('data', console.log);
To use the Delimiter parser, provide a delimiter as a string, buffer, or array of bytes:
var SerialPort = require('serialport');
var Delimiter = SerialPort.parsers.Delimiter;
var port = new SerialPort('/dev/tty-usbserial1');
var parser = port.pipe(new Delimiter({delimiter: Buffer.from('EOL')}));
parser.on('data', console.log);
To use the Readline parser, provide a delimiter (defaults to '\n')
var SerialPort = require('serialport');
var Readline = SerialPort.parsers.Readline;
var port = new SerialPort('/dev/tty-usbserial1');
var parser = port.pipe(Readline({delimiter: '\r\n'}));
parser.on('data', console.log);
To use the Ready parser provide a byte start sequence. After the bytes have been received data events will be passed through.
var SerialPort = require('serialport');
var Ready = SerialPort.parsers.Ready;
var port = new SerialPort('/dev/tty-usbserial1');
var parser = port.pipe(Ready({data: 'READY'}));
parser.on('data', console.log); // all data after READY is received