-
Notifications
You must be signed in to change notification settings - Fork 0
/
processing.js
48 lines (35 loc) · 1.15 KB
/
processing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const sample = [3, 627471, [["ss4g99xs8", "Name", 0, [
["0"], [], [], [], [], [], [], [], [], [], [], [], [], []
]]]]
let Algorythm = function () {
this.mergeMain = (name, inputParts) => {
let result = sample;
const parts = [];
//input
result[2][0][1] = name;
inputParts.forEach(current => {
result[0] = current[0];
result[1] = current[1] + 1;
result[2][0][0] = current[2][0][0];
result[2][0][2] = current[2][0][2];
result[2][0][3][0] = current[2][0][3][0];
current[2][0][3].shift();
parts.push(current[2][0][3]);
});
return JSON.stringify(this.sortParts(parts, result));
}
this.sortParts = (partsS, resultS) => {
const sorted = [];
for (let i = 0; i < 13; i++) sorted.push([]);
//sort
partsS.forEach(part => {
for (let i = 0; i < part.length; i++) sorted[i].push(...part[i]);
});
//fill
for (let i = 0; i < sorted.length; i++) {
resultS[2][0][3][i + 1] = sorted[i];
}
return resultS;
}
}
let m = new Algorythm();