Skip to content

Instantly share code, notes, and snippets.

@ckiee
Last active February 18, 2018 10:47
Show Gist options
  • Save ckiee/8efe7e0d4e6deecf94f2f22b744f0b9d to your computer and use it in GitHub Desktop.
Save ckiee/8efe7e0d4e6deecf94f2f22b744f0b9d to your computer and use it in GitHub Desktop.
const fs = require("fs") ;
const code = fs.readFileSync("kslaslala.js").toString().split("\r").join("") ;
const validChars = "{;})".split("") ;
const lines = code.split("\n") ;
let badchars = "" ;
for (let line of lines) {
console.log(padCharToEnd(line) )
}
/**
* @param {String} line
* @returns {String}
*/
function padCharToEnd(line) {
const lastChar = line[line.length-1] ;
if (validChars.indexOf(lastChar) == -1) return line ;
line = line.slice(0, line.length-1) ;
const length = -(line.length-99) ;
line+=new Array(length).join(" ")+lastChar;
return line ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment