Dia antes primera install
This commit is contained in:
39
node_modules/@serialport/parser-slip-encoder/dist/decoder.d.ts
generated
vendored
Normal file
39
node_modules/@serialport/parser-slip-encoder/dist/decoder.d.ts
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { Transform, TransformCallback, TransformOptions } from 'stream';
|
||||
export interface SlipDecoderOptions extends TransformOptions {
|
||||
/** Custom start byte */
|
||||
START?: number;
|
||||
/** Custom start escape byte */
|
||||
ESC_START?: number;
|
||||
/** custom escape byte */
|
||||
ESC?: number;
|
||||
/** custom end byte */
|
||||
END?: number;
|
||||
/** custom escape end byte */
|
||||
ESC_END?: number;
|
||||
/** custom escape escape byte */
|
||||
ESC_ESC?: number;
|
||||
}
|
||||
/**
|
||||
* A transform stream that decodes slip encoded data.
|
||||
* @extends Transform
|
||||
*
|
||||
* Runs in O(n) time, stripping out slip encoding and emitting decoded data. Optionally custom slip escape and delimiters can be provided.
|
||||
*/
|
||||
export declare class SlipDecoder extends Transform {
|
||||
opts: {
|
||||
START: number | undefined;
|
||||
ESC: number;
|
||||
END: number;
|
||||
ESC_START: number | undefined;
|
||||
ESC_END: number;
|
||||
ESC_ESC: number;
|
||||
};
|
||||
buffer: Buffer;
|
||||
escape: boolean;
|
||||
start: boolean;
|
||||
constructor(options?: SlipDecoderOptions);
|
||||
_transform(chunk: Buffer, encoding: BufferEncoding, cb: TransformCallback): void;
|
||||
_flush(cb: TransformCallback): void;
|
||||
}
|
||||
83
node_modules/@serialport/parser-slip-encoder/dist/decoder.js
generated
vendored
Normal file
83
node_modules/@serialport/parser-slip-encoder/dist/decoder.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SlipDecoder = void 0;
|
||||
const stream_1 = require("stream");
|
||||
/**
|
||||
* A transform stream that decodes slip encoded data.
|
||||
* @extends Transform
|
||||
*
|
||||
* Runs in O(n) time, stripping out slip encoding and emitting decoded data. Optionally custom slip escape and delimiters can be provided.
|
||||
*/
|
||||
class SlipDecoder extends stream_1.Transform {
|
||||
opts;
|
||||
buffer;
|
||||
escape;
|
||||
start;
|
||||
constructor(options = {}) {
|
||||
super(options);
|
||||
const { START, ESC = 0xdb, END = 0xc0, ESC_START, ESC_END = 0xdc, ESC_ESC = 0xdd } = options;
|
||||
this.opts = {
|
||||
START,
|
||||
ESC,
|
||||
END,
|
||||
ESC_START,
|
||||
ESC_END,
|
||||
ESC_ESC,
|
||||
};
|
||||
this.buffer = Buffer.alloc(0);
|
||||
this.escape = false;
|
||||
this.start = false;
|
||||
}
|
||||
_transform(chunk, encoding, cb) {
|
||||
for (let ndx = 0; ndx < chunk.length; ndx++) {
|
||||
let byte = chunk[ndx];
|
||||
if (byte === this.opts.START) {
|
||||
this.start = true;
|
||||
continue;
|
||||
}
|
||||
else if (undefined == this.opts.START) {
|
||||
this.start = true;
|
||||
}
|
||||
if (this.escape) {
|
||||
if (byte === this.opts.ESC_START && this.opts.START) {
|
||||
byte = this.opts.START;
|
||||
}
|
||||
else if (byte === this.opts.ESC_ESC) {
|
||||
byte = this.opts.ESC;
|
||||
}
|
||||
else if (byte === this.opts.ESC_END) {
|
||||
byte = this.opts.END;
|
||||
}
|
||||
else {
|
||||
this.escape = false;
|
||||
this.push(this.buffer);
|
||||
this.buffer = Buffer.alloc(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (byte === this.opts.ESC) {
|
||||
this.escape = true;
|
||||
continue;
|
||||
}
|
||||
if (byte === this.opts.END) {
|
||||
this.push(this.buffer);
|
||||
this.buffer = Buffer.alloc(0);
|
||||
this.escape = false;
|
||||
this.start = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
this.escape = false;
|
||||
if (this.start) {
|
||||
this.buffer = Buffer.concat([this.buffer, Buffer.from([byte])]);
|
||||
}
|
||||
}
|
||||
cb();
|
||||
}
|
||||
_flush(cb) {
|
||||
this.push(this.buffer);
|
||||
this.buffer = Buffer.alloc(0);
|
||||
cb();
|
||||
}
|
||||
}
|
||||
exports.SlipDecoder = SlipDecoder;
|
||||
38
node_modules/@serialport/parser-slip-encoder/dist/encoder.d.ts
generated
vendored
Normal file
38
node_modules/@serialport/parser-slip-encoder/dist/encoder.d.ts
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { Transform, TransformCallback, TransformOptions } from 'stream';
|
||||
export interface SlipEncoderOptions extends TransformOptions {
|
||||
/** Custom start byte */
|
||||
START?: number;
|
||||
/** Custom start escape byte */
|
||||
ESC_START?: number;
|
||||
/** custom escape byte */
|
||||
ESC?: number;
|
||||
/** custom end byte */
|
||||
END?: number;
|
||||
/** custom escape end byte */
|
||||
ESC_END?: number;
|
||||
/** custom escape escape byte */
|
||||
ESC_ESC?: number;
|
||||
/** Adds an END character at the beginning of each packet per the Bluetooth Core Specification 4.0, Volume 4, Part D, Chapter 3 "SLIP Layer" and allowed by RFC 1055 */
|
||||
bluetoothQuirk?: boolean;
|
||||
}
|
||||
/**
|
||||
* A transform stream that emits SLIP-encoded data for each incoming packet.
|
||||
*
|
||||
* Runs in O(n) time, adding a 0xC0 character at the end of each
|
||||
* received packet and escaping characters, according to RFC 1055.
|
||||
*/
|
||||
export declare class SlipEncoder extends Transform {
|
||||
opts: {
|
||||
START: number | undefined;
|
||||
ESC: number;
|
||||
END: number;
|
||||
ESC_START: number | undefined;
|
||||
ESC_END: number;
|
||||
ESC_ESC: number;
|
||||
bluetoothQuirk: boolean;
|
||||
};
|
||||
constructor(options?: SlipEncoderOptions);
|
||||
_transform(chunk: Buffer, encoding: BufferEncoding, cb: TransformCallback): void;
|
||||
}
|
||||
63
node_modules/@serialport/parser-slip-encoder/dist/encoder.js
generated
vendored
Normal file
63
node_modules/@serialport/parser-slip-encoder/dist/encoder.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SlipEncoder = void 0;
|
||||
const stream_1 = require("stream");
|
||||
/**
|
||||
* A transform stream that emits SLIP-encoded data for each incoming packet.
|
||||
*
|
||||
* Runs in O(n) time, adding a 0xC0 character at the end of each
|
||||
* received packet and escaping characters, according to RFC 1055.
|
||||
*/
|
||||
class SlipEncoder extends stream_1.Transform {
|
||||
opts;
|
||||
constructor(options = {}) {
|
||||
super(options);
|
||||
const { START, ESC = 0xdb, END = 0xc0, ESC_START, ESC_END = 0xdc, ESC_ESC = 0xdd, bluetoothQuirk = false } = options;
|
||||
this.opts = {
|
||||
START,
|
||||
ESC,
|
||||
END,
|
||||
ESC_START,
|
||||
ESC_END,
|
||||
ESC_ESC,
|
||||
bluetoothQuirk,
|
||||
};
|
||||
}
|
||||
_transform(chunk, encoding, cb) {
|
||||
const chunkLength = chunk.length;
|
||||
if (this.opts.bluetoothQuirk && chunkLength === 0) {
|
||||
// Edge case: push no data. Bluetooth-quirky SLIP parsers don't like
|
||||
// lots of 0xC0s together.
|
||||
return cb();
|
||||
}
|
||||
// Allocate memory for the worst-case scenario: all bytes are escaped,
|
||||
// plus start and end separators.
|
||||
const encoded = Buffer.alloc(chunkLength * 2 + 2);
|
||||
let j = 0;
|
||||
if (this.opts.bluetoothQuirk == true) {
|
||||
encoded[j++] = this.opts.END;
|
||||
}
|
||||
if (this.opts.START !== undefined) {
|
||||
encoded[j++] = this.opts.START;
|
||||
}
|
||||
for (let i = 0; i < chunkLength; i++) {
|
||||
let byte = chunk[i];
|
||||
if (byte === this.opts.START && this.opts.ESC_START) {
|
||||
encoded[j++] = this.opts.ESC;
|
||||
byte = this.opts.ESC_START;
|
||||
}
|
||||
else if (byte === this.opts.END) {
|
||||
encoded[j++] = this.opts.ESC;
|
||||
byte = this.opts.ESC_END;
|
||||
}
|
||||
else if (byte === this.opts.ESC) {
|
||||
encoded[j++] = this.opts.ESC;
|
||||
byte = this.opts.ESC_ESC;
|
||||
}
|
||||
encoded[j++] = byte;
|
||||
}
|
||||
encoded[j++] = this.opts.END;
|
||||
cb(null, encoded.slice(0, j));
|
||||
}
|
||||
}
|
||||
exports.SlipEncoder = SlipEncoder;
|
||||
2
node_modules/@serialport/parser-slip-encoder/dist/index.d.ts
generated
vendored
Normal file
2
node_modules/@serialport/parser-slip-encoder/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './decoder';
|
||||
export * from './encoder';
|
||||
18
node_modules/@serialport/parser-slip-encoder/dist/index.js
generated
vendored
Normal file
18
node_modules/@serialport/parser-slip-encoder/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./decoder"), exports);
|
||||
__exportStar(require("./encoder"), exports);
|
||||
Reference in New Issue
Block a user