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

log-update

Package Overview
Dependencies
Maintainers
1
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 4.0.0 to 5.0.0

152

index.d.ts

@@ -1,80 +0,104 @@

/// <reference types="node"/>
export interface Options {
/**
Show the cursor. This can be useful when a CLI accepts input from a user.
declare namespace logUpdate {
interface LogUpdate {
/**
Log to `stdout` by overwriting the previous output in the terminal.
@example
```
import {createLogUpdate} from 'log-update';
@param text - The text to log to `stdout`.
// Write output but don't hide the cursor
const log = createLogUpdate(process.stdout, {
showCursor: true
});
```
*/
readonly showCursor?: boolean;
}
@example
```
import logUpdate = require('log-update');
type LogUpdateMethods = {
/**
Clear the logged output.
*/
clear(): void;
const frames = ['-', '\\', '|', '/'];
let i = 0;
/**
Persist the logged output. Useful if you want to start a new log session below the current one.
*/
done(): void;
};
setInterval(() => {
const frame = frames[i = ++i % frames.length];
/**
Log to `stdout` by overwriting the previous output in the terminal.
logUpdate(
`
♥♥
${frame} unicorns ${frame}
♥♥
`
);
}, 80);
```
*/
(...text: string[]): void;
@param text - The text to log to `stdout`.
/**
Clear the logged output.
*/
clear(): void;
@example
```
import logUpdate from 'log-update';
/**
Persist the logged output. Useful if you want to start a new log session below the current one.
*/
done(): void;
}
const frames = ['-', '\\', '|', '/'];
let index = 0;
interface Options {
/**
Show the cursor. This can be useful when a CLI accepts input from a user.
setInterval(() => {
const frame = frames[index = ++index % frames.length];
@example
```
import logUpdate = require('log-update');
logUpdate(
`
♥♥
${frame} unicorns ${frame}
♥♥
`
);
}, 80);
```
*/
declare const logUpdate: ((...text: string[]) => void) & LogUpdateMethods;
// Write output but don't hide the cursor
const log = logUpdate.create(process.stdout, {
showCursor: true
});
```
*/
readonly showCursor?: boolean;
}
}
export default logUpdate;
declare const logUpdate: logUpdate.LogUpdate & {
/**
Log to `stderr` by overwriting the previous output in the terminal.
/**
Log to `stderr` by overwriting the previous output in the terminal.
@param text - The text to log to `stderr`.
*/
readonly stderr: logUpdate.LogUpdate;
@param text - The text to log to `stderr`.
/**
Get a `logUpdate` method that logs to the specified stream.
@example
```
import {logUpdateStderr} from 'log-update';
@param stream - The stream to log to.
*/
readonly create: (
stream: NodeJS.WritableStream,
options?: logUpdate.Options
) => logUpdate.LogUpdate;
};
const frames = ['-', '\\', '|', '/'];
let index = 0;
export = logUpdate;
setInterval(() => {
const frame = frames[index = ++index % frames.length];
logUpdateStderr(
`
♥♥
${frame} unicorns ${frame}
♥♥
`
);
}, 80);
```
*/
declare const logUpdateStderr: ((...text: string[]) => void) & LogUpdateMethods;
export {logUpdateStderr};
/**
Get a `logUpdate` method that logs to the specified stream.
@param stream - The stream to log to.
@example
```
import {createLogUpdate} from 'log-update';
// Write output but don't hide the cursor
const log = createLogUpdate(process.stdout);
```
*/
export function createLogUpdate(
stream: NodeJS.WritableStream,
options?: Options
): typeof logUpdate;

@@ -1,6 +0,6 @@

'use strict';
const ansiEscapes = require('ansi-escapes');
const cliCursor = require('cli-cursor');
const wrapAnsi = require('wrap-ansi');
const sliceAnsi = require('slice-ansi');
import process from 'node:process';
import ansiEscapes from 'ansi-escapes';
import cliCursor from 'cli-cursor';
import wrapAnsi from 'wrap-ansi';
import sliceAnsi from 'slice-ansi';

@@ -34,3 +34,3 @@ const defaultTerminalHeight = 24;

const main = (stream, {showCursor = false} = {}) => {
export function createLogUpdate(stream, {showCursor = false} = {}) {
let previousLineCount = 0;

@@ -40,3 +40,3 @@ let previousWidth = getWidth(stream);

const render = (...args) => {
const render = (...arguments_) => {
if (!showCursor) {

@@ -46,3 +46,3 @@ cliCursor.hide();

let output = args.join(' ') + '\n';
let output = arguments_.join(' ') + '\n';
output = fitToTerminalHeight(stream, output);

@@ -59,3 +59,3 @@ const width = getWidth(stream);

hard: true,
wordWrap: false
wordWrap: false,
});

@@ -84,6 +84,7 @@ stream.write(ansiEscapes.eraseLines(previousLineCount) + output);

return render;
};
}
module.exports = main(process.stdout);
module.exports.stderr = main(process.stderr);
module.exports.create = main;
const logUpdate = createLogUpdate(process.stdout);
export default logUpdate;
export const logUpdateStderr = createLogUpdate(process.stderr);
{
"name": "log-update",
"version": "4.0.0",
"version": "5.0.0",
"description": "Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc.",

@@ -11,6 +11,8 @@ "license": "MIT",

"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=10"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},

@@ -43,14 +45,14 @@ "scripts": {

"dependencies": {
"ansi-escapes": "^4.3.0",
"cli-cursor": "^3.1.0",
"slice-ansi": "^4.0.0",
"wrap-ansi": "^6.2.0"
"ansi-escapes": "^5.0.0",
"cli-cursor": "^4.0.0",
"slice-ansi": "^5.0.0",
"wrap-ansi": "^8.0.1"
},
"devDependencies": {
"@types/node": "^13.7.4",
"ava": "^3.3.0",
"terminal.js": "^1.0.10",
"tsd": "^0.11.0",
"xo": "^0.26.1"
"@types/node": "^16.11.1",
"ava": "^3.15.0",
"terminal.js": "^1.0.11",
"tsd": "^0.18.0",
"xo": "^0.45.0"
}
}

@@ -1,4 +0,4 @@

# log-update [![Build Status](https://travis-ci.org/sindresorhus/log-update.svg?branch=master)](https://travis-ci.org/sindresorhus/log-update)
# log-update
> Log by overwriting the previous output in the terminal.<br>
> Log by overwriting the previous output in the terminal.\
> Useful for rendering progress bars, animations, etc.

@@ -10,5 +10,5 @@

```sh
npm install log-update
```
$ npm install log-update
```

@@ -18,9 +18,9 @@ ## Usage

```js
const logUpdate = require('log-update');
import logUpdate from 'log-update';
const frames = ['-', '\\', '|', '/'];
let i = 0;
let index = 0;
setInterval(() => {
const frame = frames[i = ++i % frames.length];
const frame = frames[index = ++index % frames.length];

@@ -49,13 +49,14 @@ logUpdate(

Persist the logged output.<br>
Persist the logged output.
Useful if you want to start a new log session below the current one.
### logUpdate.stderr(text…)
### logUpdateStderr(text…)
Log to stderr.
### logUpdate.stderr.clear()
### logUpdate.stderr.done()
### logUpdateStderr.clear()
### logUpdateStderr.done()
### logUpdate.create(stream, options?)
### createLogUpdate(stream, options?)

@@ -76,3 +77,3 @@ Get a `logUpdate` method that logs to the specified stream.

```js
const logUpdate = require('log-update');
import logUpdate from 'log-update';

@@ -79,0 +80,0 @@ // Write output but don't hide the cursor

Sorry, the diff of this file is not supported yet

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