split-frames 2.4.4 → 2.5.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/.eslintrc.js DELETED
@@ -1,296 +0,0 @@
1
- module.exports = {
2
- "extends": "eslint:recommended",
3
- "parserOptions": {
4
- "ecmaVersion": 2018
5
- },
6
- "env": {
7
- "es6": true,
8
- "mocha": true,
9
- "node": true
10
- },
11
- "globals": {
12
- "after": true,
13
- "afterEach": true,
14
- "angular": true,
15
- "before": true,
16
- "beforeEach": true,
17
- "Buffer": true,
18
- "console": true,
19
- "clearInterval": true,
20
- "clearTimeout": true,
21
- "describe": true,
22
- "it": true,
23
- "jQuery": true,
24
- "Promise": true,
25
- "Map": true,
26
- "module": true,
27
- "os": true,
28
- "process": true,
29
- "require": true,
30
- "setImmediate": true,
31
- "setInterval": true,
32
- "setTimeout": true,
33
- "__dirname": true,
34
- "__filename": true
35
- },
36
- "rules": {
37
- "for-direction": "error",
38
- "getter-return": "error",
39
- "no-await-in-loop": "error",
40
- "no-compare-neg-zero": "error",
41
- "no-cond-assign": "error",
42
- "no-console": "error",
43
- "no-constant-condition": "error",
44
- "no-control-regex": "error",
45
- "no-debugger": "error",
46
- "no-dupe-args": "error",
47
- "no-dupe-keys": "error",
48
- "no-duplicate-case": "error",
49
- "no-empty": "error",
50
- "no-empty-character-class": "error",
51
- "no-ex-assign": "error",
52
- "no-extra-boolean-cast": "error",
53
- "no-extra-parens": "error",
54
- "no-extra-semi": "error",
55
- "no-func-assign": "error",
56
- "no-inner-declarations": "error",
57
- "no-invalid-regexp": "error",
58
- "no-irregular-whitespace": "error",
59
- "no-obj-calls": "error",
60
- "no-prototype-builtins": "error",
61
- "no-regex-spaces": "error",
62
- "no-sparse-arrays": "error",
63
- "no-template-curly-in-string": "error",
64
- "no-unexpected-multiline": "error",
65
- "no-unreachable": "error",
66
- "no-unsafe-finally": "error",
67
- "no-unsafe-negation": "error",
68
- "use-isnan": "error",
69
- "valid-jsdoc": "error",
70
- "valid-typeof": "error",
71
-
72
-
73
- "accessor-pairs": "error",
74
- "array-callback-return": "error",
75
- "block-scoped-var": "error",
76
- "class-methods-use-this": "error",
77
- "complexity": "error",
78
- "consistent-return": "error",
79
- "curly": "error",
80
- "default-case": "error",
81
- "dot-location": [ "error", "property" ],
82
- "dot-notation": "error",
83
- "eqeqeq": "error",
84
- "guard-for-in": "error",
85
- "no-alert": "error",
86
- "no-caller": "error",
87
- "no-case-declarations": "error",
88
- "no-div-regex": "error",
89
- "no-else-return": 0,
90
- "no-empty-function": "error",
91
- "no-empty-pattern": "error",
92
- "no-eq-null": "error",
93
- "no-eval": "error",
94
- "no-extend-native": "error",
95
- "no-extra-bind": "error",
96
- "no-extra-label": "error",
97
- "no-fallthrough": "error",
98
- "no-floating-decimal": "error",
99
- "no-global-assign": "error",
100
- "no-implicit-coercion": "error",
101
- "no-implicit-globals": "error",
102
- "no-implied-eval": "error",
103
- "no-invalid-this": "error",
104
- "no-iterator": "error",
105
- "no-labels": "error",
106
- "no-lone-blocks": "error",
107
- "no-loop-func": "error",
108
- "no-magic-numbers": 0,
109
- "no-multi-spaces": "error",
110
- "no-multi-str": "error",
111
- "no-new": "error",
112
- "no-new-func": "error",
113
- "no-new-wrappers": "error",
114
- "no-octal": "error",
115
- "no-octal-escape": "error",
116
- "no-param-reassign": "error",
117
- "no-proto": "error",
118
- "no-redeclare": "error",
119
- "no-restricted-properties": "error",
120
- "no-return-assign": "error",
121
- "no-return-await": "error",
122
- "no-script-url": "error",
123
- "no-self-assign": "error",
124
- "no-self-compare": "error",
125
- "no-sequences": "error",
126
- "no-throw-literal": "error",
127
- "no-unmodified-loop-condition": "error",
128
- "no-unused-expressions": "error",
129
- "no-unused-labels": "error",
130
- "no-useless-call": "error",
131
- "no-useless-concat": "error",
132
- "no-useless-escape": "error",
133
- "no-useless-return": "error",
134
- "no-void": "error",
135
- "no-warning-comments": "error",
136
- "no-with": "error",
137
- "prefer-promise-reject-errors": "error",
138
- "radix": "error",
139
- "require-await": "error",
140
- "vars-on-top": "error",
141
- "wrap-iife": "error",
142
- "yoda": [ "error", "always" ],
143
-
144
-
145
- "strict": [ "error", "global" ],
146
-
147
-
148
- "init-declarations": "error",
149
- "no-catch-shadow": "error",
150
- "no-delete-var": "error",
151
- "no-label-var": "error",
152
- "no-restricted-globals": "error",
153
- "no-shadow": "error",
154
- "no-shadow-restricted-names": "error",
155
- "no-undef": "error",
156
- "no-undef-init": "error",
157
- "no-undefined": "error",
158
- "no-unused-vars": "error",
159
- "no-use-before-define": "error",
160
-
161
-
162
- "callback-return": "error",
163
- "global-require": 0,
164
- "handle-callback-err": "error",
165
- "no-buffer-constructor": "error",
166
- "no-mixed-requires": "error",
167
- "no-new-require": "error",
168
- "no-path-concat": "error",
169
- "no-process-env": "error",
170
- "no-process-exit": "error",
171
- "no-restricted-modules": "error",
172
- "no-sync": "error",
173
-
174
-
175
- "array-bracket-newline": "error",
176
- "array-bracket-spacing": [ "error", "always" ],
177
- "array-element-newline": [ "error", "consistent" ],
178
- "block-spacing": "error",
179
- "brace-style": [ "error", "stroustrup" ],
180
- "camelcase": "error",
181
- "capitalized-comments": 0,
182
- "comma-dangle": [ "error", "never" ],
183
- "comma-spacing": [ "error", { "before": false, "after": true } ],
184
- "comma-style": [ "error", "last" ],
185
- "computed-property-spacing": [ "error", "never" ],
186
- "consistent-this": "error",
187
- "eol-last": "error",
188
- "func-call-spacing": "error",
189
- "func-name-matching": "error",
190
- "func-names": "error",
191
- "func-style": [ "error", "declaration" ],
192
- "id-blacklist": 0,
193
- "id-length": 0,
194
- "id-match": 0,
195
- "indent": 0,
196
- "jsx-quotes": [ "error", "prefer-double" ],
197
- "key-spacing": [ "error", { "beforeColon": false, "afterColon": true } ],
198
- "keyword-spacing": [ "error", { "after": true, "before": true } ],
199
- "line-comment-position": [ "error", { "position": "above" } ],
200
- "linebreak-style": 0,
201
- "lines-around-comment": "error",
202
- "max-depth": [ "error", 4 ],
203
- "max-len": [ "error", 150 ],
204
- "max-lines": [ "error", { "max": 500, "skipComments": true } ],
205
- "max-nested-callbacks": [ "error", 5 ],
206
- "max-params": [ "error", 4 ],
207
- "max-statements": [ "error", 25 ],
208
- "max-statements-per-line": [ "error", { "max": 2 } ],
209
- "multiline-ternary": 0,
210
- "new-cap": "error",
211
- "new-parens": "error",
212
- "newline-per-chained-call": 0,
213
- "no-array-constructor": "error",
214
- "no-bitwise": "error",
215
- "no-continue": "error",
216
- "no-inline-comments": "error",
217
- "no-lonely-if": "error",
218
- "no-mixed-operators": "error",
219
- "no-mixed-spaces-and-tabs": "error",
220
- "no-multi-assign": "error",
221
- "no-multiple-empty-lines": "error",
222
- "no-negated-condition": 0,
223
- "no-nested-ternary": "error",
224
- "no-new-object": "error",
225
- "no-plusplus": 0,
226
- "no-restricted-syntax": "error",
227
- "no-tabs": [ "error", { "allowIndentationTabs": true } ],
228
- "no-ternary": 0,
229
- "no-trailing-spaces": "error",
230
- "no-underscore-dangle": 0,
231
- "no-unneeded-ternary": "error",
232
- "no-whitespace-before-property": "error",
233
- "nonblock-statement-body-position": [ "error", "below" ],
234
- "object-curly-newline": [ "error", { "consistent": true } ],
235
- "object-curly-spacing": [ "error", "always" ],
236
- "object-property-newline": "error",
237
- "one-var": [ "error", "never" ],
238
- "one-var-declaration-per-line": "error",
239
- "operator-assignment": [ "error", "always" ],
240
- "operator-linebreak": [ "error", "after" ],
241
- "padded-blocks": ["error", { "classes": "always", "switches": "always" } ],
242
- "padding-line-between-statements": "error",
243
- "quote-props": [ "error", "always" ],
244
- "quotes": [ "error", "double" ],
245
- "require-jsdoc": "error",
246
- "semi": [ "error", "always" ],
247
- "semi-spacing": [ "error", { "before": false, "after": true } ],
248
- "semi-style": [ "error", "last" ],
249
- "sort-keys": 0,
250
- "sort-vars": "error",
251
- "space-before-blocks": [ "error", "always" ],
252
- "space-before-function-paren": [ "error", "always" ],
253
- "space-in-parens": [ "error", "never" ],
254
- "space-infix-ops": "error",
255
- "space-unary-ops": "error",
256
- "spaced-comment": [ "error", "always" ],
257
- "switch-colon-spacing": [ "error", { "after": true, "before": false } ],
258
- "template-tag-spacing": [ "error", "always" ],
259
- "unicode-bom": 0,
260
- "wrap-regex": "error",
261
-
262
-
263
- "arrow-body-style": [ "error", "always" ],
264
- "arrow-parens": [ "error", "always" ],
265
- "arrow-spacing": ["error", { "before": true, "after": true } ],
266
- "constructor-super": "error",
267
- "generator-star-spacing": [ "error", { "before": true, "after": false } ],
268
- "no-class-assign": "error",
269
- "no-confusing-arrow": "error",
270
- "no-const-assign": "error",
271
- "no-dupe-class-members": "error",
272
- "no-duplicate-imports": "error",
273
- "no-new-symbol": "error",
274
- "no-restricted-imports": 0,
275
- "no-this-before-super": "error",
276
- "no-useless-computed-key": "error",
277
- "no-useless-constructor": "error",
278
- "no-useless-rename": "error",
279
- "no-var": "error",
280
- "object-shorthand": "error",
281
- "prefer-arrow-callback": "error",
282
- "prefer-const": "error",
283
- "prefer-destructuring": "error",
284
- "prefer-numeric-literals": "error",
285
- "prefer-rest-params": "error",
286
- "prefer-spread": "error",
287
- "prefer-template": 0,
288
- "require-yield": "error",
289
- "rest-spread-spacing": [ "error", "never" ],
290
- "sort-imports": "error",
291
- "symbol-description": "error",
292
- "template-curly-spacing": "error",
293
- "yield-star-spacing": [ "error", { "before": true, "after": false } ]
294
-
295
- }
296
- };
package/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - "8"
4
- - "10"
5
- install:
6
- - "npm install -g typescript"
7
- - "npm install"
8
- script: "npm run-script ci"
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = (tags) => {
4
-
5
- let result = true;
6
-
7
- if (
8
- "number" !== typeof tags && "object" !== typeof tags && !(tags instanceof Array || tags instanceof Buffer)
9
- ) {
10
- result = false;
11
- }
12
- else if ("object" === typeof tags && tags instanceof Array) {
13
-
14
- for (let i = 0; i < tags.length; ++i) {
15
-
16
- if ("number" !== typeof tags[i] && "object" !== typeof tags[i] && !(tags[i] instanceof Buffer)) {
17
- result = false; break;
18
- }
19
-
20
- }
21
-
22
- }
23
-
24
- return result;
25
-
26
- };
@@ -1,119 +0,0 @@
1
- /*
2
- eslint complexity: [ "error", { "max": 30 } ]
3
- */
4
-
5
- "use strict";
6
-
7
- // deps
8
-
9
- const checkTagsValidity = require(require("path").join(__dirname, "checkTagsValidity.js"));
10
-
11
- // consts
12
-
13
- const ALLOWED_CONTROL_BITS_OPTIONS = [ "none", "end+1", "end+2" ];
14
-
15
- // module
16
-
17
- module.exports = (options) => {
18
-
19
- const result = {
20
- "startWith": null,
21
- "startTimeout": null,
22
- "endWith": null,
23
- "escapeWith": null,
24
- "escaped": [],
25
- "specifics": {},
26
- "controlBits": ""
27
- };
28
-
29
- if ("undefined" !== typeof options) {
30
-
31
- if ("object" !== typeof options) {
32
- throw new TypeError("parameter sended is not an object");
33
- }
34
-
35
- else if ("undefined" !== typeof options.startWith && !checkTagsValidity(options.startWith)) {
36
- throw new TypeError("startWith parameter sended is not a number, Buffer, or an Array of numbers");
37
- }
38
- else if ("undefined" !== typeof options.startTimeout && "number" !== typeof options.startTimeout) {
39
- throw new TypeError("startTimeout parameter sended is not a number");
40
- }
41
- else if ("undefined" !== typeof options.endWith && !checkTagsValidity(options.endWith)) {
42
- throw new TypeError("endWith parameter sended is not a number, Buffer, or an Array of numbers");
43
- }
44
-
45
- else if ("undefined" !== typeof options.escapeWith && "number" !== typeof options.escapeWith) {
46
- throw new TypeError("escapeWith parameter sended is not a number");
47
- }
48
-
49
- else if ("undefined" !== typeof options.specifics && "object" !== typeof options.specifics) {
50
- throw new TypeError("escapeWith parameter sended is not an object");
51
- }
52
-
53
- else if ("undefined" !== typeof options.controlBits && "string" !== typeof options.controlBits) {
54
- throw new TypeError("controlBits parameter sended is not a string");
55
- }
56
-
57
- else if ("undefined" !== typeof options.controlBits && !ALLOWED_CONTROL_BITS_OPTIONS.includes(options.controlBits)) {
58
- throw new Error("controlBits option sended is not in [ \"" + ALLOWED_CONTROL_BITS_OPTIONS.join("\", \"") + "\" ]");
59
- }
60
-
61
- else {
62
-
63
- result.startWith = "undefined" !== typeof options.startWith ? options.startWith : null;
64
- result.startTimeout = "undefined" !== typeof options.startTimeout ? options.startTimeout : 200;
65
- result.endWith = "undefined" !== typeof options.endWith ? options.endWith : null;
66
-
67
- result.escapeWith = "undefined" !== typeof options.escapeWith ? options.escapeWith : null;
68
- result.escaped = "undefined" !== typeof options.escaped ? options.escaped : [];
69
-
70
- for (let i = 0; i < result.escaped.length; ++i) {
71
-
72
- if ("number" !== typeof result.escaped[i]) {
73
- throw new TypeError("escaped parameter n°" + i + " sended is not a number");
74
- }
75
-
76
- }
77
-
78
- if ("object" === typeof options.specifics) {
79
-
80
- Object.keys(options.specifics).forEach((key) => {
81
-
82
- if ("undefined" !== typeof options.specifics[key]) {
83
-
84
- if (!checkTagsValidity(options.specifics[key])) {
85
-
86
- throw new Error(
87
- "\"" + options.specifics[key] + "\" specifics option" +
88
- " sended is not a number, or an Array of numbers"
89
- );
90
-
91
- }
92
- else if (
93
- null !== options.specifics[key] &&
94
- null !== result.startWith && null === result.endWith
95
- ) {
96
-
97
- throw new Error(
98
- "If you want to use \"" + options.specifics[key] + "\" specific option," +
99
- " you have to use \"endWith\" option"
100
- );
101
-
102
- }
103
-
104
- }
105
-
106
- });
107
-
108
- }
109
-
110
- result.specifics = "undefined" !== typeof options.specifics ? options.specifics : {};
111
- result.controlBits = "undefined" !== typeof options.controlBits ? options.controlBits : "none";
112
-
113
- }
114
-
115
- }
116
-
117
- return result;
118
-
119
- };
@@ -1,73 +0,0 @@
1
- /*
2
- eslint no-invalid-this: 0, no-implicit-globals: 0
3
- */
4
-
5
- "use strict";
6
-
7
- // private
8
-
9
- // method
10
-
11
- /**
12
- * Extract specific tags
13
- * @param {SplitFrames} self : pointer
14
- * @returns {void}
15
- */
16
- function _extractSpecifics (self) {
17
-
18
- let found = false;
19
-
20
- Object.keys(self._specifics).forEach((key) => {
21
-
22
- if (0 === self._frame.indexOf(self._specifics[key])) {
23
-
24
- found = true;
25
-
26
- const size = "object" === typeof self._specifics[key] && self._specifics[key] instanceof Buffer ?
27
- self._specifics[key].length : 1;
28
-
29
- self.emit(key);
30
-
31
- self._frame = Buffer.from(self._frame.slice(size, self._frame.length));
32
-
33
- }
34
-
35
- });
36
-
37
- if (found) {
38
- _extractSpecifics(self);
39
- }
40
-
41
- }
42
-
43
- module.exports = function digestEndOnly () {
44
-
45
- _extractSpecifics(this);
46
-
47
- const firstEnd = this._searchFirstEnd();
48
-
49
- // no end tag detected
50
- if (!firstEnd) {
51
- this._digesting = false;
52
- }
53
-
54
- // first end tag detected
55
- else {
56
-
57
- // extract first frame
58
- this.push(Buffer.from(this._frame.slice(0, firstEnd.end)));
59
-
60
- // remove extracted frame from main one
61
- this._frame = Buffer.from(this._frame.slice(firstEnd.end, this._frame.length));
62
-
63
- // second full frame detected
64
- if (-1 < this._searchTags(this._endWith)) {
65
- this._digest();
66
- }
67
- else {
68
- this._digesting = false;
69
- }
70
-
71
- }
72
-
73
- };
@@ -1,38 +0,0 @@
1
- /*
2
- eslint no-invalid-this: 0
3
- */
4
-
5
- "use strict";
6
-
7
- module.exports = function digestNoStartNoEnd () {
8
-
9
- const KEYS = Object.keys(this._specifics);
10
-
11
- if (KEYS.length) {
12
-
13
- KEYS.forEach((key) => {
14
-
15
- const size = "object" === typeof this._specifics[key] && this._specifics[key] instanceof Buffer ? this._specifics[key].length : 1;
16
-
17
- for (let foundAt = this._searchTags(this._specifics[key]); -1 < foundAt; foundAt = this._searchTags(this._specifics[key])) {
18
-
19
- this.emit(key);
20
-
21
- this._frame = Buffer.from(Buffer.concat([
22
- this._frame.slice(0, foundAt),
23
- this._frame.slice(foundAt + size, this._frame.length)
24
- ]));
25
-
26
- }
27
-
28
- });
29
-
30
- }
31
-
32
- this.push(Buffer.from(this._frame));
33
-
34
- this._frame = Buffer.from([]);
35
-
36
- this._digesting = false;
37
-
38
- };
@@ -1,92 +0,0 @@
1
- /*
2
- eslint no-unmodified-loop-condition:0, no-invalid-this: 0
3
- */
4
-
5
- "use strict";
6
-
7
- module.exports = function digestStartAndEnd () {
8
-
9
- const KEYS = Object.keys(this._specifics);
10
-
11
- if (KEYS.length) {
12
-
13
- KEYS.forEach((key) => {
14
-
15
- const firstStart = this._searchFirstStart();
16
-
17
- const size = "object" === typeof this._specifics[key] && this._specifics[key] instanceof Buffer ? this._specifics[key].length : 1;
18
-
19
- for (
20
- let foundAt = this._searchTags(this._specifics[key]), i = 0;
21
- -1 < foundAt && (!firstStart || foundAt < firstStart.start - i);
22
- foundAt = this._searchTags(this._specifics[key]), i += size
23
- ) {
24
-
25
- this.emit(key);
26
-
27
- this._frame = Buffer.from(Buffer.concat([
28
- this._frame.slice(0, foundAt),
29
- this._frame.slice(foundAt + size, this._frame.length)
30
- ]));
31
-
32
- }
33
-
34
- });
35
-
36
- }
37
-
38
- const firstStart = this._searchFirstStart();
39
-
40
- // no start tag detected
41
- if (!firstStart) {
42
-
43
- this._frame = Buffer.from([]);
44
- this._digesting = false;
45
-
46
- }
47
-
48
- // start tag detected
49
- else {
50
-
51
- const firstEnd = this._searchFirstEnd();
52
-
53
- // end tag not detected
54
- if (!firstEnd) {
55
-
56
- // remove useless bits
57
- this._frame = 0 < firstStart.start ? Buffer.from(this._frame.slice(firstStart.start, this._frame.length)) : this._frame;
58
- this._digesting = false;
59
-
60
- }
61
-
62
- // end tag detected
63
- else {
64
-
65
- this.push(Buffer.from(this._frame.slice(firstStart.start, firstEnd.end)));
66
-
67
- // remove extracted frame from main one
68
- this._frame = Buffer.from(this._frame.slice(firstEnd.end, this._frame.length));
69
-
70
- // search specifics
71
- let foundSpecific = false;
72
- for (let i = 0; i < KEYS.length && !foundSpecific; ++i) {
73
-
74
- if (-1 < this._searchTags(this._specifics[KEYS[i]])) {
75
- foundSpecific = true; break;
76
- }
77
-
78
- }
79
-
80
- // specific detected or second start detected (force minimal data length)
81
- if (foundSpecific || -1 < this._searchTags(this._startWith, 1)) {
82
- this._digest();
83
- }
84
- else {
85
- this._digesting = false;
86
- }
87
-
88
- }
89
-
90
- }
91
-
92
- };