Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let fs = require('fs');
- let arr = process.argv;
- let getTheLine = readFileSync(arr[2].toString());
- let counter1 = 0;
- let len = getTheLine.length;
- let quantity = "";
- while(len > counter1)
- {
- let counter2 = 1;
- while (getTheLine.CharAt(counter1) == getTheLine.CharAt(counter1 + counter2))
- counter2++;
- counter2_Old = counter2;
- while(counter2 > 255)
- {
- quantity += "#" + String.fromCharCode(255) + getTheLine.CharAt(counter1);
- }
- if(counter2 > 3)
- quantity += "#" + String.fromCharCode(counter2) + getTheLine.CharAt(counter1);
- else if (inputString.charAt(counter1) == "#")
- quantity += "#" + String.fromCharCode(counter2) + inputString.charAt(counter2);
- else
- quantity += inputString.substr(counter1,counter2);
- len += counter2_Old;
- }
- fs.writeFileSync(".txt", quantity);
- let stringdecoding = fs.writeFileSync(".txt");
- let newstr = stringdecoding;
- let counter1 = 0;
- let len = stringdecoding.length;
- while (counter1 < len)
- {
- if (stringdecoding(counter1)==='#')
- {
- newstr = newstr.replace("#" + stringdecoding[i+1] + stringdecoding[i+2], stringdecoding[i+2].repeat(stringdecoding[i+1].charCodeAt(0)));
- counter1 += 2;
- }
- counter1++;
- }
- fs.writeFileSync(".txt",newstr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement