Initial commit
This commit is contained in:
21
node_modules/@serialport/parser-regex/LICENSE
generated
vendored
Normal file
21
node_modules/@serialport/parser-regex/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2010 Christopher Williams. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
3
node_modules/@serialport/parser-regex/README.md
generated
vendored
Normal file
3
node_modules/@serialport/parser-regex/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# @serialport/parser-regex
|
||||
|
||||
See our api docs https://serialport.io/docs/api-parser-regex
|
||||
21
node_modules/@serialport/parser-regex/dist/index.d.ts
generated
vendored
Normal file
21
node_modules/@serialport/parser-regex/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { Transform, TransformCallback, TransformOptions } from 'stream';
|
||||
export interface RegexParserOptions extends TransformOptions {
|
||||
/** The regular expression to use to split incoming text */
|
||||
regex: RegExp | string | Buffer;
|
||||
/** Defaults to utf8 */
|
||||
encoding?: BufferEncoding;
|
||||
}
|
||||
/**
|
||||
* 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`).
|
||||
*/
|
||||
export declare class RegexParser extends Transform {
|
||||
regex: RegExp;
|
||||
data: string;
|
||||
constructor({ regex, ...options }: RegexParserOptions);
|
||||
_transform(chunk: string, encoding: BufferEncoding, cb: TransformCallback): void;
|
||||
_flush(cb: TransformCallback): void;
|
||||
}
|
||||
43
node_modules/@serialport/parser-regex/dist/index.js
generated
vendored
Normal file
43
node_modules/@serialport/parser-regex/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RegexParser = void 0;
|
||||
const stream_1 = require("stream");
|
||||
/**
|
||||
* 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`).
|
||||
*/
|
||||
class RegexParser extends stream_1.Transform {
|
||||
regex;
|
||||
data;
|
||||
constructor({ regex, ...options }) {
|
||||
const opts = {
|
||||
encoding: 'utf8',
|
||||
...options,
|
||||
};
|
||||
if (regex === undefined) {
|
||||
throw new TypeError('"options.regex" must be a regular expression pattern or object');
|
||||
}
|
||||
if (!(regex instanceof RegExp)) {
|
||||
regex = new RegExp(regex.toString());
|
||||
}
|
||||
super(opts);
|
||||
this.regex = regex;
|
||||
this.data = '';
|
||||
}
|
||||
_transform(chunk, encoding, cb) {
|
||||
const data = this.data + chunk;
|
||||
const parts = data.split(this.regex);
|
||||
this.data = parts.pop() || '';
|
||||
parts.forEach(part => {
|
||||
this.push(part);
|
||||
});
|
||||
cb();
|
||||
}
|
||||
_flush(cb) {
|
||||
this.push(this.data);
|
||||
this.data = '';
|
||||
cb();
|
||||
}
|
||||
}
|
||||
exports.RegexParser = RegexParser;
|
||||
25
node_modules/@serialport/parser-regex/package.json
generated
vendored
Normal file
25
node_modules/@serialport/parser-regex/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@serialport/parser-regex",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"version": "12.0.0",
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "tsc --build tsconfig-build.json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/serialport/node-serialport.git"
|
||||
},
|
||||
"funding": "https://opencollective.com/serialport/donate",
|
||||
"devDependencies": {
|
||||
"typescript": "5.2.2"
|
||||
},
|
||||
"gitHead": "f7e7bd53f9578a26c4f44cc1949fef396dc064c7"
|
||||
}
|
||||
Reference in New Issue
Block a user