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.
@@ -1,3 +1,2 @@
1
- import { tTag } from "../SplitFrames.js";
2
- declare const _default: (tags: tTag) => boolean;
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
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // module
4
- exports.default = (tags) => {
5
- let result = true;
6
- if ("number" !== typeof tags && "object" !== typeof tags) {
7
- result = false;
8
- }
9
- else if ("object" === typeof tags && tags instanceof Array) {
10
- for (let i = 0; i < tags.length; ++i) {
11
- if ("number" !== typeof tags[i] && "object" !== typeof tags[i] && !(tags[i] instanceof Buffer)) {
12
- result = false;
13
- break;
14
- }
15
- }
16
- }
17
- return result;
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- // deps
7
- // locals
8
- const checkTagsValidity_1 = __importDefault(require("./checkTagsValidity"));
9
- // consts
10
- const ALLOWED_CONTROL_BITS_OPTIONS = ["none", "end+1", "end+2"];
11
- // module
12
- function initData(options) {
13
- const result = {
14
- "startWith": undefined,
15
- "startTimeout": 200,
16
- "endWith": undefined,
17
- "escapeWith": undefined,
18
- "escaped": [],
19
- "specifics": {},
20
- "controlBits": "none"
21
- };
22
- if ("undefined" !== typeof options) {
23
- if ("object" !== typeof options) {
24
- throw new TypeError("parameter sended is not an object");
25
- }
26
- else if ("undefined" !== typeof options.startWith && !(0, checkTagsValidity_1.default)(options.startWith)) {
27
- throw new TypeError("startWith parameter sended is not a number, Buffer, or an Array of numbers");
28
- }
29
- else if ("undefined" !== typeof options.startTimeout && "number" !== typeof options.startTimeout) {
30
- throw new TypeError("startTimeout parameter sended is not a number");
31
- }
32
- else if ("undefined" !== typeof options.endWith && !(0, checkTagsValidity_1.default)(options.endWith)) {
33
- throw new TypeError("endWith parameter sended is not a number, Buffer, or an Array of numbers");
34
- }
35
- else if ("undefined" !== typeof options.escapeWith && "number" !== typeof options.escapeWith) {
36
- throw new TypeError("escapeWith parameter sended is not a number");
37
- }
38
- else if ("undefined" !== typeof options.specifics && "object" !== typeof options.specifics) {
39
- throw new TypeError("escapeWith parameter sended is not an object");
40
- }
41
- else if ("undefined" !== typeof options.controlBits && "string" !== typeof options.controlBits) {
42
- throw new TypeError("controlBits parameter sended is not a string");
43
- }
44
- else if ("undefined" !== typeof options.controlBits && !ALLOWED_CONTROL_BITS_OPTIONS.includes(options.controlBits)) {
45
- throw new Error("controlBits option sended is not in [ \"" + ALLOWED_CONTROL_BITS_OPTIONS.join("\", \"") + "\" ]");
46
- }
47
- else {
48
- result.startWith = "undefined" !== typeof options.startWith ? options.startWith : undefined;
49
- result.endWith = "undefined" !== typeof options.endWith ? options.endWith : undefined;
50
- if ("undefined" !== typeof options.startTimeout) {
51
- result.startTimeout = options.startTimeout;
52
- }
53
- result.escapeWith = "undefined" !== typeof options.escapeWith ? options.escapeWith : undefined;
54
- if ("undefined" !== typeof options.escaped) {
55
- result.escaped = options.escaped;
56
- }
57
- for (let i = 0; i < result.escaped.length; ++i) {
58
- if ("number" !== typeof result.escaped[i]) {
59
- throw new TypeError("escaped parameter n°" + i + " sended is not a number");
60
- }
61
- }
62
- if ("object" === typeof options.specifics) {
63
- const specifics = options.specifics;
64
- Object.keys(specifics).forEach((key) => {
65
- if ("undefined" !== typeof specifics[key]) {
66
- if (!(0, checkTagsValidity_1.default)(specifics[key])) {
67
- throw new Error("\"" + specifics[key] + "\" specifics option" +
68
- " sended is not a number, or an Array of numbers");
69
- }
70
- else if (undefined !== specifics[key] &&
71
- undefined !== result.startWith && undefined === result.endWith) {
72
- throw new Error("If you want to use \"" + specifics[key] + "\" specific option," +
73
- " you have to use \"endWith\" option");
74
- }
75
- }
76
- });
77
- }
78
- result.specifics = "undefined" !== typeof options.specifics ? options.specifics : {};
79
- result.controlBits = "undefined" !== typeof options.controlBits ? options.controlBits : "none";
80
- }
81
- }
82
- return result;
83
- }
84
- exports.default = initData;
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- // deps
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;
@@ -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.0",
5
- "description": "Split Buffer frames from streams",
6
-
7
- "type": "commonjs",
8
- "typings": "./lib/cjs/main.d.cts",
9
- "main": "./lib/cjs/main.cjs",
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
- "build": "node ./removeOldBuild.js && npx tsc --project \"./tsconfig.json\"",
23
-
24
- "lint": "npx eslint ./test/**/*.js",
25
- "check-requires": "npx used-deps-analyzer \"./package.json\" \"./src\" --no-dev --overkill \"fs-extra\" \"node-promfs\"",
26
- "check-updates": "npx check-version-modules",
27
- "unit-tests": "npm run build && npx nyc --reporter=html --reporter=text mocha",
28
-
29
- "tests": "npm run-script lint && npm run check-requires && npm run-script check-updates && npm run-script unit-tests",
30
- "ci": "npm run-script tests && npx nyc report --reporter=text-lcov | coveralls"
31
-
32
- },
33
-
34
- "files": [
35
- "/lib"
36
- ],
37
- "engines": {
38
- "node": ">=16.0.0"
39
- },
40
-
41
- "dependencies": {},
42
- "devDependencies": {
43
- "@types/node": "20.5.7",
44
- "check-version-modules": "1.5.0",
45
- "coveralls": "3.1.1",
46
- "eslint": "8.48.0",
47
- "husky": "8.0.3",
48
- "mocha": "10.2.0",
49
- "nyc": "15.1.0",
50
- "used-deps-analyzer": "0.1.6"
51
- },
52
- "optionalDependencies": {},
53
-
54
- "husky": {
55
- "hooks": {
56
- "pre-commit": "npm run-script lint",
57
- "pre-push": "npm run-script tests"
58
- }
59
- },
60
- "keywords": [
61
- "frame",
62
- "Buffer",
63
- "buffer",
64
- "split",
65
- "formate",
66
- "parse",
67
- "escape",
68
- "bit",
69
- "stream",
70
- "Transform",
71
- "transform",
72
- "STX",
73
- "ETX",
74
- "ACK",
75
- "WAK",
76
- "NAK",
77
- "DLE",
78
- "industrial",
79
- "protocol",
80
- "LRC",
81
- "MSB",
82
- "LSB"
83
- ],
84
- "author": "Sébastien VIDAL",
85
- "license": "ISC",
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
+
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
+ }