Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function logProgress(str) {
// A little bit of readline magic to not fill the screen with progress messages.
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0, null);
process.stdout.write(str);
}
function onProgress(value: number) {
value = Math.round(value * 100);
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0, 1);
console.log(`${value}%`);
if (process != null && process.send != null) process.send({ type: "progress", value });
}
function printMessage({
from = null,
me = null,
to = null,
text = "",
timestamp = new Date()
} = {}) {
const message = formatter(from, me, to, text, timestamp);
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0);
process.stdout.write(message);
rl.prompt(true);
}
progress(message) {
this._currentProgressMessage = message;
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0);
if (message) process.stdout.write(`${this._nextLoadingChar()} ${message}`);
}
function clear () {
readline.clearLine(writeStream);
readline.cursorTo(writeStream, 0);
}