mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-26 02:47:17 +00:00
24 lines
605 B
JavaScript
24 lines
605 B
JavaScript
'use strict';
|
|
var DelimiterParser = require('./parser-delimiter');
|
|
var inherits = require('inherits');
|
|
|
|
function ReadlineParser(options) {
|
|
if (!(this instanceof ReadlineParser)) {
|
|
return new ReadlineParser(options);
|
|
}
|
|
|
|
options = options || {};
|
|
|
|
if (options.delimiter === undefined) {
|
|
options.delimiter = new Buffer('\n', 'utf8');
|
|
}
|
|
|
|
DelimiterParser.call(this, options);
|
|
|
|
var encoding = options.encoding || 'utf8';
|
|
this.delimiter = new Buffer(options.delimiter, encoding);
|
|
this.setEncoding(encoding);
|
|
}
|
|
|
|
inherits(ReadlineParser, DelimiterParser);
|
|
module.exports = ReadlineParser;
|