Last active
October 10, 2015 02:24
-
-
Save designfrontier/3e6a4e1b24e699a730c8 to your computer and use it in GitHub Desktop.
node console spinner (rough)
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
var arr = [ | |
'\\', | |
'|', | |
'/', | |
'-', | |
] | |
, position = 0; | |
arr = arr.concat(arr, arr, arr, arr, arr, arr); | |
var spinerval = setInterval(function () { | |
var spin = arr[position]; | |
if(position > 0) { | |
spin = '\b' + spin; | |
} | |
process.stdout.write(spin); | |
position++; | |
if (position === arr.length) { | |
clearInterval(spinerval); | |
process.stdout.write('\b' + ''); | |
} | |
}, 50); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can I play too?