Total Complexity | 6 |
Complexity/F | 2 |
Lines of Code | 21 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | const OPTIONS = [ 'ean128', 'ignoreBrackets', 'ignoreSpaces' ]; |
||
2 | |||
3 | export const normalizeOptions = (options) => { |
||
4 | OPTIONS.forEach((option) => { |
||
5 | if (option in options) { |
||
6 | const value = options[option]; |
||
7 | options[option] = value === true || value === 'true'; |
||
8 | } |
||
9 | }); |
||
10 | return options; |
||
11 | }; |
||
12 | |||
13 | export const formatData = (data, options) => { |
||
14 | if (options.ignoreBrackets === true) { |
||
15 | data = data.replace(/[()]/g, ''); |
||
16 | } |
||
17 | if (options.ignoreSpaces === true) { |
||
18 | data = data.replace(/ /g, ''); |
||
19 | } |
||
20 | return data; |
||
21 | }; |
||
22 |