Initial commit
This commit is contained in:
21
node_modules/@serialport/parser-inter-byte-timeout/LICENSE
generated
vendored
Normal file
21
node_modules/@serialport/parser-inter-byte-timeout/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-inter-byte-timeout/README.md
generated
vendored
Normal file
3
node_modules/@serialport/parser-inter-byte-timeout/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# @serialport/parser-inter-byte-timeout
|
||||
|
||||
See our api docs https://serialport.io/docs/api-parser-inter-byte-timeout
|
||||
23
node_modules/@serialport/parser-inter-byte-timeout/dist/index.d.ts
generated
vendored
Normal file
23
node_modules/@serialport/parser-inter-byte-timeout/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { Transform, TransformCallback, TransformOptions } from 'stream';
|
||||
export interface InterByteTimeoutOptions extends TransformOptions {
|
||||
/** the period of silence in milliseconds after which data is emitted */
|
||||
interval: number;
|
||||
/** the maximum number of bytes after which data will be emitted. Defaults to 65536 */
|
||||
maxBufferSize?: number;
|
||||
}
|
||||
/**
|
||||
* A transform stream that buffers data and emits it after not receiving any bytes for the specified amount of time or hitting a max buffer size.
|
||||
*/
|
||||
export declare class InterByteTimeoutParser extends Transform {
|
||||
maxBufferSize: number;
|
||||
currentPacket: number[];
|
||||
interval: number;
|
||||
intervalID: NodeJS.Timeout | undefined;
|
||||
constructor({ maxBufferSize, interval, ...transformOptions }: InterByteTimeoutOptions);
|
||||
_transform(chunk: Buffer, encoding: BufferEncoding, cb: TransformCallback): void;
|
||||
emitPacket(): void;
|
||||
_flush(cb: TransformCallback): void;
|
||||
}
|
||||
61
node_modules/@serialport/parser-inter-byte-timeout/dist/index.js
generated
vendored
Normal file
61
node_modules/@serialport/parser-inter-byte-timeout/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.InterByteTimeoutParser = void 0;
|
||||
const stream_1 = require("stream");
|
||||
/**
|
||||
* A transform stream that buffers data and emits it after not receiving any bytes for the specified amount of time or hitting a max buffer size.
|
||||
*/
|
||||
class InterByteTimeoutParser extends stream_1.Transform {
|
||||
maxBufferSize;
|
||||
currentPacket;
|
||||
interval;
|
||||
intervalID;
|
||||
constructor({ maxBufferSize = 65536, interval, ...transformOptions }) {
|
||||
super(transformOptions);
|
||||
if (!interval) {
|
||||
throw new TypeError('"interval" is required');
|
||||
}
|
||||
if (typeof interval !== 'number' || Number.isNaN(interval)) {
|
||||
throw new TypeError('"interval" is not a number');
|
||||
}
|
||||
if (interval < 1) {
|
||||
throw new TypeError('"interval" is not greater than 0');
|
||||
}
|
||||
if (typeof maxBufferSize !== 'number' || Number.isNaN(maxBufferSize)) {
|
||||
throw new TypeError('"maxBufferSize" is not a number');
|
||||
}
|
||||
if (maxBufferSize < 1) {
|
||||
throw new TypeError('"maxBufferSize" is not greater than 0');
|
||||
}
|
||||
this.maxBufferSize = maxBufferSize;
|
||||
this.currentPacket = [];
|
||||
this.interval = interval;
|
||||
}
|
||||
_transform(chunk, encoding, cb) {
|
||||
if (this.intervalID) {
|
||||
clearTimeout(this.intervalID);
|
||||
}
|
||||
for (let offset = 0; offset < chunk.length; offset++) {
|
||||
this.currentPacket.push(chunk[offset]);
|
||||
if (this.currentPacket.length >= this.maxBufferSize) {
|
||||
this.emitPacket();
|
||||
}
|
||||
}
|
||||
this.intervalID = setTimeout(this.emitPacket.bind(this), this.interval);
|
||||
cb();
|
||||
}
|
||||
emitPacket() {
|
||||
if (this.intervalID) {
|
||||
clearTimeout(this.intervalID);
|
||||
}
|
||||
if (this.currentPacket.length > 0) {
|
||||
this.push(Buffer.from(this.currentPacket));
|
||||
}
|
||||
this.currentPacket = [];
|
||||
}
|
||||
_flush(cb) {
|
||||
this.emitPacket();
|
||||
cb();
|
||||
}
|
||||
}
|
||||
exports.InterByteTimeoutParser = InterByteTimeoutParser;
|
||||
25
node_modules/@serialport/parser-inter-byte-timeout/package.json
generated
vendored
Normal file
25
node_modules/@serialport/parser-inter-byte-timeout/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@serialport/parser-inter-byte-timeout",
|
||||
"version": "12.0.0",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"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