split-frames 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -13
- package/README.md +263 -263
- package/lib/cjs/SplitFrames.d.ts +52 -57
- package/lib/cjs/SplitFrames.js +385 -384
- package/lib/cjs/checkers/checkTagsValidity.d.ts +2 -3
- package/lib/cjs/checkers/checkTagsValidity.js +20 -18
- package/lib/cjs/checkers/initData.d.ts +2 -2
- package/lib/cjs/checkers/initData.js +89 -85
- package/lib/cjs/main.cjs +8 -8
- package/lib/cjs/main.d.cts +2 -2
- package/package.json +95 -96
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { tTag } from "../SplitFrames.js";
|
|
2
|
-
|
|
3
|
-
export default _default;
|
|
1
|
+
import type { tTag } from "../SplitFrames.js";
|
|
2
|
+
export default function checkTagsValidity(tags: tTag): boolean;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.default =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
// types & interfaces
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.default = checkTagsValidity;
|
|
5
|
+
// module
|
|
6
|
+
function checkTagsValidity(tags) {
|
|
7
|
+
let result = true;
|
|
8
|
+
if ("number" !== typeof tags && "object" !== typeof tags) {
|
|
9
|
+
result = false;
|
|
10
|
+
}
|
|
11
|
+
else if ("object" === typeof tags && tags instanceof Array) {
|
|
12
|
+
for (let i = 0; i < tags.length; ++i) {
|
|
13
|
+
if ("number" !== typeof tags[i] && "object" !== typeof tags[i] && !(tags[i] instanceof Buffer)) {
|
|
14
|
+
result = false;
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { iOptions, iConf } from "../SplitFrames.js";
|
|
2
|
-
export default function initData(options?: iOptions): iConf;
|
|
1
|
+
import type { iOptions, iConf } from "../SplitFrames.js";
|
|
2
|
+
export default function initData(options?: iOptions): iConf;
|
|
@@ -1,85 +1,89 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
result.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
throw new Error("
|
|
73
|
-
"
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
;
|
|
1
|
+
"use strict";
|
|
2
|
+
// deps
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.default = initData;
|
|
8
|
+
// locals
|
|
9
|
+
const checkTagsValidity_1 = __importDefault(require("./checkTagsValidity"));
|
|
10
|
+
// consts
|
|
11
|
+
const ALLOWED_CONTROL_BITS_OPTIONS = [
|
|
12
|
+
"none",
|
|
13
|
+
"end+1",
|
|
14
|
+
"end+2"
|
|
15
|
+
];
|
|
16
|
+
// module
|
|
17
|
+
function initData(options) {
|
|
18
|
+
const result = {
|
|
19
|
+
"startWith": undefined,
|
|
20
|
+
"startTimeout": 200,
|
|
21
|
+
"endWith": undefined,
|
|
22
|
+
"escapeWith": undefined,
|
|
23
|
+
"escaped": [],
|
|
24
|
+
"specifics": {},
|
|
25
|
+
"controlBits": "none"
|
|
26
|
+
};
|
|
27
|
+
if ("undefined" !== typeof options) {
|
|
28
|
+
if ("object" !== typeof options) {
|
|
29
|
+
throw new TypeError("parameter sended is not an object");
|
|
30
|
+
}
|
|
31
|
+
else if ("undefined" !== typeof options.startWith && !(0, checkTagsValidity_1.default)(options.startWith)) {
|
|
32
|
+
throw new TypeError("startWith parameter sended is not a number, Buffer, or an Array of numbers");
|
|
33
|
+
}
|
|
34
|
+
else if ("undefined" !== typeof options.startTimeout && "number" !== typeof options.startTimeout) {
|
|
35
|
+
throw new TypeError("startTimeout parameter sended is not a number");
|
|
36
|
+
}
|
|
37
|
+
else if ("undefined" !== typeof options.endWith && !(0, checkTagsValidity_1.default)(options.endWith)) {
|
|
38
|
+
throw new TypeError("endWith parameter sended is not a number, Buffer, or an Array of numbers");
|
|
39
|
+
}
|
|
40
|
+
else if ("undefined" !== typeof options.escapeWith && "number" !== typeof options.escapeWith) {
|
|
41
|
+
throw new TypeError("escapeWith parameter sended is not a number");
|
|
42
|
+
}
|
|
43
|
+
else if ("undefined" !== typeof options.specifics && "object" !== typeof options.specifics) {
|
|
44
|
+
throw new TypeError("escapeWith parameter sended is not an object");
|
|
45
|
+
}
|
|
46
|
+
else if ("undefined" !== typeof options.controlBits && "string" !== typeof options.controlBits) {
|
|
47
|
+
throw new TypeError("controlBits parameter sended is not a string");
|
|
48
|
+
}
|
|
49
|
+
else if ("undefined" !== typeof options.controlBits && !ALLOWED_CONTROL_BITS_OPTIONS.includes(options.controlBits)) {
|
|
50
|
+
throw new Error("controlBits option sended is not in [ \"" + ALLOWED_CONTROL_BITS_OPTIONS.join("\", \"") + "\" ]");
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
result.startWith = "undefined" !== typeof options.startWith ? options.startWith : undefined;
|
|
54
|
+
result.endWith = "undefined" !== typeof options.endWith ? options.endWith : undefined;
|
|
55
|
+
if ("undefined" !== typeof options.startTimeout) {
|
|
56
|
+
result.startTimeout = options.startTimeout;
|
|
57
|
+
}
|
|
58
|
+
result.escapeWith = "undefined" !== typeof options.escapeWith ? options.escapeWith : undefined;
|
|
59
|
+
if ("undefined" !== typeof options.escaped) {
|
|
60
|
+
result.escaped = options.escaped;
|
|
61
|
+
}
|
|
62
|
+
for (let i = 0; i < result.escaped.length; ++i) {
|
|
63
|
+
if ("number" !== typeof result.escaped[i]) {
|
|
64
|
+
throw new TypeError("escaped parameter n°" + i + " sended is not a number");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if ("object" === typeof options.specifics) {
|
|
68
|
+
const specifics = options.specifics;
|
|
69
|
+
Object.keys(specifics).forEach((key) => {
|
|
70
|
+
if ("undefined" !== typeof specifics[key]) {
|
|
71
|
+
if (!(0, checkTagsValidity_1.default)(specifics[key])) {
|
|
72
|
+
throw new Error("\"" + specifics[key] + "\" specifics option"
|
|
73
|
+
+ " sended is not a number, or an Array of numbers");
|
|
74
|
+
}
|
|
75
|
+
else if (undefined !== specifics[key]
|
|
76
|
+
&& undefined !== result.startWith
|
|
77
|
+
&& undefined === result.endWith) {
|
|
78
|
+
throw new Error("If you want to use \"" + specifics[key] + "\" specific option,"
|
|
79
|
+
+ " you have to use \"endWith\" option");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
result.specifics = "undefined" !== typeof options.specifics ? options.specifics : {};
|
|
85
|
+
result.controlBits = "undefined" !== typeof options.controlBits ? options.controlBits : "none";
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
package/lib/cjs/main.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
// locals
|
|
7
|
-
const SplitFrames_1 = __importDefault(require("./SplitFrames"));
|
|
8
|
-
module.exports = SplitFrames_1.default;
|
|
1
|
+
"use strict";
|
|
2
|
+
// deps
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
// locals
|
|
7
|
+
const SplitFrames_1 = __importDefault(require("./SplitFrames"));
|
|
8
|
+
module.exports = SplitFrames_1.default;
|
package/lib/cjs/main.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import SplitFrames from "./SplitFrames";
|
|
2
|
-
export = SplitFrames;
|
|
1
|
+
import SplitFrames from "./SplitFrames";
|
|
2
|
+
export = SplitFrames;
|
package/package.json
CHANGED
|
@@ -1,96 +1,95 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"homepage": "https://github.com/Psychopoulet/split-frames#readme",
|
|
88
|
-
"repository": {
|
|
89
|
-
"type": "git",
|
|
90
|
-
"url": "git://github.com/Psychopoulet/split-frames"
|
|
91
|
-
},
|
|
92
|
-
"bugs": {
|
|
93
|
-
"url": "https://github.com/Psychopoulet/split-frames/issues"
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "split-frames",
|
|
3
|
+
"version": "2.5.1",
|
|
4
|
+
"description": "Split Buffer frames from streams",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"typings": "./lib/cjs/main.d.cts",
|
|
7
|
+
"main": "./lib/cjs/main.cjs",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": {
|
|
11
|
+
"types": "./lib/cjs/main.d.cts",
|
|
12
|
+
"default": "./lib/cjs/main.cjs"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"prepare": "husky",
|
|
18
|
+
"clean": "npx rimraf lib/cjs",
|
|
19
|
+
"build": "npm run-script clean && npx tsc --project \"./tsconfig.json\"",
|
|
20
|
+
"lint": "npx eslint --config .eslintrc-src.js --ext .cts,.ts ./lib/src/**/* && npx eslint --config .eslintrc-tests.js ./bin/*.js ./test/**/*.js",
|
|
21
|
+
"check-requires": "npx used-deps-analyzer \"./package.json\" \"./lib/src\" --no-dev --overkill \"fs-extra\" \"node-promfs\"",
|
|
22
|
+
"check-updates": "npx check-version-modules",
|
|
23
|
+
"unit-tests": "npm run-script build && npx nyc --reporter=html --reporter=text mocha",
|
|
24
|
+
"tests": "npm run-script lint && npm run-script check-requires && npm run-script check-updates && npm run-script unit-tests"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"/bin",
|
|
28
|
+
"/lib/cjs",
|
|
29
|
+
"/public"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=16.0.0"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "22.7.8",
|
|
37
|
+
"check-version-modules": "2.1.2",
|
|
38
|
+
"colors": "1.4.0",
|
|
39
|
+
"eslint-plugin-personnallinter": "git+ssh://git@github.com/Psychopoulet/eslint-plugin-personnallinter",
|
|
40
|
+
"husky": "9.1.6",
|
|
41
|
+
"mocha": "10.7.3",
|
|
42
|
+
"nyc": "17.1.0",
|
|
43
|
+
"rimraf": "6.0.1",
|
|
44
|
+
"typescript": "5.6.3",
|
|
45
|
+
"used-deps-analyzer": "0.1.8"
|
|
46
|
+
},
|
|
47
|
+
"optionalDependencies": {},
|
|
48
|
+
"husky": {
|
|
49
|
+
"hooks": {
|
|
50
|
+
"pre-commit": "npm run-script lint",
|
|
51
|
+
"pre-push": "npm run-script unit-tests",
|
|
52
|
+
"pre-receive": "npm run-script tests"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"keywords": [
|
|
56
|
+
"frame",
|
|
57
|
+
"Buffer",
|
|
58
|
+
"buffer",
|
|
59
|
+
"split",
|
|
60
|
+
"formate",
|
|
61
|
+
"parse",
|
|
62
|
+
"escape",
|
|
63
|
+
"bit",
|
|
64
|
+
"stream",
|
|
65
|
+
"Transform",
|
|
66
|
+
"transform",
|
|
67
|
+
"STX",
|
|
68
|
+
"ETX",
|
|
69
|
+
"ACK",
|
|
70
|
+
"WAK",
|
|
71
|
+
"NAK",
|
|
72
|
+
"DLE",
|
|
73
|
+
"industrial",
|
|
74
|
+
"protocol",
|
|
75
|
+
"LRC",
|
|
76
|
+
"MSB",
|
|
77
|
+
"LSB"
|
|
78
|
+
],
|
|
79
|
+
"author": "Sébastien VIDAL",
|
|
80
|
+
"contributors": [
|
|
81
|
+
{
|
|
82
|
+
"name": "07ke",
|
|
83
|
+
"url": "https://github.com/07ke"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"license": "ISC",
|
|
87
|
+
"homepage": "https://github.com/Psychopoulet/split-frames#readme",
|
|
88
|
+
"repository": {
|
|
89
|
+
"type": "git",
|
|
90
|
+
"url": "git://github.com/Psychopoulet/split-frames"
|
|
91
|
+
},
|
|
92
|
+
"bugs": {
|
|
93
|
+
"url": "https://github.com/Psychopoulet/split-frames/issues"
|
|
94
|
+
}
|
|
95
|
+
}
|