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

multi-progress-bars

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multi-progress-bars - npm Package Compare versions

Comparing version 2.0.5 to 2.0.7

15

CHANGELOG.md

@@ -5,2 +5,17 @@ # Changelog

### [2.0.7](https://github.com/kamiyo/multi-progress-bars/compare/v2.0.6...v2.0.7) (2020-12-31)
### Bug Fixes
* **deps:** updated dependencies ([2039e48](https://github.com/kamiyo/multi-progress-bars/commit/2039e485d2a1a12fc3d899eeeeadad36a4c21195))
### [2.0.6](https://github.com/kamiyo/multi-progress-bars/compare/v2.0.5...v2.0.6) (2020-12-31)
### Bug Fixes
* **core:** multi line logs were getting truncated because of faulty logic. Added some comments as well. ([7758974](https://github.com/kamiyo/multi-progress-bars/commit/77589749da18ef454fe435f090a49ba0c4dae752))
* **example:** Updated example to test for multiline and long console messages. ([a7b373f](https://github.com/kamiyo/multi-progress-bars/commit/a7b373f1f6806328d362919e26f1b1a6b58e458e))
### [2.0.5](https://github.com/kamiyo/multi-progress-bars/compare/v2.0.4...v2.0.5) (2020-11-05)

@@ -7,0 +22,0 @@

18

dist/multi-progress-bars.cjs.js

@@ -103,2 +103,3 @@ 'use strict';

(_a = this.stream) === null || _a === void 0 ? void 0 : _a.write('\x1b[0m');
console = this.originalConsole;
}

@@ -118,2 +119,3 @@ init() {

upsertProgress(options) {
// If the progress we're upserting exists already, just update.
if (options.index < this.progressHeight) {

@@ -125,6 +127,7 @@ this.progressBuffer[options.index] = clampString(options.data, this.width);

}
// Truncate progress line to console width.
this.progressBuffer[options.index] = clampString(options.data, this.width);
// Extend the progress bars section, and reduce the corresponding console buffer height.
const numToExtend = 1 + options.index - this.progressHeight;
this.progressHeight = Math.max(options.index + 1, this.progressHeight);
// this.consoleHeight = this.height - this.progressHeight;
if (numToExtend > 0) {

@@ -157,2 +160,3 @@ this.consoleHeight -= numToExtend;

}
/* Prints out the buffers as they are */
refresh() {

@@ -170,2 +174,3 @@ var _a;

const writeString = util.format.apply(null, data);
// Split by newlines, and then split the resulting lines if they run longer than width.
const clampedLines = writeString.split('\n').reduce((prev, curr) => {

@@ -177,14 +182,15 @@ const clamped = [];

clamped.push(front);
} while (curr.length > this.width);
} while (curr.length > 0);
return [...prev, ...clamped];
}, []);
this.consoleBuffer.push(...clampedLines);
// If the console buffer is higher than console height, remove the top, and print them first.
const topLines = (this.consoleBuffer.length > this.consoleHeight) ?
this.consoleBuffer.splice(0, this.consoleBuffer.length - this.consoleHeight) : [];
const outString = CUP(0)
+ topLines.map((val) => val + EL(EL_MODE.TO_END)).join('\n')
+ (topLines.length ? '\n' : '')
+ this.progressBuffer.map((val) => val + EL(EL_MODE.TO_END)).join('\n')
+ topLines.map((val) => val + EL(EL_MODE.TO_END)).join('\n') // print the previously removed top lines
+ (topLines.length ? '\n' : '') // separator
+ this.progressBuffer.map((val) => val + EL(EL_MODE.TO_END)).join('\n') // progress bars
+ (this.progressBuffer.length ? '\n' : '')
+ this.consoleBuffer.map((val) => val + EL(EL_MODE.TO_END)).join('\n')
+ this.consoleBuffer.map((val) => val + EL(EL_MODE.TO_END)).join('\n') // rest of the console log.
+ '\n';

@@ -191,0 +197,0 @@ (_a = this.stream) === null || _a === void 0 ? void 0 : _a.write(outString);

@@ -95,2 +95,3 @@ import { green } from 'chalk';

(_a = this.stream) === null || _a === void 0 ? void 0 : _a.write('\x1b[0m');
console = this.originalConsole;
}

@@ -110,2 +111,3 @@ init() {

upsertProgress(options) {
// If the progress we're upserting exists already, just update.
if (options.index < this.progressHeight) {

@@ -117,6 +119,7 @@ this.progressBuffer[options.index] = clampString(options.data, this.width);

}
// Truncate progress line to console width.
this.progressBuffer[options.index] = clampString(options.data, this.width);
// Extend the progress bars section, and reduce the corresponding console buffer height.
const numToExtend = 1 + options.index - this.progressHeight;
this.progressHeight = Math.max(options.index + 1, this.progressHeight);
// this.consoleHeight = this.height - this.progressHeight;
if (numToExtend > 0) {

@@ -149,2 +152,3 @@ this.consoleHeight -= numToExtend;

}
/* Prints out the buffers as they are */
refresh() {

@@ -162,2 +166,3 @@ var _a;

const writeString = format.apply(null, data);
// Split by newlines, and then split the resulting lines if they run longer than width.
const clampedLines = writeString.split('\n').reduce((prev, curr) => {

@@ -169,14 +174,15 @@ const clamped = [];

clamped.push(front);
} while (curr.length > this.width);
} while (curr.length > 0);
return [...prev, ...clamped];
}, []);
this.consoleBuffer.push(...clampedLines);
// If the console buffer is higher than console height, remove the top, and print them first.
const topLines = (this.consoleBuffer.length > this.consoleHeight) ?
this.consoleBuffer.splice(0, this.consoleBuffer.length - this.consoleHeight) : [];
const outString = CUP(0)
+ topLines.map((val) => val + EL(EL_MODE.TO_END)).join('\n')
+ (topLines.length ? '\n' : '')
+ this.progressBuffer.map((val) => val + EL(EL_MODE.TO_END)).join('\n')
+ topLines.map((val) => val + EL(EL_MODE.TO_END)).join('\n') // print the previously removed top lines
+ (topLines.length ? '\n' : '') // separator
+ this.progressBuffer.map((val) => val + EL(EL_MODE.TO_END)).join('\n') // progress bars
+ (this.progressBuffer.length ? '\n' : '')
+ this.consoleBuffer.map((val) => val + EL(EL_MODE.TO_END)).join('\n')
+ this.consoleBuffer.map((val) => val + EL(EL_MODE.TO_END)).join('\n') // rest of the console log.
+ '\n';

@@ -183,0 +189,0 @@ (_a = this.stream) === null || _a === void 0 ? void 0 : _a.write(outString);

{
"name": "multi-progress-bars",
"version": "2.0.5",
"version": "2.0.7",
"description": "Multiple progress bars with option for indefinite spinners",

@@ -36,10 +36,10 @@ "main": "dist/multi-progress-bars.cjs.js",

"devDependencies": {
"@types/node": "12",
"@wessberg/rollup-plugin-ts": "^1.3.7",
"rollup": "^2.33.1",
"@types/node": "^12.19.0",
"@wessberg/rollup-plugin-ts": "^1.3.8",
"rollup": "^2.35.1",
"rollup-plugin-typescript2": "^0.29.0",
"standard-version": "^9.0.0",
"trash-cli": "^3.1.0",
"standard-version": "^9.1.0",
"trash-cli": "^4.0.0",
"tslib": "^2.0.3",
"typescript": "^4.0.5"
"typescript": "^4.1.3"
},

@@ -46,0 +46,0 @@ "dependencies": {

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