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.
@@ -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,20 @@
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 (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
- 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
+ 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
- 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,95 @@
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
+ "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
+ }