Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

log-update

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

log-update - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

20

index.js
'use strict';
var ansiEscapes = require('ansi-escapes');
var cliCursor = require('cli-cursor');
const ansiEscapes = require('ansi-escapes');
const cliCursor = require('cli-cursor');
const wrapAnsi = require('wrap-ansi');
function main(stream) {
var prevLineCount = 0;
const main = stream => {
let prevLineCount = 0;
var render = function () {
const render = function () {
cliCursor.hide();
var out = [].join.call(arguments, ' ') + '\n';
let out = [].join.call(arguments, ' ') + '\n';
out = wrapAnsi(out, process.stdout.columns || 80, {wordWrap: false});
stream.write(ansiEscapes.eraseLines(prevLineCount) + out);

@@ -15,3 +17,3 @@ prevLineCount = out.split('\n').length;

render.clear = function () {
render.clear = () => {
stream.write(ansiEscapes.eraseLines(prevLineCount));

@@ -21,3 +23,3 @@ prevLineCount = 0;

render.done = function () {
render.done = () => {
prevLineCount = 0;

@@ -28,3 +30,3 @@ cliCursor.show();

return render;
}
};

@@ -31,0 +33,0 @@ module.exports = main(process.stdout);

{
"name": "log-update",
"version": "1.0.2",
"version": "2.0.0",
"description": "Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc.",

@@ -13,6 +13,6 @@ "license": "MIT",

"engines": {
"node": ">=0.10.0"
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
"test": "xo && node test.js"
},

@@ -42,8 +42,8 @@ "files": [

"ansi-escapes": "^1.0.0",
"cli-cursor": "^1.0.2"
"cli-cursor": "^2.0.0",
"wrap-ansi": "^2.1.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
}
# log-update [![Build Status](https://travis-ci.org/sindresorhus/log-update.svg?branch=master)](https://travis-ci.org/sindresorhus/log-update)
> Log by overwriting the previous output in the terminal.
> Log by overwriting the previous output in the terminal.<br>
> Useful for rendering progress bars, animations, etc.

@@ -19,11 +19,17 @@

```js
var logUpdate = require('log-update');
const logUpdate = require('log-update');
const frames = ['-', '\\', '|', '/'];
let i = 0;
var i = 0;
var frames = ['-', '\\', '|', '/'];
setInterval(() => {
const frame = frames[i = ++i % frames.length];
setInterval(function () {
var frame = frames[i++ % frames.length];
logUpdate('\n' + ' ♥♥\n ' + frame + ' unicorns ' + frame + '\n ♥♥');
}, 100);
logUpdate(
`
♥♥
${frame} unicorns ${frame}
♥♥
`
);
}, 80);
```

@@ -44,3 +50,3 @@

Persist the logged output.
Persist the logged output.<br>
Useful if you want to start a new log session below the current one.

@@ -62,3 +68,5 @@

- [speed-test](https://github.com/sindresorhus/speed-test) - Uses this module to render a spinner
- [listr](https://github.com/SamVerschueren/listr) - Uses this module to render an interactive task list
- [ora](https://github.com/sindresorhus/ora) - Uses this module to render awesome spinners
- [speed-test](https://github.com/sindresorhus/speed-test) - Uses this module to render a [spinner](https://github.com/sindresorhus/elegant-spinner)

@@ -68,2 +76,2 @@

MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc