Skip to content

Instantly share code, notes, and snippets.

@joeyjiron06
Created June 15, 2020 23:41
Show Gist options
  • Save joeyjiron06/9d0a4cb5d2563be2506eaa9d0e7f702d to your computer and use it in GitHub Desktop.
Save joeyjiron06/9d0a4cb5d2563be2506eaa9d0e7f702d to your computer and use it in GitHub Desktop.
const readline = require("readline");
/**
* Writes a certain percentage number to the node js console
*/
const writePercentate = percentage => {
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0);
process.stdout.write(`loading... ${percentage}%`);
};
let percentage = 0;
const interval = setInterval(() => {
writePercentate(percentage);
if (++percentage == 100) {
clearInterval(interval);
}
}, 500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment