Created
September 11, 2014 22:24
-
-
Save jclulow/53d5bc4eef0d29ae2691 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env node | |
var ESC = '\u001b'; | |
var CSI = ESC + '['; | |
var L0 = [' ', ' # ', ' # ', ' #']; | |
var L1 = [' ', ' # ', ' # ', ' # ']; | |
var L2 = [' ', ' # ', ' # ', ' # ']; | |
var L3 = [' ###### ', ' # ', ' # ', ' # ']; | |
var L4 = [' ', ' # ', ' # ', ' # ']; | |
var L5 = [' ', ' # ', ' # ', ' # ']; | |
var L6 = [' ', ' #', ' # ', ' # ']; | |
var L = [ L0, L1, L2, L3, L4, L5, L6 ]; | |
function | |
w(s) | |
{ | |
process.stdout.write(s); | |
} | |
function | |
wl(n) | |
{ | |
for (var i = 0; i < L.length; i++) { | |
w(L[i][n] + '\n'); | |
} | |
} | |
var FIRST = true; | |
var ITER = 0; | |
setInterval(function () { | |
if (!FIRST) { | |
/* | |
* Rewind to the top line of the spinner region. | |
*/ | |
w(CSI + (L.length) + 'A'); | |
w(CSI + '1G'); | |
} else { | |
FIRST = false; | |
} | |
wl(ITER++ % L[0].length); | |
}, 250); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment