Initial commit
This commit is contained in:
21
node_modules/@serialport/parser-ready/LICENSE
generated
vendored
Normal file
21
node_modules/@serialport/parser-ready/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-ready/README.md
generated
vendored
Normal file
3
node_modules/@serialport/parser-ready/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# @serialport/parser-ready
|
||||
|
||||
See our api docs https://serialport.io/docs/api-parser-ready
|
||||
19
node_modules/@serialport/parser-ready/dist/index.d.ts
generated
vendored
Normal file
19
node_modules/@serialport/parser-ready/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { Transform, TransformCallback, TransformOptions } from 'stream';
|
||||
export interface ReadyParserOptions extends TransformOptions {
|
||||
/** delimiter to use to detect the input is ready */
|
||||
delimiter: string | Buffer | number[];
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export declare class ReadyParser extends Transform {
|
||||
delimiter: Buffer;
|
||||
readOffset: number;
|
||||
ready: boolean;
|
||||
constructor({ delimiter, ...options }: ReadyParserOptions);
|
||||
_transform(chunk: Buffer, encoding: BufferEncoding, cb: TransformCallback): void;
|
||||
}
|
||||
53
node_modules/@serialport/parser-ready/dist/index.js
generated
vendored
Normal file
53
node_modules/@serialport/parser-ready/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ReadyParser = void 0;
|
||||
const stream_1 = require("stream");
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
class ReadyParser extends stream_1.Transform {
|
||||
delimiter;
|
||||
readOffset;
|
||||
ready;
|
||||
constructor({ delimiter, ...options }) {
|
||||
if (delimiter === undefined) {
|
||||
throw new TypeError('"delimiter" is not a bufferable object');
|
||||
}
|
||||
if (delimiter.length === 0) {
|
||||
throw new TypeError('"delimiter" has a 0 or undefined length');
|
||||
}
|
||||
super(options);
|
||||
this.delimiter = Buffer.from(delimiter);
|
||||
this.readOffset = 0;
|
||||
this.ready = false;
|
||||
}
|
||||
_transform(chunk, encoding, cb) {
|
||||
if (this.ready) {
|
||||
this.push(chunk);
|
||||
return cb();
|
||||
}
|
||||
const delimiter = this.delimiter;
|
||||
let chunkOffset = 0;
|
||||
while (this.readOffset < delimiter.length && chunkOffset < chunk.length) {
|
||||
if (delimiter[this.readOffset] === chunk[chunkOffset]) {
|
||||
this.readOffset++;
|
||||
}
|
||||
else {
|
||||
this.readOffset = 0;
|
||||
}
|
||||
chunkOffset++;
|
||||
}
|
||||
if (this.readOffset === delimiter.length) {
|
||||
this.ready = true;
|
||||
this.emit('ready');
|
||||
const chunkRest = chunk.slice(chunkOffset);
|
||||
if (chunkRest.length > 0) {
|
||||
this.push(chunkRest);
|
||||
}
|
||||
}
|
||||
cb();
|
||||
}
|
||||
}
|
||||
exports.ReadyParser = ReadyParser;
|
||||
25
node_modules/@serialport/parser-ready/package.json
generated
vendored
Normal file
25
node_modules/@serialport/parser-ready/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@serialport/parser-ready",
|
||||
"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