loading-spinner
v1.2.1
Published
Loading spinner for NodeJS.
Downloads
17,291
Maintainers
Readme
loading-spinner
Loading spinner for NodeJS.
Installation
npm install --save loading-spinner
Usage
var loadingSpinner = require('loading-spinner');
// Start the loading spinner
loadingSpinner.start(
[Integer, default: 100], // Interval (in ms) between each spinner sequence element
{
clearChar: [Boolean, default: false], // Clear the spinner when stop() is called
clearLine: [Boolean, default: false], // Clear the entire line when stop() is called
doNotBlock: [Boolean, default: false], // Does not prevent the process from exiting
hideCursor: [Boolean, default: false] // Hide the cursor until stop() is called
}
);
// Stop the loading spinner
loadingSpinner.stop();
// Customize the spinner sequence
loadingSpinner.setSequence(
[Array, default: ['|','/','-','\\']], // Sequence of spinner elements
);
Example
var loadingSpinner = require('loading-spinner');
var dary = function() {
loadingSpinner.stop();
process.stdout.write('DA-RY !');
};
var legend = function() {
process.stdout.write('It\'s gonna be LE-GEN... Wait for it... ');
loadingSpinner.start(100, {
clearChar: true
});
setTimeout(dary, 1000);
};
legend();