Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. let fs = require('fs');
  2.  
  3. let arr = process.argv;
  4. let getTheLine = readFileSync(arr[2].toString());
  5. let counter1 = 0;
  6. let len = getTheLine.length;
  7. let quantity = "";
  8.  
  9. while(len > counter1)
  10. {
  11. let counter2 = 1;
  12. while (getTheLine.CharAt(counter1) == getTheLine.CharAt(counter1 + counter2))
  13. counter2++;
  14. counter2_Old = counter2;
  15. while(counter2 > 255)
  16. {
  17. quantity += "#" + String.fromCharCode(255) + getTheLine.CharAt(counter1);
  18. }
  19. if(counter2 > 3)
  20. quantity += "#" + String.fromCharCode(counter2) + getTheLine.CharAt(counter1);
  21. else if (inputString.charAt(counter1) == "#")
  22. quantity += "#" + String.fromCharCode(counter2) + inputString.charAt(counter2);
  23. else
  24. quantity += inputString.substr(counter1,counter2);
  25. len += counter2_Old;
  26. }
  27.  
  28. fs.writeFileSync(".txt", quantity);
  29.  
  30. let stringdecoding = fs.writeFileSync(".txt");
  31. let newstr = stringdecoding;
  32. let counter1 = 0;
  33. let len = stringdecoding.length;
  34.  
  35. while (counter1 < len)
  36. {
  37. if (stringdecoding(counter1)==='#')
  38. {
  39. newstr = newstr.replace("#" + stringdecoding[i+1] + stringdecoding[i+2], stringdecoding[i+2].repeat(stringdecoding[i+1].charCodeAt(0)));
  40. counter1 += 2;
  41. }
  42. counter1++;
  43. }
  44. fs.writeFileSync(".txt",newstr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement