Last active
January 18, 2017 14:31
-
-
Save miki2826/99b2970989d7dd22abe0d2a0777a6471 to your computer and use it in GitHub Desktop.
Node command line infinite loader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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