Last active
December 19, 2015 15:59
-
-
Save wlaurance/5980479 to your computer and use it in GitHub Desktop.
simple charm progress bar
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 charm = require('charm')(); | |
| charm.pipe(process.stdout); | |
| charm.write('\n'); | |
| charm.cursor(false); | |
| var start = 0, | |
| end = 100, | |
| prev = ""; | |
| function progress(){ | |
| charm.left(prev.length); | |
| prev = start++ + '/' + end; | |
| charm.write(prev); | |
| if (start <= end) { | |
| setTimeout(progress, 20); | |
| } else { | |
| charm.write('\n'); | |
| charm.cursor(true); | |
| } | |
| } | |
| progress(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment