console-progress-bar
Advanced tools
Comparing version
10
app.js
// Import. | ||
const CColor = require('ccolor'); | ||
const cc = require('ccolor'); | ||
@@ -68,4 +68,4 @@ // Constants. | ||
// Show progress bar. | ||
const progressBarString = `${CColor.whiteBackground(this.startChars)}${addColor(filledPartsCharsString, this.percent)}${ | ||
notFilledPartCharsString}${CColor.whiteBackground(this.endChars)}`; | ||
const progressBarString = `${cc.whiteBackground(this.startChars)}${addColor(filledPartsCharsString, this.percent)}${ | ||
notFilledPartCharsString}${cc.whiteBackground(this.endChars)}`; | ||
const newLineIfLast = this.percent === MAX_PERCENT_VALUE ? '\n' : ''; | ||
@@ -125,5 +125,5 @@ process.stdout.write(`\r${progressBarString}${newLineIfLast}`); | ||
case 100: | ||
return CColor.greenBackground(progressBarString); | ||
return cc.greenBackground(progressBarString); | ||
default: | ||
return CColor.cyanBackground(progressBarString); | ||
return cc.cyanBackground(progressBarString); | ||
} | ||
@@ -130,0 +130,0 @@ } |
{ | ||
"name": "console-progress-bar", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Console progress bar", | ||
@@ -5,0 +5,0 @@ "main": "app.js", |
@@ -12,20 +12,16 @@ # console-progress-bar | ||
```sh | ||
npm install console-progress-bar --save | ||
npm install console-progress-bar | ||
``` | ||
## Initialization | ||
## Using | ||
```js | ||
// Import. | ||
const ConsoleProgressBar = require('console-progress-bar'); | ||
``` | ||
const ProgressBar = require('console-progress-bar'); | ||
## Using | ||
```js | ||
// Init. | ||
const consoleProgressBar = new ConsoleProgressBar({ maxValue: 100 }); | ||
const progressBar = new ProgressBar({ maxValue: 100 }); | ||
// Some work in loop started... | ||
consoleProgressBar.addValue(1); | ||
progressBar.addValue(1); | ||
// Loop end. | ||
@@ -38,3 +34,3 @@ ``` | ||
Copyright © 2018 - 2021 Volodymyr Sichka | ||
Copyright © 2018 - 2022 Volodymyr Sichka | ||
@@ -41,0 +37,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
// Import. | ||
const ConsoleProgressBar = require('./app'); | ||
const ProgressBar = require('./app'); | ||
// Init. | ||
const consoleProgressBar = new ConsoleProgressBar({ maxValue: 100 }); | ||
const progressBar = new ProgressBar({ maxValue: 100 }); | ||
// Append with interval. | ||
const interval = setInterval(() => { | ||
consoleProgressBar.addValue(1); | ||
if (consoleProgressBar.percent === 100) { | ||
progressBar.addValue(1); | ||
if (progressBar.percent === 100) { | ||
clearInterval(interval); | ||
} | ||
}, 10); |
6791
-1.72%43
-8.51%