Skip to content

Instantly share code, notes, and snippets.

@BytewaveMLP
Last active January 24, 2018 15:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BytewaveMLP/9aea184ab9a056d9a2e68682ac666cf6 to your computer and use it in GitHub Desktop.
Save BytewaveMLP/9aea184ab9a056d9a2e68682ac666cf6 to your computer and use it in GitHub Desktop.
const readline = require("readline");
const TINYFACE = "• c •";
const BOOP = "/)";
const LINE = "~";
const HEART = "❤";
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms)).catch(() => {});
}
async function tinyload(length, delay) {
if (length < 2) {
throw "Length is too short";
}
let bar = new Array(length);
bar[0] = HEART;
for (i = 1; i < length; i++) {
bar[i] = LINE;
}
process.stdout.write(BOOP + " " + bar.join(" ") + " " + TINYFACE);
await sleep(delay);
readline.cursorTo(process.stdout, 0);
for (i = 0; i < length - 1; i++) {
bar[i] = LINE;
bar[i + 1] = HEART;
process.stdout.write(BOOP + " " + bar.join(" ") + " " + TINYFACE);
await sleep(delay);
readline.cursorTo(process.stdout, 0);
}
}
tinyload(10, 50);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment