src/help/linearizeEncodings.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 2

Size

Lines of Code 22
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
c 0
b 0
f 0
nc 1
dl 0
loc 22
rs 10
wmc 4
mnd 2
bc 5
fnc 2
bpm 2.5
cpm 2
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A linearizeEncodings.js ➔ linearizeEncodings 0 18 1
1
export default linearizeEncodings;
2
3
// Encodings can be nestled like [[1-1, 1-2], 2, [3-1, 3-2]
4
// Convert to [1-1, 1-2, 2, 3-1, 3-2]
5
function linearizeEncodings(encodings){
6
	var linearEncodings = [];
7
	function nextLevel(encoded){
8
		if(Array.isArray(encoded)){
9
			for(let i = 0; i < encoded.length; i++){
10
				nextLevel(encoded[i]);
11
			}
12
		}
13
		else{
14
			encoded.text = encoded.text || "";
15
			encoded.data = encoded.data || "";
16
			linearEncodings.push(encoded);
17
		}
18
	}
19
	nextLevel(encodings);
20
21
	return linearEncodings;
22
}
23