mirror of https://github.com/lukechilds/docs.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.2 KiB
66 lines
1.2 KiB
6 years ago
|
# log-update [](https://travis-ci.org/sindresorhus/log-update)
|
||
|
|
||
|
> Log by overwriting the previous output in the terminal.
|
||
|
> Useful for rendering progress bars, animations, etc.
|
||
|
|
||
|

|
||
|
|
||
|
|
||
|
## Install
|
||
|
|
||
|
```
|
||
|
$ npm install --save log-update
|
||
|
```
|
||
|
|
||
|
|
||
|
## Usage
|
||
|
|
||
|
```js
|
||
|
var logUpdate = require('log-update');
|
||
|
|
||
|
var i = 0;
|
||
|
var frames = ['-', '\\', '|', '/'];
|
||
|
|
||
|
setInterval(function () {
|
||
|
var frame = frames[i++ % frames.length];
|
||
|
logUpdate('\n' + ' ♥♥\n ' + frame + ' unicorns ' + frame + '\n ♥♥');
|
||
|
}, 100);
|
||
|
```
|
||
|
|
||
|
|
||
|
## API
|
||
|
|
||
|
### logUpdate(text, ...)
|
||
|
|
||
|
Log to stdout.
|
||
|
|
||
|
### logUpdate.clear()
|
||
|
|
||
|
Clear the logged output.
|
||
|
|
||
|
### logUpdate.done()
|
||
|
|
||
|
Persist the logged output.
|
||
|
Useful if you want to start a new log session below the current one.
|
||
|
|
||
|
### logUpdate.stderr(text, ...)
|
||
|
|
||
|
Log to stderr.
|
||
|
|
||
|
### logUpdate.stderr.clear()
|
||
|
### logUpdate.stderr.done()
|
||
|
|
||
|
### logUpdate.create(stream)
|
||
|
|
||
|
Get a `logUpdate` method that logs to the specified stream.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
|
||
|
- [speed-test](https://github.com/sindresorhus/speed-test) - Uses this module to render a spinner
|
||
|
|
||
|
|
||
|
## License
|
||
|
|
||
|
MIT © [Sindre Sorhus](http://sindresorhus.com)
|