Skip to content

Instantly share code, notes, and snippets.

@matutter
Created June 5, 2018 02:44
Show Gist options
  • Select an option

  • Save matutter/afb3b5eb00808585d9525c9c4a077a09 to your computer and use it in GitHub Desktop.

Select an option

Save matutter/afb3b5eb00808585d9525c9c4a077a09 to your computer and use it in GitHub Desktop.
NodeJs gauge example
const Gauge = require('gauge');
const themes = require('./node_modules/gauge/themes');
const $ = require('chalk');
let x = themes.themes.colorBrailleSpinner;
x.preSubsection = $.bold.blue('|');
x.preProgressbar = '';
x.postProgressbar = '';
//console.log(x)
let g = new Gauge(null, { theme: x })
function makeSequence(text, n, total) {
let calc = () => Math.floor(((total / n) + Math.random() * 100));
let elapse = 0;
let step = 0;
g.show(text, elapse / total);
let next = () => {
let change = calc();
g.pulse(`${$.red.bold(text)}`, elapse / total);
setTimeout(() => {
step++;
elapse += change;
g.show($`increasing value by {rgb(86,197,244) ${change}} to ${elapse} of ${$.green(total)}`, elapse / total);
if (elapse > total) {
g.hide()
} else next();
}, change);
}
next()
}
makeSequence('working...', 230, 3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment