Total Complexity | 8 |
Complexity/F | 1.14 |
Lines of Code | 42 |
Function Count | 7 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | export default class Characters { |
||
2 | constructor(value, object = {}) { |
||
3 | this.object = object; |
||
4 | this.chars = ''; |
||
5 | this.times = 0; |
||
6 | this.atFirst = null; |
||
7 | this.atEnd = null; |
||
8 | this.between = null; |
||
9 | this.langsRegex = ''; |
||
10 | this.languages = ''; |
||
11 | this.value = value || null; |
||
12 | } |
||
13 | |||
14 | isObject() { |
||
15 | return (typeof this.object === 'object' && Object.keys(this.object).length); |
||
16 | } |
||
17 | |||
18 | isCharsString() { |
||
19 | return (typeof this.chars === 'string'); |
||
20 | } |
||
21 | |||
22 | isCharsAnArray() { |
||
23 | return Array.isArray(this.chars); |
||
24 | } |
||
25 | |||
26 | canCharsSeparateViaComma() { |
||
27 | return this.char.match(/,/) && this.char.match(/,/g).length > 1; |
||
28 | } |
||
29 | |||
30 | formatCharsViaComma($comma) { |
||
31 | if ($comma) { |
||
32 | this.chars = this.chars.split(','); |
||
33 | } else { |
||
34 | this.chars = this.chars.split(''); |
||
35 | } |
||
36 | return `\\${this.chars.join('\\')}`; |
||
37 | } |
||
38 | |||
39 | formatCharsString() { |
||
40 | return this.formatCharsViaComma(this.canCharsSeparateViaComma()); |
||
41 | } |
||
42 | } |
||
43 |