Comparing version 0.3.3 to 0.3.4
## Version History [![Changelog Status](https://changelogs.md/img/changelog-check-green.svg)](https://changelogs.md/github/nathanpeck/clui/) | ||
### [0.3.4] - 2017-6-15 | ||
Added new clear() function to CLI. Used to cleanly clear the screen and reduce flickering. Progress and Gauge bars will also show the correct length when value/currentValue is <= 0. Updated examples to include new clear() function. Spinner will clear the line after each draw loop so that shorter update messages will render correctly. | ||
### [0.3.3] - 2017-6-13 | ||
Updated incorrect method signature from 'update' to 'message' in the Spinner example. | ||
### [0.3.2] - 2017-6-12 | ||
Updated README.md with some missing/incorrect dependency references for cli-color and clui. Updated incorrect method signature from 'update' to 'message' in the Spinner example. | ||
Updated README.md with some missing/incorrect dependency references for cli-color and clui. | ||
@@ -7,0 +15,0 @@ ### [0.3.1] - 2014-10-08 |
var CLI = require('../lib/clui.js'), | ||
clear = CLI.Clear, | ||
clc = require('cli-color'); | ||
@@ -10,3 +11,3 @@ | ||
function draw() { | ||
console.log(clc.reset); | ||
clear() | ||
@@ -67,2 +68,2 @@ var xLocation = Math.floor(process.stdout.columns / 2) - 35; | ||
draw(); | ||
}); | ||
}); |
var CLI = require('../lib/clui.js'), | ||
clear = CLI.Clear, | ||
clc = require('cli-color'), | ||
@@ -14,3 +15,3 @@ os = require('os'); | ||
function draw() { | ||
console.log(clc.reset); | ||
clear() | ||
@@ -81,2 +82,2 @@ var blankLine = new Line().fill().output(); | ||
draw(); | ||
}); | ||
}); |
var CLI = require('../lib/clui.js'), | ||
clear = CLI.Clear, | ||
clc = require('cli-color'); | ||
@@ -13,3 +14,4 @@ | ||
function drawProgress () { | ||
process.stdout.write('\x1b[9A'); | ||
clear() | ||
var blankLine = new Line().fill().output(); | ||
@@ -48,2 +50,1 @@ | ||
}, 500); | ||
var CLI = require('../lib/clui.js'), | ||
clc = require('cli-color'); | ||
var Line = CLI.Line; | ||
var Line = CLI.Line; | ||
@@ -30,2 +30,2 @@ var blankLine = new Line().fill().output(); | ||
blankLine.output(); | ||
blankLine.output(); |
@@ -17,2 +17,2 @@ var CLI = require('../lib/clui.js'), | ||
} | ||
}, 1000); | ||
}, 1000); |
@@ -39,2 +39,3 @@ var clc = require('cli-color'), | ||
var str = arr[i++ % len]; | ||
process.stdout.clearLine(); | ||
process.stdout.write('\u001b[0G' + str + '\u001b[90m' + spinnerMessage + '\u001b[0m'); | ||
@@ -65,19 +66,16 @@ }; | ||
Gauge: function (value, maxValue, width, dangerZone, suffix) { | ||
if(maxValue === 0) | ||
{ | ||
if (maxValue === 0) { | ||
return '[]'; | ||
} | ||
else | ||
{ | ||
var barLength = Math.ceil(value/maxValue*width); | ||
if(barLength > width) | ||
} else { | ||
var barLength = value ? Math.ceil(value / maxValue * width) : 1; | ||
if (barLength > width) | ||
barLength = width; | ||
var barColor = clc.green; | ||
if(value > dangerZone) | ||
if (value > dangerZone) | ||
barColor = clc.red; | ||
return '['+ | ||
barColor(Array(barLength).join("|")) + //The filled portion | ||
Array(width+1-barLength).join("-") + //The empty portion | ||
barColor(Array(barLength).join("|")) + // The filled portion | ||
Array(width + 1 - barLength).join("-") + // The empty portion | ||
'] ' + clc.blackBright(suffix); | ||
@@ -100,3 +98,3 @@ } | ||
{ | ||
var barLength = Math.ceil(currentValue / maxValue * width); | ||
var barLength = currentValue ? Math.ceil(currentValue / maxValue * width) : 1; | ||
if(barLength > width) | ||
@@ -333,3 +331,3 @@ barLength = width; | ||
}; | ||
// Return the contents | ||
@@ -339,2 +337,14 @@ this.contents = function () { | ||
}; | ||
}, | ||
// Effectively clear a screen. | ||
// Code based on code from Clear by bahamas10/node-clear | ||
// https://github.com/bahamas10/node-clear | ||
Clear: function(clear) { | ||
if (clear !== false) { | ||
// Ansi code for clearing screen | ||
process.stdout.write('\033[2J'); | ||
} | ||
// if false, don't clear screen, rather move cursor to top left | ||
process.stdout.write('\033[0;0f'); | ||
} | ||
@@ -341,0 +351,0 @@ }; |
{ | ||
"name": "clui", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "A Node.js toolkit for drawing nice command line tables, gauges, spinners, and sparklines.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/clui", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
73902
491
0