1. 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
single-line-log
Package: single-line-log
Created by: freeall
Last modified: Wed, 12 Apr 2023 02:46:38 GMT
Version: 1.1.2
License: MIT
Downloads: 579,479
Repository: https://github.com/freeall/single-line-log

Install

npm install single-line-log
yarn add single-line-log

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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code