New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

single-line-log2

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

single-line-log2

Keep writing to the same line in the terminal. Very useful when you write progress bars, or a status message during longer operations

latest
Source
npmnpm
Version
1.1.3
Version published
Maintainers
1
Created
Source

single-line-log2

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.

This patches single-line-log for columns missing and adds line feed normalization.

Installation

npm install single-line-log2

Usage

var log = require('single-line-log2').stdout;
// or pass any stream:
// var log = require('single-line-log2')(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-log2').stdout;

log('Line 1');
log.clear();
log('Line 2');

.stdout

Outputs to process.stdout.

.stderr

Outputs to process.stderr.

License

MIT

Keywords

single

FAQs

Package last updated on 13 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts