Created
January 16, 2017 14:55
-
-
Save PanayotCankov/64f55d2e643ec1bf2369a1127f594234 to your computer and use it in GitHub Desktop.
Nice undetermined activity indicator and a progress bar for the terminal
This file contains 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
var chars = "○○◐●◕◑◔"; | |
var progress_chars = " ▏▎▍▌▋▊▉█"; | |
var p = 0; | |
var progLen = 8; | |
function progress() { | |
p = 1 + (p % (8 * progLen)); | |
var r = ""; | |
for (var i = 0; i < progLen; i++) { | |
r += progress_chars[Math.max(0, Math.min(8, p - i * 8))]; | |
} | |
return r + "▏"; | |
} | |
console.log(" ✔ less"); | |
console.log(" ✘ sass"); | |
var i = 0; | |
setInterval(() => { | |
process.stdout.write("\r " + chars[i = (i + 1) % chars.length] + " " + progress() + "tsc "); | |
}, 175); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment