// To use the `ByteLength` parser:
const SerialPort = require('serialport');
const ByteLength = SerialPort.parsers.ByteLength
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
-```
+parser.on('data', console.log); // will have 8 bytes per data event
@@ -285,7 +283,7 @@ parser.on('data', console.log); // will have 8 bytes per data event
diff --git a/docs/CCTalkParser.html b/docs/CCTalkParser.html
index 4dc30ec..146abc5 100644
--- a/docs/CCTalkParser.html
+++ b/docs/CCTalkParser.html
@@ -69,7 +69,7 @@
To use the `Delimiter` parser, provide a delimiter as a string, buffer, or array of bytes:
-```js
+
// To use the `Delimiter` parser, provide a delimiter as a string, buffer, or array of bytes:
const SerialPort = require('serialport');
const Delimiter = SerialPort.parsers.Delimiter;
const port = new SerialPort('/dev/tty-usbserial1');
-const 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'). Data is emitted as string controllable by the `encoding` option (defaults to `utf8`).
-```js
-const SerialPort = require('serialport');
+
To use the `Ready` parser provide a byte start sequence. After the bytes have been received a ready event is fired and data events are passed through.
-```js
-const SerialPort = require('serialport');
+
const SerialPort = require('serialport');
const Ready = SerialPort.parsers.Ready;
const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Ready({ delimiter: 'READY' }));
parser.on('ready', () => console.log('the ready byte sequence has been received'))
-parser.on('data', console.log); // all data after READY is received
-```
+parser.on('data', console.log); // all data after READY is received
@@ -292,7 +290,7 @@ parser.on('data', console.log); // all data after READY is received
diff --git a/docs/RegexParser.html b/docs/RegexParser.html
index 05344f3..56e1d0e 100644
--- a/docs/RegexParser.html
+++ b/docs/RegexParser.html
@@ -43,7 +43,8 @@
RegexParser
-
A transform stream that uses a regular expression to split the incoming text upon.
+
A transform stream that uses a regular expression to split the incoming text upon.
+
To use the Regex parser provide a regular expression to split the incoming text upon. Data is emitted as string controllable by the encoding option (defaults to utf8).
To use the `Regex` parser provide a regular expression to split the incoming text upon. Data is emitted as string controllable by the `encoding` option (defaults to `utf8`).
-```js
-const SerialPort = require('serialport');
+
@@ -187,7 +185,7 @@ parser.on('data', console.log);
diff --git a/docs/SerialPort.html b/docs/SerialPort.html
index fa2868c..b9e1a90 100644
--- a/docs/SerialPort.html
+++ b/docs/SerialPort.html
@@ -2981,7 +2981,7 @@ function writeAndDrain (data, callback) {
diff --git a/docs/bindings_base.js.html b/docs/bindings_base.js.html
index a59a6e3..94b10cb 100644
--- a/docs/bindings_base.js.html
+++ b/docs/bindings_base.js.html
@@ -280,7 +280,7 @@ module.exports = BaseBinding;
diff --git a/docs/bindings_poller.js.html b/docs/bindings_poller.js.html
index 81a5505..94cbfb8 100644
--- a/docs/bindings_poller.js.html
+++ b/docs/bindings_poller.js.html
@@ -151,7 +151,7 @@ module.exports = Poller;
diff --git a/docs/global.html b/docs/global.html
index a83adcf..8d21030 100644
--- a/docs/global.html
+++ b/docs/global.html
@@ -2027,7 +2027,7 @@ port.write('ROBOT PLEASE RESPOND\n');
diff --git a/docs/index.html b/docs/index.html
index dd26ff1..8aa335a 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -465,7 +465,7 @@ null
diff --git a/docs/index.js.html b/docs/index.js.html
index 02b58dc..8660eaa 100644
--- a/docs/index.js.html
+++ b/docs/index.js.html
@@ -65,7 +65,7 @@ module.exports = SerialPort;
diff --git a/docs/parsers_byte-length.js.html b/docs/parsers_byte-length.js.html
index 9a680ea..b58164c 100644
--- a/docs/parsers_byte-length.js.html
+++ b/docs/parsers_byte-length.js.html
@@ -47,14 +47,12 @@ const Transform = require('stream').Transform;
* @param {Object} options parser options object
* @param {Number} options.length the number of bytes on each data event
* @example
-To use the `ByteLength` parser:
-```js
+// To use the `ByteLength` parser:
const SerialPort = require('serialport');
const ByteLength = SerialPort.parsers.ByteLength
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
-```
*/
class ByteLengthParser extends Transform {
constructor(options) {
@@ -109,7 +107,7 @@ module.exports = ByteLengthParser;
diff --git a/docs/parsers_cctalk.js.html b/docs/parsers_cctalk.js.html
index 10fcb1c..82a7a36 100644
--- a/docs/parsers_cctalk.js.html
+++ b/docs/parsers_cctalk.js.html
@@ -44,14 +44,12 @@ const Buffer = require('safe-buffer').Buffer;
* Parses the CCTalk protocol
* @extends Transform
* @example
-CCTalk Messages are emitted as buffers.
-```js
+// CCTalk Messages are emitted as buffers.
const SerialPort = require('serialport');
const CCTalk = SerialPort.parsers.CCTalk;
const port = new SerialPort('/dev/ttyUSB0');
const parser = port.pipe(new CCtalk());
parser.on('data', console.log);
-```
*/
class CCTalkParser extends Transform {
constructor() {
@@ -94,7 +92,7 @@ module.exports = CCTalkParser;
diff --git a/docs/parsers_delimiter.js.html b/docs/parsers_delimiter.js.html
index b2ba812..c889782 100644
--- a/docs/parsers_delimiter.js.html
+++ b/docs/parsers_delimiter.js.html
@@ -44,14 +44,12 @@ const Transform = require('stream').Transform;
* A transform stream that emits data each time a byte sequence is received.
* @extends Transform
* @example
-To use the `Delimiter` parser, provide a delimiter as a string, buffer, or array of bytes:
-```js
+// To use the `Delimiter` parser, provide a delimiter as a string, buffer, or array of bytes:
const SerialPort = require('serialport');
const Delimiter = SerialPort.parsers.Delimiter;
const port = new SerialPort('/dev/tty-usbserial1');
-const parser = port.pipe(new Delimiter({ delimiter: Buffer.from('EOL') }));
+const parser = port.pipe(new Delimiter({ delimiter: '\n' }));
parser.on('data', console.log);
-```
*/
class DelimiterParser extends Transform {
constructor(options) {
@@ -102,7 +100,7 @@ module.exports = DelimiterParser;
diff --git a/docs/parsers_index.js.html b/docs/parsers_index.js.html
index 3bf95e1..7d5d75a 100644
--- a/docs/parsers_index.js.html
+++ b/docs/parsers_index.js.html
@@ -86,7 +86,7 @@ module.exports = {
diff --git a/docs/parsers_readline.js.html b/docs/parsers_readline.js.html
index 6967411..6cbc3db 100644
--- a/docs/parsers_readline.js.html
+++ b/docs/parsers_readline.js.html
@@ -42,16 +42,15 @@ const Buffer = require('safe-buffer').Buffer;
const DelimiterParser = require('./delimiter');
/**
* A transform stream that emits data after a newline delimiter is received.
+ *
+ * To use the `Readline` parser, provide a delimiter (defaults to `\n`). Data is emitted as string controllable by the `encoding` option (defaults to `utf8`).
* @extends DelimiterParser
* @example
-To use the `Readline` parser, provide a delimiter (defaults to '\n'). Data is emitted as string controllable by the `encoding` option (defaults to `utf8`).
-```js
const SerialPort = require('serialport');
const Readline = SerialPort.parsers.Readline;
const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Readline({ delimiter: '\r\n' }));
parser.on('data', console.log);
-```
*/
class ReadLineParser extends DelimiterParser {
constructor(options) {
@@ -81,7 +80,7 @@ module.exports = ReadLineParser;
diff --git a/docs/parsers_ready.js.html b/docs/parsers_ready.js.html
index 0af3d55..773240f 100644
--- a/docs/parsers_ready.js.html
+++ b/docs/parsers_ready.js.html
@@ -42,17 +42,16 @@ const Buffer = require('safe-buffer').Buffer;
const Transform = require('stream').Transform;
/**
* A transform stream that waits for a sequence of "ready" bytes before emitting a ready event and emitting data events
+ *
+ * To use the `Ready` parser provide a byte start sequence. After the bytes have been received a ready event is fired and data events are passed through.
* @extends Transform
* @example
-To use the `Ready` parser provide a byte start sequence. After the bytes have been received a ready event is fired and data events are passed through.
-```js
const SerialPort = require('serialport');
const Ready = SerialPort.parsers.Ready;
const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Ready({ delimiter: 'READY' }));
parser.on('ready', () => console.log('the ready byte sequence has been received'))
parser.on('data', console.log); // all data after READY is received
-```
*/
class ReadyParser extends Transform {
/**
@@ -116,7 +115,7 @@ module.exports = ReadyParser;
diff --git a/docs/parsers_regex.js.html b/docs/parsers_regex.js.html
index a3391f7..f6454ae 100644
--- a/docs/parsers_regex.js.html
+++ b/docs/parsers_regex.js.html
@@ -41,17 +41,15 @@
const Transform = require('stream').Transform;
/**
* A transform stream that uses a regular expression to split the incoming text upon.
+ *
+ * To use the `Regex` parser provide a regular expression to split the incoming text upon. Data is emitted as string controllable by the `encoding` option (defaults to `utf8`).
* @extends Transform
* @example
-To use the `Regex` parser provide a regular expression to split the incoming text upon. Data is emitted as string controllable by the `encoding` option (defaults to `utf8`).
-```js
const SerialPort = require('serialport');
const Regex = SerialPort.parsers.Regex;
const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Regex({ regex: /[\r\n]+/ }));
parser.on('data', console.log);
-```
-
*/
class RegexParser extends Transform {
constructor(options) {
@@ -103,7 +101,7 @@ module.exports = RegexParser;
diff --git a/docs/serialport.js.html b/docs/serialport.js.html
index 008d665..32065b7 100644
--- a/docs/serialport.js.html
+++ b/docs/serialport.js.html
@@ -684,7 +684,7 @@ module.exports = SerialPort;
diff --git a/lib/parsers/byte-length.js b/lib/parsers/byte-length.js
index cd7cb50..91271be 100644
--- a/lib/parsers/byte-length.js
+++ b/lib/parsers/byte-length.js
@@ -8,14 +8,12 @@ const Transform = require('stream').Transform;
* @param {Object} options parser options object
* @param {Number} options.length the number of bytes on each data event
* @example
-To use the `ByteLength` parser:
-```js
+// To use the `ByteLength` parser:
const SerialPort = require('serialport');
const ByteLength = SerialPort.parsers.ByteLength
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
-```
*/
class ByteLengthParser extends Transform {
constructor(options) {
diff --git a/lib/parsers/cctalk.js b/lib/parsers/cctalk.js
index e895f86..de03a6c 100644
--- a/lib/parsers/cctalk.js
+++ b/lib/parsers/cctalk.js
@@ -5,14 +5,12 @@ const Buffer = require('safe-buffer').Buffer;
* Parses the CCTalk protocol
* @extends Transform
* @example
-CCTalk Messages are emitted as buffers.
-```js
+// CCTalk Messages are emitted as buffers.
const SerialPort = require('serialport');
const CCTalk = SerialPort.parsers.CCTalk;
const port = new SerialPort('/dev/ttyUSB0');
const parser = port.pipe(new CCtalk());
parser.on('data', console.log);
-```
*/
class CCTalkParser extends Transform {
constructor() {
diff --git a/lib/parsers/delimiter.js b/lib/parsers/delimiter.js
index f9b7475..5653e7e 100644
--- a/lib/parsers/delimiter.js
+++ b/lib/parsers/delimiter.js
@@ -5,14 +5,12 @@ const Transform = require('stream').Transform;
* A transform stream that emits data each time a byte sequence is received.
* @extends Transform
* @example
-To use the `Delimiter` parser, provide a delimiter as a string, buffer, or array of bytes:
-```js
+// To use the `Delimiter` parser, provide a delimiter as a string, buffer, or array of bytes:
const SerialPort = require('serialport');
const Delimiter = SerialPort.parsers.Delimiter;
const port = new SerialPort('/dev/tty-usbserial1');
-const parser = port.pipe(new Delimiter({ delimiter: Buffer.from('EOL') }));
+const parser = port.pipe(new Delimiter({ delimiter: '\n' }));
parser.on('data', console.log);
-```
*/
class DelimiterParser extends Transform {
constructor(options) {
diff --git a/lib/parsers/readline.js b/lib/parsers/readline.js
index 3484371..c463f4b 100644
--- a/lib/parsers/readline.js
+++ b/lib/parsers/readline.js
@@ -3,16 +3,15 @@ const Buffer = require('safe-buffer').Buffer;
const DelimiterParser = require('./delimiter');
/**
* A transform stream that emits data after a newline delimiter is received.
+ *
+ * To use the `Readline` parser, provide a delimiter (defaults to `\n`). Data is emitted as string controllable by the `encoding` option (defaults to `utf8`).
* @extends DelimiterParser
* @example
-To use the `Readline` parser, provide a delimiter (defaults to '\n'). Data is emitted as string controllable by the `encoding` option (defaults to `utf8`).
-```js
const SerialPort = require('serialport');
const Readline = SerialPort.parsers.Readline;
const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Readline({ delimiter: '\r\n' }));
parser.on('data', console.log);
-```
*/
class ReadLineParser extends DelimiterParser {
constructor(options) {
diff --git a/lib/parsers/ready.js b/lib/parsers/ready.js
index c953ba7..e349554 100644
--- a/lib/parsers/ready.js
+++ b/lib/parsers/ready.js
@@ -3,17 +3,16 @@ const Buffer = require('safe-buffer').Buffer;
const Transform = require('stream').Transform;
/**
* A transform stream that waits for a sequence of "ready" bytes before emitting a ready event and emitting data events
+ *
+ * To use the `Ready` parser provide a byte start sequence. After the bytes have been received a ready event is fired and data events are passed through.
* @extends Transform
* @example
-To use the `Ready` parser provide a byte start sequence. After the bytes have been received a ready event is fired and data events are passed through.
-```js
const SerialPort = require('serialport');
const Ready = SerialPort.parsers.Ready;
const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Ready({ delimiter: 'READY' }));
parser.on('ready', () => console.log('the ready byte sequence has been received'))
parser.on('data', console.log); // all data after READY is received
-```
*/
class ReadyParser extends Transform {
/**
diff --git a/lib/parsers/regex.js b/lib/parsers/regex.js
index fa4031b..977d04b 100644
--- a/lib/parsers/regex.js
+++ b/lib/parsers/regex.js
@@ -2,17 +2,15 @@
const Transform = require('stream').Transform;
/**
* A transform stream that uses a regular expression to split the incoming text upon.
+ *
+ * To use the `Regex` parser provide a regular expression to split the incoming text upon. Data is emitted as string controllable by the `encoding` option (defaults to `utf8`).
* @extends Transform
* @example
-To use the `Regex` parser provide a regular expression to split the incoming text upon. Data is emitted as string controllable by the `encoding` option (defaults to `utf8`).
-```js
const SerialPort = require('serialport');
const Regex = SerialPort.parsers.Regex;
const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Regex({ regex: /[\r\n]+/ }));
parser.on('data', console.log);
-```
-
*/
class RegexParser extends Transform {
constructor(options) {