Completed
Pull Request — master (#166)
by
unknown
47s
created

helpers.js ➔ ... ➔ ???   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 6
rs 9.4285
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