var MOVE_LEFT = new Buffer('1b5b3130303044', 'hex').toString(); var MOVE_UP = new Buffer('1b5b3141', 'hex').toString(); var CLEAR_LINE = new Buffer('1b5b304b', 'hex').toString(); var stringWidth = require('string-width'); module.exports = function(stream) { var write = stream.write; var str; stream.write = function(data) { if (str && data !== str) str = null; return write.apply(this, arguments); }; if (stream === process.stderr || stream === process.stdout) { process.on('exit', function() { if (str !== null) stream.write(''); }); } var prevLineCount = 0; var log = function() { str = ''; var nextStr = Array.prototype.join.call(arguments, ' '); // Clear screen for (var i=0; i