Skip to content

Instantly share code, notes, and snippets.

@MNBuyskih
Last active September 22, 2015 08:02
Show Gist options
  • Save MNBuyskih/524e832e683c2e3aff24 to your computer and use it in GitHub Desktop.
Save MNBuyskih/524e832e683c2e3aff24 to your computer and use it in GitHub Desktop.
Node.js stdout and clear prev. line
var out = {
prev: '',
log: function (message) {
process.stdout((new Array(this.prev.length + 1)).join(' ') + " \r");
process.stdout(message + "\r");
this.prev = message;
}
};
@MNBuyskih
Copy link
Author

Usage:
out.log('First very very very very long message');
out.log('Short message');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment