Skip to content

Instantly share code, notes, and snippets.

@jclulow
Created September 11, 2014 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jclulow/53d5bc4eef0d29ae2691 to your computer and use it in GitHub Desktop.
Save jclulow/53d5bc4eef0d29ae2691 to your computer and use it in GitHub Desktop.
#!/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