-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIndentInverter.txt
39 lines (35 loc) · 1.11 KB
/
IndentInverter.txt
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
//THIS IS JUST TO MAKE THE CODE INTENDTAION INVERTED
let canvas = "";
let sizes = [];
let largest = 0;
let ls = unrolled.code.split("\n");
console.log(ls);
for(var i = 0; i < ls.length; i++){
let re = /^[\s]*/gm;
let spaces = re.exec(ls[i]);
let size = Math.floor(spaces[0].length/4);
ls[i] = ls[i].replace(spaces, '');
sizes.push(size);
}
console.log("1");
let max = Math.max.apply(null ,sizes);
let newSize = []
for(var i = 0; i < ls.length; i++){
newSize.push(max - sizes[i]);
}
console.log("1");
for(var i = 0; i < ls.length; i++){
var sp = "";
for(var b = 0; b < newSize[i]; b++){
sp = sp + " ";
}
ls[i] = sp + ls[i];
}
console.log("1");
let shished = "";
for(var i = 0; i < ls.length; i++){
shished = shished + ls[i] + "\n";
}
2
unrolled.code = shished;
//FINISHED INVERTING INDENTATION.