Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/freeall/single-line-log
Output one line and move to beginning of line. Useful for progress bars and counters with no breaks in the terminal
https://github.com/freeall/single-line-log
Last synced: 6 days ago
JSON representation
Output one line and move to beginning of line. Useful for progress bars and counters with no breaks in the terminal
- Host: GitHub
- URL: https://github.com/freeall/single-line-log
- Owner: freeall
- License: mit
- Created: 2013-09-11T18:55:55.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-08-05T09:53:53.000Z (over 2 years ago)
- Last Synced: 2025-01-15T21:08:03.778Z (13 days ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 210
- Watchers: 3
- Forks: 26
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cli - single-line-log - Keep writing to the same line in the terminal. (Animation)
README
# single-line-log
Node.js module that keeps writing to the same line in the console (or a stream). Very useful when you write progress bars, or a status message during longer operations. Supports multilines.
## Installation
npm install single-line-log
## Usage
``` js
var log = require('single-line-log').stdout;
// or pass any stream:
// var log = require('single-line-log')(process.stdout);var read = 0;
var size = fs.statSync('super-large-file').size;var rs = fs.createReadStream('super-large-file');
rs.on('data', function(data) {
read += data.length;
var percentage = Math.floor(100*read/size);// Keep writing to the same two lines in the console
log('Writing to super large file\n[' + percentage + '%]', read, 'bytes read');
});
```## .clear()
Clears the log (i.e., writes a newline).
``` js
var log = require('single-line-log').stdout;log('Line 1');
log.clear();
log('Line 2');
```## .stdout
Outputs to `process.stdout`.
## .stderr
Outputs to `process.stderr`.
## License
MIT