diff --git a/README.md b/README.md index 9b1eca9..79b3437 100644 --- a/README.md +++ b/README.md @@ -758,7 +758,7 @@ To use the `Readline` parser, provide a delimiter (defaults to '\n'). Data is em const SerialPort = require('serialport'); const Readline = SerialPort.parsers.Readline; const port = new SerialPort('/dev/tty-usbserial1'); -const parser = port.pipe(Readline({ delimiter: '\r\n' })); +const parser = port.pipe(new Readline({ delimiter: '\r\n' })); parser.on('data', console.log); ``` @@ -767,7 +767,7 @@ To use the `Ready` parser provide a byte start sequence. After the bytes have be const SerialPort = require('serialport'); const Ready = SerialPort.parsers.Ready; const port = new SerialPort('/dev/tty-usbserial1'); -const parser = port.pipe(Ready({ data: 'READY' })); +const parser = port.pipe(new Ready({ data: 'READY' })); parser.on('ready', () => console.log('the ready byte sequence has been received')) parser.on('data', console.log); // all data after READY is received ``` @@ -777,7 +777,7 @@ To use the `Regex` parser provide a regular expression to split the incoming tex const SerialPort = require('serialport'); const Regex = SerialPort.parsers.Regex; const port = new SerialPort('/dev/tty-usbserial1'); -const parser = port.pipe(Regex({ regex: /[\r\n]+/ })); +const parser = port.pipe(new Regex({ regex: /[\r\n]+/ })); parser.on('data', console.log); ``` diff --git a/lib/parsers/index.js b/lib/parsers/index.js index f67f99b..1b8afa1 100644 --- a/lib/parsers/index.js +++ b/lib/parsers/index.js @@ -47,7 +47,7 @@ To use the `Readline` parser, provide a delimiter (defaults to '\n'). Data is em const SerialPort = require('serialport'); const Readline = SerialPort.parsers.Readline; const port = new SerialPort('/dev/tty-usbserial1'); -const parser = port.pipe(Readline({ delimiter: '\r\n' })); +const parser = port.pipe(new Readline({ delimiter: '\r\n' })); parser.on('data', console.log); ``` @@ -56,7 +56,7 @@ To use the `Ready` parser provide a byte start sequence. After the bytes have be const SerialPort = require('serialport'); const Ready = SerialPort.parsers.Ready; const port = new SerialPort('/dev/tty-usbserial1'); -const parser = port.pipe(Ready({ data: 'READY' })); +const parser = port.pipe(new Ready({ data: 'READY' })); parser.on('ready', () => console.log('the ready byte sequence has been received')) parser.on('data', console.log); // all data after READY is received ``` @@ -66,7 +66,7 @@ To use the `Regex` parser provide a regular expression to split the incoming tex const SerialPort = require('serialport'); const Regex = SerialPort.parsers.Regex; const port = new SerialPort('/dev/tty-usbserial1'); -const parser = port.pipe(Regex({ regex: /[\r\n]+/ })); +const parser = port.pipe(new Regex({ regex: /[\r\n]+/ })); parser.on('data', console.log); ``` */