@serialport/parser-regex
Advanced tools
Comparing version 1.0.5 to 2.0.1
{ | ||
"name": "@serialport/parser-regex", | ||
"main": "regex.js", | ||
"version": "1.0.5", | ||
"dependencies": { | ||
"safe-buffer": "^5.1.1" | ||
"version": "2.0.1", | ||
"engines": { | ||
"node": ">=6.0.0" | ||
}, | ||
@@ -14,4 +14,5 @@ "publishConfig": { | ||
"type": "git", | ||
"url": "git://github.com/node-serialport/parsers.git" | ||
} | ||
"url": "git://github.com/node-serialport/node-serialport.git" | ||
}, | ||
"gitHead": "40a06fb71d659940ed5058316b594b9da9957c2f" | ||
} |
@@ -1,1 +0,1 @@ | ||
See our api docs https://node-serialport.github.io/parsers/RegexParser.html | ||
See our api docs https://node-serialport.github.io/node-serialport/RegexParser.html |
22
regex.js
@@ -1,2 +0,1 @@ | ||
'use strict' | ||
const Transform = require('stream').Transform | ||
@@ -17,9 +16,14 @@ | ||
class RegexParser extends Transform { | ||
constructor (options) { | ||
const opts = Object.assign({ | ||
encoding: 'utf8' | ||
}, options) | ||
constructor(options) { | ||
const opts = Object.assign( | ||
{ | ||
encoding: 'utf8', | ||
}, | ||
options | ||
) | ||
if (opts.regex === undefined) { | ||
throw new TypeError('"options.regex" must be a regular expression pattern or object') | ||
throw new TypeError( | ||
'"options.regex" must be a regular expression pattern or object' | ||
) | ||
} | ||
@@ -36,3 +40,3 @@ | ||
_transform (chunk, encoding, cb) { | ||
_transform(chunk, encoding, cb) { | ||
const data = this.data + chunk | ||
@@ -42,3 +46,3 @@ const parts = data.split(this.regex) | ||
parts.forEach((part) => { | ||
parts.forEach(part => { | ||
this.push(part) | ||
@@ -49,3 +53,3 @@ }) | ||
_flush (cb) { | ||
_flush(cb) { | ||
this.push(this.data) | ||
@@ -52,0 +56,0 @@ this.data = '' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3437
0
5
49
- Removedsafe-buffer@^5.1.1
- Removedsafe-buffer@5.2.1(transitive)