Skip to content

Instantly share code, notes, and snippets.

@jan-osch
Created June 1, 2018 12:57
Show Gist options
  • Save jan-osch/6d2682ac43629521e61993de9fb3e954 to your computer and use it in GitHub Desktop.
Save jan-osch/6d2682ac43629521e61993de9fb3e954 to your computer and use it in GitHub Desktop.
function * dawejPadding(str, len, ch=' '){
let current = str.length;
while(current < len){
yield ch;
current++;
}
yield str;
}
const printuj = (subject) => {
for(const c of subject){
process.stdout.write(c);
}
process.stdout.write('\n')
}
const leftLepszyPad = (str, len, ch=' ')=>{
const missing = len - str.length;
return `${new Array(missing).fill(ch).join('')}${str}`
}
const DUZO = 400000000
// printuj(leftLepszyPad('kuku', 100000000, 'X'))
printuj(leftPad('kuku', DUZO, 'X'))
printuj(dawejPadding('kuku', DUZO, 'X'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment