single-line-log

1.1.2last stable release 8 years ago
Complexity Score
Low
Open Issues
7
Dependent Projects
275
Weekly Downloadsglobal
102,565

License

  • MIT
    • Yesattribution
    • Permissivelinking
    • Permissivedistribution
    • Permissivemodification
    • Nopatent grant
    • Yesprivate use
    • Permissivesublicensing
    • Notrademark grant

Downloads

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

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

Dependencies

CVE IssuesActive
0
Scorecards Score
3.30
Test Coverage
No Data
Follows Semver
Yes
Github Stars
209
Dependenciestotal
1
DependenciesOutdated
1
DependenciesDeprecated
0
Threat Modelling
No
Repo Audits
No

Learn how to distribute single-line-log in your own private NPM registry

npm config set registry  https://npm.cloudsmith.com/owner/repo
Processing...
Done
npm install single-line-log
Processing...
Done

13 Releases

NPM on Cloudsmith

Getting started with NPM on Cloudsmith is fast and easy.