terminal-overwrite
v2.0.1
Published
Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc.
Downloads
20,345
Maintainers
Readme
terminal-overwrite
Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc. Forked from log-update
Install
$ npm install --save terminal-overwrite
Usage
const terminalOverwrite = require('terminal-overwrite');
const frames = ['-', '\\', '|', '/'];
let i = 0;
setInterval(() => {
const frame = frames[i = ++i % frames.length];
terminalOverwrite(
`
♥♥
${frame} unicorns ${frame}
♥♥
`
);
}, 80);
API
terminalOverwrite(text, ...)
Log to stdout.
terminalOverwrite.clear()
Clear the logged output.
terminalOverwrite.done()
Persist the logged output. Useful if you want to start a new log session below the current one.
terminalOverwrite.stderr(text, ...)
Log to stderr.
terminalOverwrite.stderr.clear()
terminalOverwrite.stderr.done()
terminalOverwrite.create(stream)
Get a terminalOverwrite
method that logs to the specified stream.
License
- MIT © Dyson Woo
- MIT © Sindre Sorhus