split-frames 2.4.1 → 2.4.3
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 +296 -0
- package/.travis.yml +1 -1
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/index.d.ts +14 -0
- package/lib/main.js +115 -79
- package/package.json +16 -15
- package/{tests → test}/0_compilation_typescript.js +0 -0
- package/{tests → test}/0_parameters.js +0 -0
- package/{tests → test}/1_withoutTags.js +0 -0
- package/{tests → test}/2_endOnly.js +0 -0
- package/{tests → test}/2_startOnly.js +23 -8
- package/{tests → test}/3_startAndEnd.js +0 -0
- package/{tests → test}/4_specifics.js +0 -0
- package/{tests → test}/5_documentation.js +0 -0
- package/{tests → test}/typescript/compilation.ts +0 -0
- package/gulpfile/eslint/env.json +0 -5
- package/gulpfile/eslint/globals.json +0 -25
- package/gulpfile/eslint/rules.json +0 -261
- package/gulpfile.js +0 -85
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
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
CHANGED
package/LICENSE
CHANGED
package/README.md
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -10,6 +10,16 @@ declare module "split-frames" {
|
|
|
10
10
|
"end": number;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
interface iOptions {
|
|
14
|
+
"startWith"?: Tag;
|
|
15
|
+
"startTimeout"?: number;
|
|
16
|
+
"endWith"?: Tag;
|
|
17
|
+
"escapeWith"?: Tag;
|
|
18
|
+
"escaped"?: Array<number>;
|
|
19
|
+
"specifics"?: { [key:string]: Tag };
|
|
20
|
+
"controlBits"?: ControlBits;
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
class Splitter extends require("stream").Transform {
|
|
14
24
|
|
|
15
25
|
protected _frame: Buffer;
|
|
@@ -24,6 +34,10 @@ declare module "split-frames" {
|
|
|
24
34
|
protected _specifics: object;
|
|
25
35
|
protected _controlBits: ControlBits;
|
|
26
36
|
|
|
37
|
+
// constructor
|
|
38
|
+
|
|
39
|
+
constructor (params?: iOptions);
|
|
40
|
+
|
|
27
41
|
// methods
|
|
28
42
|
protected _searchFirstTag(tag: Tag, beginWith?: number): SearchedBits;
|
|
29
43
|
protected _searchFirstStart(): SearchedBits;
|
package/lib/main.js
CHANGED
|
@@ -98,10 +98,59 @@ module.exports = class SplitFrames extends require("stream").Transform {
|
|
|
98
98
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
_digest () {
|
|
102
|
+
|
|
103
|
+
if (!this._frame.length) {
|
|
104
|
+
this._digesting = false;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
|
|
108
|
+
this._digesting = true;
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
this._digester();
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
this.emit("error", e);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
_transform (chunk, enc, cb) {
|
|
122
|
+
|
|
123
|
+
if (chunk.length) {
|
|
124
|
+
|
|
125
|
+
this._frame = Buffer.concat([ this._frame, chunk ]);
|
|
126
|
+
|
|
127
|
+
if (!this._digesting) {
|
|
128
|
+
this._digest();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
cb();
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
101
137
|
_searchTags (tags, beginAt = 0) {
|
|
102
138
|
|
|
103
139
|
// number
|
|
104
140
|
if ("number" === typeof tags) {
|
|
141
|
+
return this._searchNumberTags(tags, beginAt);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Buffer | Array
|
|
145
|
+
else if ("object" === typeof tags) {
|
|
146
|
+
return this._searchBufferOrArrayTags(tags, beginAt);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return -1;
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
_searchNumberTags (tags, beginAt) {
|
|
105
154
|
|
|
106
155
|
const foundAt = this._frame.indexOf(tags, beginAt);
|
|
107
156
|
|
|
@@ -116,19 +165,14 @@ module.exports = class SplitFrames extends require("stream").Transform {
|
|
|
116
165
|
if (!this._escaped.includes(this._escapeWith) || 1 >= foundAt || this._frame[foundAt - 2] !== this._escapeWith) {
|
|
117
166
|
return this._searchTags(tags, foundAt + 1);
|
|
118
167
|
}
|
|
119
|
-
else {
|
|
120
|
-
return foundAt;
|
|
121
|
-
}
|
|
122
168
|
|
|
123
169
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
170
|
+
|
|
171
|
+
return foundAt;
|
|
127
172
|
|
|
128
173
|
}
|
|
129
174
|
|
|
130
|
-
|
|
131
|
-
else if ("object" === typeof tags) {
|
|
175
|
+
_searchBufferOrArrayTags (tags, beginAt) {
|
|
132
176
|
|
|
133
177
|
// Buffer
|
|
134
178
|
if (tags instanceof Buffer) {
|
|
@@ -175,11 +219,9 @@ module.exports = class SplitFrames extends require("stream").Transform {
|
|
|
175
219
|
|
|
176
220
|
}
|
|
177
221
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return -1;
|
|
222
|
+
return -1;
|
|
181
223
|
|
|
182
|
-
|
|
224
|
+
}
|
|
183
225
|
|
|
184
226
|
_searchFirstTag (tag, beginAt = 0) {
|
|
185
227
|
|
|
@@ -189,44 +231,20 @@ module.exports = class SplitFrames extends require("stream").Transform {
|
|
|
189
231
|
// number
|
|
190
232
|
if ("number" === typeof tag) {
|
|
191
233
|
|
|
192
|
-
|
|
193
|
-
|
|
234
|
+
const find = this._searchFirstNumberTag(tag, beginAt);
|
|
235
|
+
|
|
236
|
+
startAt = find.start;
|
|
237
|
+
endAt = find.end;
|
|
194
238
|
|
|
195
239
|
}
|
|
196
240
|
|
|
197
241
|
// Buffer | Array
|
|
198
242
|
else if ("object" === typeof tag) {
|
|
199
243
|
|
|
200
|
-
|
|
201
|
-
if (tag instanceof Buffer) {
|
|
244
|
+
const find = this._searchFirstBufferOrArrayTag(tag, beginAt);
|
|
202
245
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Array
|
|
209
|
-
else if (tag instanceof Array) {
|
|
210
|
-
|
|
211
|
-
for (let i = 0; i < tag.length; ++i) {
|
|
212
|
-
|
|
213
|
-
// number | Buffer
|
|
214
|
-
if ("number" === typeof tag[i] ||
|
|
215
|
-
("object" === typeof tag[i] && tag[i] instanceof Buffer)
|
|
216
|
-
) {
|
|
217
|
-
|
|
218
|
-
const _startAt = this._frame.indexOf(tag[i], beginAt);
|
|
219
|
-
|
|
220
|
-
if (-1 < _startAt && (-1 >= startAt || _startAt < startAt)) {
|
|
221
|
-
startAt = _startAt;
|
|
222
|
-
endAt = startAt + ("number" === typeof tag[i] ? 1 : tag[i].length);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
}
|
|
246
|
+
startAt = find.start;
|
|
247
|
+
endAt = find.end;
|
|
230
248
|
|
|
231
249
|
}
|
|
232
250
|
|
|
@@ -270,6 +288,60 @@ module.exports = class SplitFrames extends require("stream").Transform {
|
|
|
270
288
|
|
|
271
289
|
}
|
|
272
290
|
|
|
291
|
+
_searchFirstNumberTag (tag, beginAt) {
|
|
292
|
+
|
|
293
|
+
const startAt = this._frame.indexOf(tag, beginAt);
|
|
294
|
+
|
|
295
|
+
return {
|
|
296
|
+
"start": startAt,
|
|
297
|
+
"end": startAt + 1
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
_searchFirstBufferOrArrayTag (tag, beginAt) {
|
|
303
|
+
|
|
304
|
+
let startAt = -1;
|
|
305
|
+
let endAt = -1;
|
|
306
|
+
|
|
307
|
+
// Buffer
|
|
308
|
+
if (tag instanceof Buffer) {
|
|
309
|
+
|
|
310
|
+
startAt = this._frame.indexOf(tag, beginAt);
|
|
311
|
+
endAt = startAt + tag.length;
|
|
312
|
+
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Array
|
|
316
|
+
else if (tag instanceof Array) {
|
|
317
|
+
|
|
318
|
+
for (let i = 0; i < tag.length; ++i) {
|
|
319
|
+
|
|
320
|
+
// number | Buffer
|
|
321
|
+
if ("number" === typeof tag[i] ||
|
|
322
|
+
("object" === typeof tag[i] && tag[i] instanceof Buffer)
|
|
323
|
+
) {
|
|
324
|
+
|
|
325
|
+
const _startAt = this._frame.indexOf(tag[i], beginAt);
|
|
326
|
+
|
|
327
|
+
if (-1 < _startAt && (-1 >= startAt || _startAt < startAt)) {
|
|
328
|
+
startAt = _startAt;
|
|
329
|
+
endAt = startAt + ("number" === typeof tag[i] ? 1 : tag[i].length);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return {
|
|
339
|
+
"start": startAt,
|
|
340
|
+
"end": endAt
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
}
|
|
344
|
+
|
|
273
345
|
_searchFirstStart () {
|
|
274
346
|
return this._searchFirstTag(this._startWith);
|
|
275
347
|
}
|
|
@@ -298,40 +370,4 @@ module.exports = class SplitFrames extends require("stream").Transform {
|
|
|
298
370
|
|
|
299
371
|
}
|
|
300
372
|
|
|
301
|
-
_digest () {
|
|
302
|
-
|
|
303
|
-
if (!this._frame.length) {
|
|
304
|
-
this._digesting = false;
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
|
|
308
|
-
this._digesting = true;
|
|
309
|
-
|
|
310
|
-
try {
|
|
311
|
-
this._digester();
|
|
312
|
-
}
|
|
313
|
-
catch (e) {
|
|
314
|
-
this.emit("error", e);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
_transform (chunk, enc, cb) {
|
|
322
|
-
|
|
323
|
-
if (chunk.length) {
|
|
324
|
-
|
|
325
|
-
this._frame = Buffer.concat([ this._frame, chunk ]);
|
|
326
|
-
|
|
327
|
-
if (!this._digesting) {
|
|
328
|
-
this._digest();
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
cb();
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
|
|
337
373
|
};
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "split-frames",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
4
4
|
"description": "Split Buffer frames from streams",
|
|
5
5
|
"main": "lib/main.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
8
|
+
"lint": "npx eslint ./lib/**/*.js ./test/**/*.js",
|
|
9
|
+
"check-updates": "npx check-version-modules",
|
|
10
|
+
"unit-tests": "npx nyc --reporter=html --reporter=text mocha",
|
|
11
|
+
"tests": "npm run-script lint && npm run-script check-updates && npm run-script unit-tests",
|
|
12
|
+
"ci": "npm run-script tests && npx nyc report --reporter=text-lcov | coveralls"
|
|
11
13
|
},
|
|
12
14
|
"husky": {
|
|
13
15
|
"hooks": {
|
|
14
|
-
"pre-commit": "
|
|
15
|
-
"pre-push": "
|
|
16
|
+
"pre-commit": "npm run-script lint",
|
|
17
|
+
"pre-push": "npm run-script tests"
|
|
16
18
|
}
|
|
17
19
|
},
|
|
18
20
|
"repository": {
|
|
@@ -50,17 +52,16 @@
|
|
|
50
52
|
},
|
|
51
53
|
"dependencies": {},
|
|
52
54
|
"devDependencies": {
|
|
53
|
-
"@types/node": "
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"husky": "1.1.1"
|
|
55
|
+
"@types/node": "18.11.9",
|
|
56
|
+
"check-version-modules": "1.3.5",
|
|
57
|
+
"coveralls": "3.1.1",
|
|
58
|
+
"eslint": "8.26.0",
|
|
59
|
+
"husky": "8.0.1",
|
|
60
|
+
"mocha": "10.1.0",
|
|
61
|
+
"nyc": "15.1.0"
|
|
61
62
|
},
|
|
62
63
|
"homepage": "https://github.com/Psychopoulet/split-frames#readme",
|
|
63
64
|
"engines": {
|
|
64
|
-
"node": ">=
|
|
65
|
+
"node": ">=16.0.0"
|
|
65
66
|
}
|
|
66
67
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -268,12 +268,7 @@ describe("start only", () => {
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
// tested frame
|
|
271
|
-
}).write(Buffer.from([
|
|
272
|
-
0x24,
|
|
273
|
-
STX, 0x24, 0x25, 0x26,
|
|
274
|
-
STX2, 0x24, 0x25,
|
|
275
|
-
STX
|
|
276
|
-
]));
|
|
271
|
+
}).write(Buffer.from([ 0x24, STX, 0x24, 0x25, 0x26, STX2, 0x24, 0x25, STX ]));
|
|
277
272
|
|
|
278
273
|
});
|
|
279
274
|
|
|
@@ -318,8 +313,28 @@ describe("start only", () => {
|
|
|
318
313
|
// tested frame
|
|
319
314
|
}).write(Buffer.from([
|
|
320
315
|
0x24,
|
|
321
|
-
STX,
|
|
322
|
-
|
|
316
|
+
STX,
|
|
317
|
+
0x24,
|
|
318
|
+
DLE,
|
|
319
|
+
STX,
|
|
320
|
+
0x25,
|
|
321
|
+
0x26,
|
|
322
|
+
DLE,
|
|
323
|
+
DLE,
|
|
324
|
+
0x24,
|
|
325
|
+
0x25,
|
|
326
|
+
0x26,
|
|
327
|
+
STX2,
|
|
328
|
+
0x24,
|
|
329
|
+
DLE,
|
|
330
|
+
STX,
|
|
331
|
+
0x25,
|
|
332
|
+
0x26,
|
|
333
|
+
DLE,
|
|
334
|
+
DLE,
|
|
335
|
+
0x24,
|
|
336
|
+
0x25,
|
|
337
|
+
0x26,
|
|
323
338
|
STX
|
|
324
339
|
]));
|
|
325
340
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/gulpfile/eslint/env.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
"after",
|
|
3
|
-
"afterEach",
|
|
4
|
-
"angular",
|
|
5
|
-
"before",
|
|
6
|
-
"beforeEach",
|
|
7
|
-
"Buffer",
|
|
8
|
-
"console",
|
|
9
|
-
"clearInterval",
|
|
10
|
-
"clearTimeout",
|
|
11
|
-
"describe",
|
|
12
|
-
"it",
|
|
13
|
-
"jQuery",
|
|
14
|
-
"Promise",
|
|
15
|
-
"Map",
|
|
16
|
-
"module",
|
|
17
|
-
"os",
|
|
18
|
-
"process",
|
|
19
|
-
"require",
|
|
20
|
-
"setImmediate",
|
|
21
|
-
"setInterval",
|
|
22
|
-
"setTimeout",
|
|
23
|
-
"__dirname",
|
|
24
|
-
"__filename"
|
|
25
|
-
]
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
"for-direction": 0,
|
|
4
|
-
"getter-return": "error",
|
|
5
|
-
"no-await-in-loop": "error",
|
|
6
|
-
"no-compare-neg-zero": "error",
|
|
7
|
-
"no-cond-assign": "error",
|
|
8
|
-
"no-console": [ "error", { "allow": [ "info", "warn", "error" ] }],
|
|
9
|
-
"no-constant-condition": "error",
|
|
10
|
-
"no-control-regex": "error",
|
|
11
|
-
"no-debugger": "error",
|
|
12
|
-
"no-dupe-args": "error",
|
|
13
|
-
"no-dupe-keys": "error",
|
|
14
|
-
"no-duplicate-case": "error",
|
|
15
|
-
"no-empty": "error",
|
|
16
|
-
"no-empty-character-class": "error",
|
|
17
|
-
"no-ex-assign": "error",
|
|
18
|
-
"no-extra-boolean-cast": "error",
|
|
19
|
-
"no-extra-parens": "error",
|
|
20
|
-
"no-extra-semi": "error",
|
|
21
|
-
"no-func-assign": "error",
|
|
22
|
-
"no-inner-declarations": "error",
|
|
23
|
-
"no-invalid-regexp": "error",
|
|
24
|
-
"no-irregular-whitespace": "error",
|
|
25
|
-
"no-obj-calls": "error",
|
|
26
|
-
"no-prototype-builtins": "error",
|
|
27
|
-
"no-regex-spaces": "error",
|
|
28
|
-
"no-sparse-arrays": "error",
|
|
29
|
-
"no-template-curly-in-string": "error",
|
|
30
|
-
"no-unexpected-multiline": "error",
|
|
31
|
-
"no-unreachable": "error",
|
|
32
|
-
"no-unsafe-finally": "error",
|
|
33
|
-
"no-unsafe-negation": "error",
|
|
34
|
-
"use-isnan": "error",
|
|
35
|
-
"valid-jsdoc": "error",
|
|
36
|
-
"valid-typeof": "error",
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"accessor-pairs": "error",
|
|
40
|
-
"array-callback-return": "error",
|
|
41
|
-
"block-scoped-var": "error",
|
|
42
|
-
"class-methods-use-this": "error",
|
|
43
|
-
"complexity": "error",
|
|
44
|
-
"consistent-return": "error",
|
|
45
|
-
"curly": "error",
|
|
46
|
-
"default-case": "error",
|
|
47
|
-
"dot-location": [ "error", "property" ],
|
|
48
|
-
"dot-notation": "error",
|
|
49
|
-
"eqeqeq": "error",
|
|
50
|
-
"guard-for-in": "error",
|
|
51
|
-
"no-alert": "error",
|
|
52
|
-
"no-caller": "error",
|
|
53
|
-
"no-case-declarations": "error",
|
|
54
|
-
"no-div-regex": "error",
|
|
55
|
-
"no-else-return": 0,
|
|
56
|
-
"no-empty-function": "error",
|
|
57
|
-
"no-empty-pattern": "error",
|
|
58
|
-
"no-eq-null": "error",
|
|
59
|
-
"no-eval": "error",
|
|
60
|
-
"no-extend-native": "error",
|
|
61
|
-
"no-extra-bind": "error",
|
|
62
|
-
"no-extra-label": "error",
|
|
63
|
-
"no-fallthrough": "error",
|
|
64
|
-
"no-floating-decimal": "error",
|
|
65
|
-
"no-global-assign": "error",
|
|
66
|
-
"no-implicit-coercion": "error",
|
|
67
|
-
"no-implicit-globals": "error",
|
|
68
|
-
"no-implied-eval": "error",
|
|
69
|
-
"no-invalid-this": "error",
|
|
70
|
-
"no-iterator": "error",
|
|
71
|
-
"no-labels": "error",
|
|
72
|
-
"no-lone-blocks": "error",
|
|
73
|
-
"no-loop-func": "error",
|
|
74
|
-
"no-magic-numbers": 0,
|
|
75
|
-
"no-multi-spaces": "error",
|
|
76
|
-
"no-multi-str": "error",
|
|
77
|
-
"no-new": "error",
|
|
78
|
-
"no-new-func": "error",
|
|
79
|
-
"no-new-wrappers": "error",
|
|
80
|
-
"no-octal": "error",
|
|
81
|
-
"no-octal-escape": "error",
|
|
82
|
-
"no-param-reassign": "error",
|
|
83
|
-
"no-proto": "error",
|
|
84
|
-
"no-redeclare": "error",
|
|
85
|
-
"no-restricted-properties": "error",
|
|
86
|
-
"no-return-assign": "error",
|
|
87
|
-
"no-return-await": "error",
|
|
88
|
-
"no-script-url": "error",
|
|
89
|
-
"no-self-assign": "error",
|
|
90
|
-
"no-self-compare": "error",
|
|
91
|
-
"no-sequences": "error",
|
|
92
|
-
"no-throw-literal": "error",
|
|
93
|
-
"no-unmodified-loop-condition": "error",
|
|
94
|
-
"no-unused-expressions": "error",
|
|
95
|
-
"no-unused-labels": "error",
|
|
96
|
-
"no-useless-call": "error",
|
|
97
|
-
"no-useless-concat": "error",
|
|
98
|
-
"no-useless-escape": "error",
|
|
99
|
-
"no-useless-return": "error",
|
|
100
|
-
"no-void": "error",
|
|
101
|
-
"no-warning-comments": "error",
|
|
102
|
-
"no-with": "error",
|
|
103
|
-
"prefer-promise-reject-errors": "error",
|
|
104
|
-
"radix": "error",
|
|
105
|
-
"require-await": "error",
|
|
106
|
-
"vars-on-top": "error",
|
|
107
|
-
"wrap-iife": "error",
|
|
108
|
-
"yoda": [ "error", "always" ],
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
"strict": [ "error", "global" ],
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
"init-declarations": [ "error", "always" ],
|
|
115
|
-
"no-catch-shadow": "error",
|
|
116
|
-
"no-delete-var": 0,
|
|
117
|
-
"no-label-var": "error",
|
|
118
|
-
"no-restricted-globals": "error",
|
|
119
|
-
"no-shadow": "error",
|
|
120
|
-
"no-shadow-restricted-names": "error",
|
|
121
|
-
"no-undef": "error",
|
|
122
|
-
"no-undef-init": "error",
|
|
123
|
-
"no-undefined": "error",
|
|
124
|
-
"no-unused-vars": "error",
|
|
125
|
-
"no-use-before-define": "error",
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
"callback-return": [ "error", [ "done", "send.error", "send.success" ] ],
|
|
129
|
-
"global-require": 0,
|
|
130
|
-
"handle-callback-err": "error",
|
|
131
|
-
"no-buffer-constructor": "error",
|
|
132
|
-
"no-mixed-requires": "error",
|
|
133
|
-
"no-new-require": "error",
|
|
134
|
-
"no-path-concat": "error",
|
|
135
|
-
"no-process-env": "error",
|
|
136
|
-
"no-process-exit": "error",
|
|
137
|
-
"no-restricted-modules": "error",
|
|
138
|
-
"no-sync": "error",
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
"array-bracket-newline": [ "error", { "multiline": true } ],
|
|
142
|
-
"array-bracket-spacing": [ "error", "always" ],
|
|
143
|
-
"array-element-newline": 0,
|
|
144
|
-
"block-spacing": "error",
|
|
145
|
-
"brace-style": [ "error", "stroustrup" ],
|
|
146
|
-
"camelcase": "error",
|
|
147
|
-
"capitalized-comments": 0,
|
|
148
|
-
"comma-dangle": [ "error", "never" ],
|
|
149
|
-
"comma-spacing": [ "error", { "before": false, "after": true } ],
|
|
150
|
-
"comma-style": [ "error", "last" ],
|
|
151
|
-
"computed-property-spacing": [ "error", "never" ],
|
|
152
|
-
"consistent-this": "error",
|
|
153
|
-
"eol-last": "error",
|
|
154
|
-
"func-call-spacing": "error",
|
|
155
|
-
"func-name-matching": "error",
|
|
156
|
-
"func-names": [ "error", "always" ],
|
|
157
|
-
"func-style": [ "error", "declaration" ],
|
|
158
|
-
"id-blacklist": 0,
|
|
159
|
-
"id-length": 0,
|
|
160
|
-
"id-match": 0,
|
|
161
|
-
"indent": 0,
|
|
162
|
-
"jsx-quotes": [ "error", "prefer-double" ],
|
|
163
|
-
"key-spacing": [ "error", { "beforeColon": false, "afterColon": true } ],
|
|
164
|
-
"keyword-spacing": [ "error", { "after": true, "before": true } ],
|
|
165
|
-
"line-comment-position": [ "error", { "position": "above" } ],
|
|
166
|
-
"linebreak-style": 0,
|
|
167
|
-
"lines-around-comment": "error",
|
|
168
|
-
"max-depth": 0,
|
|
169
|
-
"max-len": [ "error", 150 ],
|
|
170
|
-
"max-lines": 0,
|
|
171
|
-
"max-nested-callbacks": [ "error", 5 ],
|
|
172
|
-
"max-params": [ "error", 5 ],
|
|
173
|
-
"max-statements": 0,
|
|
174
|
-
"max-statements-per-line": [ "error", { "max": 2 } ],
|
|
175
|
-
"multiline-ternary": 0,
|
|
176
|
-
"new-cap": "error",
|
|
177
|
-
"new-parens": "error",
|
|
178
|
-
"newline-per-chained-call": 0,
|
|
179
|
-
"no-array-constructor": "error",
|
|
180
|
-
"no-bitwise": "error",
|
|
181
|
-
"no-continue": "error",
|
|
182
|
-
"no-inline-comments": "error",
|
|
183
|
-
"no-lonely-if": "error",
|
|
184
|
-
"no-mixed-operators": "error",
|
|
185
|
-
"no-mixed-spaces-and-tabs": "error",
|
|
186
|
-
"no-multi-assign": "error",
|
|
187
|
-
"no-multiple-empty-lines": "error",
|
|
188
|
-
"no-negated-condition": 0,
|
|
189
|
-
"no-nested-ternary": "error",
|
|
190
|
-
"no-new-object": "error",
|
|
191
|
-
"no-plusplus": 0,
|
|
192
|
-
"no-restricted-syntax": "error",
|
|
193
|
-
"no-tabs": 0,
|
|
194
|
-
"no-ternary": 0,
|
|
195
|
-
"no-trailing-spaces": "error",
|
|
196
|
-
"no-underscore-dangle": 0,
|
|
197
|
-
"no-unneeded-ternary": "error",
|
|
198
|
-
"no-whitespace-before-property": "error",
|
|
199
|
-
"nonblock-statement-body-position": [ "error", "below" ],
|
|
200
|
-
"object-curly-newline": [ "error", { "consistent": true } ],
|
|
201
|
-
"object-curly-spacing": [ "error", "always" ],
|
|
202
|
-
"object-property-newline": "error",
|
|
203
|
-
"one-var": [ "error", "never" ],
|
|
204
|
-
"one-var-declaration-per-line": "error",
|
|
205
|
-
"operator-assignment": [ "error", "always" ],
|
|
206
|
-
"operator-linebreak": [ "error", "after" ],
|
|
207
|
-
"padded-blocks": ["error", { "classes": "always", "switches": "always" } ],
|
|
208
|
-
"padding-line-between-statements": "error",
|
|
209
|
-
"quote-props": [ "error", "always" ],
|
|
210
|
-
"quotes": [ "error", "double" ],
|
|
211
|
-
"require-jsdoc": "error",
|
|
212
|
-
"semi": [ "error", "always" ],
|
|
213
|
-
"semi-spacing": [ "error", { "before": false, "after": true } ],
|
|
214
|
-
"semi-style": [ "error", "last" ],
|
|
215
|
-
"sort-keys": 0,
|
|
216
|
-
"sort-vars": "error",
|
|
217
|
-
"space-before-blocks": [ "error", "always" ],
|
|
218
|
-
"space-before-function-paren": [ "error", "always" ],
|
|
219
|
-
"space-in-parens": [ "error", "never" ],
|
|
220
|
-
"space-infix-ops": "error",
|
|
221
|
-
"space-unary-ops": "error",
|
|
222
|
-
"spaced-comment": [ "error", "always" ],
|
|
223
|
-
"switch-colon-spacing": [ "error", { "after": true, "before": false } ],
|
|
224
|
-
"template-tag-spacing": [ "error", "always" ],
|
|
225
|
-
"unicode-bom": 0,
|
|
226
|
-
"wrap-regex": "error",
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
"arrow-body-style": [ "error", "always" ],
|
|
230
|
-
"arrow-parens": [ "error", "always" ],
|
|
231
|
-
"arrow-spacing": ["error", { "before": true, "after": true } ],
|
|
232
|
-
"constructor-super": "error",
|
|
233
|
-
"generator-star-spacing": [ "error", { "before": true, "after": false } ],
|
|
234
|
-
"no-class-assign": "error",
|
|
235
|
-
"no-confusing-arrow": "error",
|
|
236
|
-
"no-const-assign": "error",
|
|
237
|
-
"no-dupe-class-members": "error",
|
|
238
|
-
"no-duplicate-imports": "error",
|
|
239
|
-
"no-new-symbol": "error",
|
|
240
|
-
"no-restricted-imports": 0,
|
|
241
|
-
"no-this-before-super": "error",
|
|
242
|
-
"no-useless-computed-key": "error",
|
|
243
|
-
"no-useless-constructor": "error",
|
|
244
|
-
"no-useless-rename": "error",
|
|
245
|
-
"no-var": "error",
|
|
246
|
-
"object-shorthand": "error",
|
|
247
|
-
"prefer-arrow-callback": "error",
|
|
248
|
-
"prefer-const": "error",
|
|
249
|
-
"prefer-destructuring": "error",
|
|
250
|
-
"prefer-numeric-literals": "error",
|
|
251
|
-
"prefer-rest-params": "error",
|
|
252
|
-
"prefer-spread": "error",
|
|
253
|
-
"prefer-template": 0,
|
|
254
|
-
"require-yield": "error",
|
|
255
|
-
"rest-spread-spacing": [ "error", "never" ],
|
|
256
|
-
"sort-imports": "error",
|
|
257
|
-
"symbol-description": "error",
|
|
258
|
-
"template-curly-spacing": "error",
|
|
259
|
-
"yield-star-spacing": [ "error", { "before": true, "after": false } ]
|
|
260
|
-
|
|
261
|
-
}
|
package/gulpfile.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
// deps
|
|
5
|
-
|
|
6
|
-
const path = require("path");
|
|
7
|
-
|
|
8
|
-
// gulp
|
|
9
|
-
const gulp = require("gulp");
|
|
10
|
-
const plumber = require("gulp-plumber");
|
|
11
|
-
|
|
12
|
-
// tests
|
|
13
|
-
const eslint = require("gulp-eslint");
|
|
14
|
-
const mocha = require("gulp-mocha");
|
|
15
|
-
|
|
16
|
-
// reports
|
|
17
|
-
const istanbul = require("gulp-istanbul");
|
|
18
|
-
const coveralls = require("gulp-coveralls");
|
|
19
|
-
|
|
20
|
-
// consts
|
|
21
|
-
|
|
22
|
-
const APP_FILES = [ path.join(__dirname, "lib", "**", "*.js") ];
|
|
23
|
-
const UNITTESTS_FILES = [ path.join(__dirname, "tests", "**", "*.js") ];
|
|
24
|
-
|
|
25
|
-
const ALL_FILES = [ path.join(__dirname, "gulpfile.js") ]
|
|
26
|
-
.concat(APP_FILES)
|
|
27
|
-
.concat(UNITTESTS_FILES);
|
|
28
|
-
|
|
29
|
-
// tasks
|
|
30
|
-
|
|
31
|
-
gulp.task("eslint", () => {
|
|
32
|
-
|
|
33
|
-
return gulp.src(ALL_FILES)
|
|
34
|
-
.pipe(plumber())
|
|
35
|
-
.pipe(eslint({
|
|
36
|
-
"env": require(path.join(__dirname, "gulpfile", "eslint", "env.json")),
|
|
37
|
-
"globals": require(path.join(__dirname, "gulpfile", "eslint", "globals.json")),
|
|
38
|
-
"parserOptions": {
|
|
39
|
-
"ecmaVersion": 6
|
|
40
|
-
},
|
|
41
|
-
// http://eslint.org/docs/rules/
|
|
42
|
-
"rules": require(path.join(__dirname, "gulpfile", "eslint", "rules.json"))
|
|
43
|
-
}))
|
|
44
|
-
.pipe(eslint.format())
|
|
45
|
-
.pipe(eslint.failAfterError());
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
gulp.task("istanbul", gulp.series("eslint", () => {
|
|
50
|
-
|
|
51
|
-
return gulp.src(APP_FILES)
|
|
52
|
-
.pipe(plumber())
|
|
53
|
-
.pipe(istanbul({ "includeUntested": true }))
|
|
54
|
-
.pipe(istanbul.hookRequire());
|
|
55
|
-
|
|
56
|
-
}));
|
|
57
|
-
|
|
58
|
-
gulp.task("mocha", gulp.series("istanbul", () => {
|
|
59
|
-
|
|
60
|
-
return gulp.src(UNITTESTS_FILES)
|
|
61
|
-
.pipe(plumber())
|
|
62
|
-
.pipe(mocha())
|
|
63
|
-
.pipe(istanbul.writeReports())
|
|
64
|
-
.pipe(istanbul.enforceThresholds({ "thresholds": { "global": 85 } }));
|
|
65
|
-
|
|
66
|
-
}));
|
|
67
|
-
|
|
68
|
-
gulp.task("coveralls", gulp.series("mocha", () => {
|
|
69
|
-
|
|
70
|
-
return gulp.src(path.join(__dirname, "coverage", "lcov.info"))
|
|
71
|
-
.pipe(plumber())
|
|
72
|
-
.pipe(coveralls());
|
|
73
|
-
|
|
74
|
-
}));
|
|
75
|
-
|
|
76
|
-
// watcher
|
|
77
|
-
|
|
78
|
-
gulp.task("watch", () => {
|
|
79
|
-
gulp.watch(ALL_FILES, [ "eslint" ]);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// default
|
|
84
|
-
|
|
85
|
-
gulp.task("default", gulp.series("mocha"));
|