Skip to content

Instantly share code, notes, and snippets.

@wlaurance
Last active December 19, 2015 15:59
Show Gist options
  • Select an option

  • Save wlaurance/5980479 to your computer and use it in GitHub Desktop.

Select an option

Save wlaurance/5980479 to your computer and use it in GitHub Desktop.
simple charm progress bar
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