single-line-log
Keep writing to the same line in the terminal. Very useful when you write progress bars, or a status message during longer operations
Last updated 8 years ago by freeall .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install single-line-log 
SYNC missed versions from official npm registry.

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

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).

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

Current Tags

  • 1.1.2                                ...           latest (8 years ago)

13 Versions

  • 1.1.2                                ...           8 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
  • 0.4.1                                ...           10 years ago
  • 0.4.0                                ...           10 years ago
  • 0.3.1                                ...           11 years ago
  • 0.3.0                                ...           11 years ago
  • 0.2.0                                ...           11 years ago
  • 0.1.2                                ...           11 years ago
  • 0.1.1                                ...           11 years ago
  • 0.1.0                                ...           11 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |