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 6.0.0 to 6.1.0

48

index.js

@@ -10,25 +10,9 @@ import process from 'node:process';

const getWidth = stream => {
const {columns} = stream;
const getWidth = ({columns = 80}) => columns;
if (!columns) {
return 80;
}
return columns;
};
const fitToTerminalHeight = (stream, text) => {
const terminalHeight = stream.rows ?? defaultTerminalHeight;
const lines = text.split('\n');
const toRemove = lines.length - terminalHeight;
if (toRemove <= 0) {
return text;
}
return sliceAnsi(
text,
stripAnsi(lines.slice(0, toRemove).join('\n')).length + 1,
);
const toRemove = Math.max(0, lines.length - terminalHeight);
return toRemove ? sliceAnsi(text, stripAnsi(lines.slice(0, toRemove).join('\n')).length + 1) : text;
};

@@ -41,2 +25,8 @@

const reset = () => {
previousOutput = '';
previousWidth = getWidth(stream);
previousLineCount = 0;
};
const render = (...arguments_) => {

@@ -47,5 +37,5 @@ if (!showCursor) {

let output = arguments_.join(' ') + '\n';
output = fitToTerminalHeight(stream, output);
let output = fitToTerminalHeight(stream, arguments_.join(' ') + '\n');
const width = getWidth(stream);
if (output === previousOutput && previousWidth === width) {

@@ -57,7 +47,4 @@ return;

previousWidth = width;
output = wrapAnsi(output, width, {
trim: false,
hard: true,
wordWrap: false,
});
output = wrapAnsi(output, width, {trim: false, hard: true, wordWrap: false});
stream.write(ansiEscapes.eraseLines(previousLineCount) + output);

@@ -69,12 +56,7 @@ previousLineCount = output.split('\n').length;

stream.write(ansiEscapes.eraseLines(previousLineCount));
previousOutput = '';
previousWidth = getWidth(stream);
previousLineCount = 0;
reset();
};
render.done = () => {
previousOutput = '';
previousWidth = getWidth(stream);
previousLineCount = 0;
reset();
if (!showCursor) {

@@ -81,0 +63,0 @@ cliCursor.show();

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

@@ -18,2 +18,3 @@ "license": "MIT",

},
"sideEffects": false,
"engines": {

@@ -48,5 +49,5 @@ "node": ">=18"

"dependencies": {
"ansi-escapes": "^6.2.0",
"cli-cursor": "^4.0.0",
"slice-ansi": "^7.0.0",
"ansi-escapes": "^7.0.0",
"cli-cursor": "^5.0.0",
"slice-ansi": "^7.1.0",
"strip-ansi": "^7.1.0",

@@ -56,8 +57,8 @@ "wrap-ansi": "^9.0.0"

"devDependencies": {
"@types/node": "^20.8.9",
"ava": "^5.3.1",
"@types/node": "^20.14.12",
"ava": "^6.1.3",
"terminal.js": "^1.0.11",
"tsd": "^0.29.0",
"tsd": "^0.31.1",
"wcwidth": "^1.0.1",
"xo": "^0.56.0"
"xo": "^0.59.2"
},

@@ -64,0 +65,0 @@ "xo": {

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