Dia antes primera install
This commit is contained in:
21
node_modules/@serialport/parser-cctalk/LICENSE
generated
vendored
Normal file
21
node_modules/@serialport/parser-cctalk/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-cctalk/README.md
generated
vendored
Normal file
3
node_modules/@serialport/parser-cctalk/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# @serialport/parser-cctalk
|
||||
|
||||
See our api docs https://serialport.io/docs/api-parser-cctalk
|
||||
17
node_modules/@serialport/parser-cctalk/dist/index.d.ts
generated
vendored
Normal file
17
node_modules/@serialport/parser-cctalk/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { Transform, TransformCallback } from 'stream';
|
||||
/**
|
||||
* Parse the CCTalk protocol
|
||||
* @extends Transform
|
||||
*
|
||||
* A transform stream that emits CCTalk packets as they are received.
|
||||
*/
|
||||
export declare class CCTalkParser extends Transform {
|
||||
array: number[];
|
||||
cursor: number;
|
||||
lastByteFetchTime: number;
|
||||
maxDelayBetweenBytesMs: number;
|
||||
constructor(maxDelayBetweenBytesMs?: number);
|
||||
_transform(buffer: Buffer, encoding: BufferEncoding, cb: TransformCallback): void;
|
||||
}
|
||||
50
node_modules/@serialport/parser-cctalk/dist/index.js
generated
vendored
Normal file
50
node_modules/@serialport/parser-cctalk/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCTalkParser = void 0;
|
||||
const stream_1 = require("stream");
|
||||
/**
|
||||
* Parse the CCTalk protocol
|
||||
* @extends Transform
|
||||
*
|
||||
* A transform stream that emits CCTalk packets as they are received.
|
||||
*/
|
||||
class CCTalkParser extends stream_1.Transform {
|
||||
array;
|
||||
cursor;
|
||||
lastByteFetchTime;
|
||||
maxDelayBetweenBytesMs;
|
||||
constructor(maxDelayBetweenBytesMs = 50) {
|
||||
super();
|
||||
this.array = [];
|
||||
this.cursor = 0;
|
||||
this.lastByteFetchTime = 0;
|
||||
this.maxDelayBetweenBytesMs = maxDelayBetweenBytesMs;
|
||||
}
|
||||
_transform(buffer, encoding, cb) {
|
||||
if (this.maxDelayBetweenBytesMs > 0) {
|
||||
const now = Date.now();
|
||||
if (now - this.lastByteFetchTime > this.maxDelayBetweenBytesMs) {
|
||||
this.array = [];
|
||||
this.cursor = 0;
|
||||
}
|
||||
this.lastByteFetchTime = now;
|
||||
}
|
||||
this.cursor += buffer.length;
|
||||
// TODO: Better Faster es7 no supported by node 4
|
||||
// ES7 allows directly push [...buffer]
|
||||
// this.array = this.array.concat(Array.from(buffer)) //Slower ?!?
|
||||
Array.from(buffer).map(byte => this.array.push(byte));
|
||||
while (this.cursor > 1 && this.cursor >= this.array[1] + 5) {
|
||||
// full frame accumulated
|
||||
// copy command from the array
|
||||
const FullMsgLength = this.array[1] + 5;
|
||||
const frame = Buffer.from(this.array.slice(0, FullMsgLength));
|
||||
// Preserve Extra Data
|
||||
this.array = this.array.slice(frame.length, this.array.length);
|
||||
this.cursor -= FullMsgLength;
|
||||
this.push(frame);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
}
|
||||
exports.CCTalkParser = CCTalkParser;
|
||||
25
node_modules/@serialport/parser-cctalk/package.json
generated
vendored
Normal file
25
node_modules/@serialport/parser-cctalk/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@serialport/parser-cctalk",
|
||||
"version": "12.0.0",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc --build tsconfig-build.json"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"license": "MIT",
|
||||
"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