Skip to content

Instantly share code, notes, and snippets.

@miki2826
Last active January 18, 2017 14:31
Show Gist options
  • Save miki2826/99b2970989d7dd22abe0d2a0777a6471 to your computer and use it in GitHub Desktop.
Save miki2826/99b2970989d7dd22abe0d2a0777a6471 to your computer and use it in GitHub Desktop.
Node command line infinite loader
'use strict';
const readline = require('readline');
const DELAY = 100;
function startLoader() {
readline.cursorTo(process.stdout, 0);
process.stdout.write('/');
setTimeout(loaderStage1, DELAY);
}
function loaderStage1() {
readline.cursorTo(process.stdout, 0);
process.stdout.write('-');
setTimeout(loaderStage2 DELAY);
}
function loaderStage2() {
readline.cursorTo(process.stdout, 0);
process.stdout.write('\\');
setTimeout(loaderStep3, DELAY);
}
function loaderStep3() {
readline.cursorTo(process.stdout, 0);
process.stdout.write('|');
setTimeout(startLoader, DELAY);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment