Last active
September 22, 2015 08:02
-
-
Save MNBuyskih/524e832e683c2e3aff24 to your computer and use it in GitHub Desktop.
Node.js stdout and clear prev. line
This file contains 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 out = { | |
prev: '', | |
log: function (message) { | |
process.stdout((new Array(this.prev.length + 1)).join(' ') + " \r"); | |
process.stdout(message + "\r"); | |
this.prev = message; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
out.log('First very very very very long message');
out.log('Short message');