Nyan cat progress bar in Node, why not?
A nyan cat progress bar for Node.
yarn add nyan-progress
or if you use npm instead,
npm install --save nyan-progress
import nyanProgress from 'nyan-progress';
// OR
// const nyanProgress = require('nyan-progress);
const progress = nyanProgress(); // initialize
progress.start({ total: 100 }); // start the progress
const timer = setInterval(() => {
progress.tick();
if (progress.isComplete) {
clearInterval(timer);
}
}, 100);
The above example will produce the result shown in the gif in the begining.
The start()
function can pass in an option object, the available options are listed below.
0
.100
.20
.500
.['Nyaning. ', 'Nyaning.. ', 'Nyaning...']
.'Nyaned'
.'Something nyan wrong...'
.You can also pass the callback function as second argument of the start()
function.
progress.start({}, callback);
The start()
function also return a promise.
progress.start().then(callback);
start(options, callback?)
The function to nyan the cat.
tick(value? = 1)
The function that increment curr
by value
, value
is default to 1 if not specified. When curr
reached to total
, the progress will stop.
interupt()
For whatever reason you want to interupt the nyaning, call it. Note that it would not throw any error but display error message in the progress itself.
MIT