split-frames 2.5.0 → 2.6.0
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 +268 -263
- package/lib/cjs/SplitFrames.d.ts +52 -57
- package/lib/cjs/SplitFrames.js +400 -384
- package/lib/cjs/checkers/checkTagsValidity.d.ts +2 -3
- package/lib/cjs/checkers/checkTagsValidity.js +22 -18
- package/lib/cjs/checkers/initData.d.ts +2 -2
- package/lib/cjs/checkers/initData.js +94 -85
- package/lib/cjs/main.cjs +8 -8
- package/lib/cjs/main.d.cts +2 -2
- package/package.json +111 -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,22 @@
|
|
|
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 (const tag of tags) {
|
|
13
|
+
if ("number" !== typeof tag) {
|
|
14
|
+
if ("object" !== typeof tag || !(tag instanceof Buffer)) {
|
|
15
|
+
result = false;
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
@@ -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,94 @@
|
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
if ("undefined" === typeof options) {
|
|
19
|
+
return {
|
|
20
|
+
"startTimeout": 200,
|
|
21
|
+
"escaped": [],
|
|
22
|
+
"specifics": {},
|
|
23
|
+
"controlBits": "none"
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if ("object" !== typeof options) {
|
|
27
|
+
throw new TypeError("parameter is not an object");
|
|
28
|
+
}
|
|
29
|
+
else if ("undefined" !== typeof options.startWith && !(0, checkTagsValidity_1.default)(options.startWith)) {
|
|
30
|
+
throw new TypeError("startWith parameter is not a number, Buffer, or an Array of numbers");
|
|
31
|
+
}
|
|
32
|
+
else if ("undefined" !== typeof options.startTimeout && "number" !== typeof options.startTimeout) {
|
|
33
|
+
throw new TypeError("startTimeout parameter is not a number");
|
|
34
|
+
}
|
|
35
|
+
else if ("undefined" !== typeof options.endWith && !(0, checkTagsValidity_1.default)(options.endWith)) {
|
|
36
|
+
throw new TypeError("endWith parameter is not a number, Buffer, or an Array of numbers");
|
|
37
|
+
}
|
|
38
|
+
else if ("undefined" !== typeof options.escapeWith && "number" !== typeof options.escapeWith) {
|
|
39
|
+
throw new TypeError("escapeWith parameter is not a number");
|
|
40
|
+
}
|
|
41
|
+
else if ("undefined" !== typeof options.escaped) {
|
|
42
|
+
if (!(0, checkTagsValidity_1.default)(options.escaped)) {
|
|
43
|
+
throw new TypeError("escaped parameter is not a number, Buffer, or an Array of numbers");
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(options.escaped)) {
|
|
46
|
+
for (let i = 0; i < options.escaped.length; ++i) {
|
|
47
|
+
if ("number" !== typeof options.escaped[i]) {
|
|
48
|
+
throw new TypeError("escaped parameter n°" + i + " is not a number");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else if ("undefined" !== typeof options.specifics && "object" !== typeof options.specifics) {
|
|
54
|
+
throw new TypeError("specifics parameter is not an object");
|
|
55
|
+
}
|
|
56
|
+
else if ("undefined" !== typeof options.controlBits && "string" !== typeof options.controlBits) {
|
|
57
|
+
throw new TypeError("controlBits parameter is not a string");
|
|
58
|
+
}
|
|
59
|
+
else if ("undefined" !== typeof options.controlBits && !ALLOWED_CONTROL_BITS_OPTIONS.includes(options.controlBits)) {
|
|
60
|
+
throw new Error("controlBits option is not in [ \"" + ALLOWED_CONTROL_BITS_OPTIONS.join("\", \"") + "\" ]");
|
|
61
|
+
}
|
|
62
|
+
const result = {
|
|
63
|
+
"startTimeout": options.startTimeout ?? 200,
|
|
64
|
+
"escaped": options.escaped ?? [],
|
|
65
|
+
"specifics": options.specifics ?? {},
|
|
66
|
+
"controlBits": options.controlBits ?? "none"
|
|
67
|
+
};
|
|
68
|
+
if ("undefined" !== typeof options.startWith) {
|
|
69
|
+
result.startWith = options.startWith;
|
|
70
|
+
}
|
|
71
|
+
if ("undefined" !== typeof options.endWith) {
|
|
72
|
+
result.endWith = options.endWith;
|
|
73
|
+
}
|
|
74
|
+
if ("undefined" !== typeof options.escapeWith) {
|
|
75
|
+
result.escapeWith = options.escapeWith;
|
|
76
|
+
}
|
|
77
|
+
if ("object" === typeof options.specifics) {
|
|
78
|
+
const specifics = options.specifics;
|
|
79
|
+
Object.keys(specifics).forEach((key) => {
|
|
80
|
+
if ("undefined" !== typeof specifics[key]) {
|
|
81
|
+
if (!(0, checkTagsValidity_1.default)(specifics[key])) {
|
|
82
|
+
throw new Error("\"" + String(specifics[key]) + "\" specifics option"
|
|
83
|
+
+ " is not a number, or an Array of numbers");
|
|
84
|
+
}
|
|
85
|
+
else if ("undefined" !== typeof result.startWith
|
|
86
|
+
&& "undefined" === typeof result.endWith) {
|
|
87
|
+
throw new Error("If you want to use \"" + String(specifics[key]) + "\" specific option,"
|
|
88
|
+
+ " you have to use \"endWith\" option");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}
|
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,111 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
"name": "split-frames",
|
|
4
|
-
"version": "2.
|
|
5
|
-
"description": "Split Buffer frames from streams",
|
|
6
|
-
|
|
7
|
-
"type": "commonjs",
|
|
8
|
-
"typings": "./lib/cjs/main.d.cts",
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"require": {
|
|
14
|
-
"types": "./lib/cjs/main.d.cts",
|
|
15
|
-
"default": "./lib/cjs/main.cjs"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
"scripts": {
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
"lint": "npx eslint ./
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
1
|
+
{
|
|
2
|
+
|
|
3
|
+
"name": "split-frames",
|
|
4
|
+
"version": "2.6.0",
|
|
5
|
+
"description": "Split Buffer frames from streams.",
|
|
6
|
+
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"typings": "./lib/cjs/main.d.cts",
|
|
9
|
+
|
|
10
|
+
"main": "./lib/cjs/main.cjs",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"require": {
|
|
14
|
+
"types": "./lib/cjs/main.d.cts",
|
|
15
|
+
"default": "./lib/cjs/main.cjs"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
"scripts": {
|
|
21
|
+
|
|
22
|
+
"prepare": "npx husky || true",
|
|
23
|
+
|
|
24
|
+
"lint-back": "npx eslint --config .eslintrc-back.js --ext .ts,.cts,.mts ./lib/src/**/*",
|
|
25
|
+
"lint-tests": "npx eslint --config .eslintrc-tests.js --ext .js,.cjs,.mjs ./test/**/*",
|
|
26
|
+
"lint": "npm run lint-back && npm run lint-tests",
|
|
27
|
+
|
|
28
|
+
"clean-back": "npx rimraf ./lib/cjs",
|
|
29
|
+
"clean": "npm run clean-back",
|
|
30
|
+
|
|
31
|
+
"build-back": "npm run clean-back && npx tsc --project ./tsconfig.json",
|
|
32
|
+
"build": "npm run build-back",
|
|
33
|
+
|
|
34
|
+
"check-requires": "npx used-deps-analyzer ./package.json ./lib/src --no-dev",
|
|
35
|
+
"check-updates": "npx check-version-modules --no-fail-at-major --fail-at-minor --fail-at-patch",
|
|
36
|
+
"unit-tests": "npm run build && npx nyc --reporter=html --reporter=text mocha",
|
|
37
|
+
|
|
38
|
+
"tests": "npm run lint && npm run check-requires && npm run check-updates && npm run unit-tests"
|
|
39
|
+
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
"files": [
|
|
43
|
+
"lib/cjs"
|
|
44
|
+
],
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=22.22.0"
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
"dependencies": {},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "25.5.0",
|
|
52
|
+
"check-version-modules": "2.2.2",
|
|
53
|
+
"colors": "1.4.0",
|
|
54
|
+
"eslint-plugin-personnallinter": "git+ssh://git@github.com/Psychopoulet/eslint-plugin-personnallinter",
|
|
55
|
+
"husky": "9.1.7",
|
|
56
|
+
"mocha": "11.7.5",
|
|
57
|
+
"nyc": "18.0.0",
|
|
58
|
+
"rimraf": "6.1.3",
|
|
59
|
+
"typescript": "5.9.3",
|
|
60
|
+
"used-deps-analyzer": "0.2.0"
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
"husky": {
|
|
64
|
+
"hooks": {
|
|
65
|
+
"pre-commit": "npm run lint",
|
|
66
|
+
"pre-push": "npm run unit-tests"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"keywords": [
|
|
70
|
+
"frame",
|
|
71
|
+
"Buffer",
|
|
72
|
+
"buffer",
|
|
73
|
+
"split",
|
|
74
|
+
"formate",
|
|
75
|
+
"parse",
|
|
76
|
+
"escape",
|
|
77
|
+
"bit",
|
|
78
|
+
"stream",
|
|
79
|
+
"Transform",
|
|
80
|
+
"transform",
|
|
81
|
+
"STX",
|
|
82
|
+
"ETX",
|
|
83
|
+
"ACK",
|
|
84
|
+
"WAK",
|
|
85
|
+
"NAK",
|
|
86
|
+
"DLE",
|
|
87
|
+
"industrial",
|
|
88
|
+
"protocol",
|
|
89
|
+
"LRC",
|
|
90
|
+
"MSB",
|
|
91
|
+
"LSB"
|
|
92
|
+
],
|
|
93
|
+
"author": "Sébastien VIDAL",
|
|
94
|
+
"contributors": [
|
|
95
|
+
{
|
|
96
|
+
"name": "07ke",
|
|
97
|
+
"url": "https://github.com/07ke"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"license": "ISC",
|
|
101
|
+
|
|
102
|
+
"homepage": "https://github.com/Psychopoulet/split-frames#readme",
|
|
103
|
+
"repository": {
|
|
104
|
+
"type": "git",
|
|
105
|
+
"url": "git://github.com/Psychopoulet/split-frames.git"
|
|
106
|
+
},
|
|
107
|
+
"bugs": {
|
|
108
|
+
"url": "https://github.com/Psychopoulet/split-frames/issues"
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|