A simple spinner for node cli
JavaScript
Latest commit 96105f7 Feb 4, 2017 Pasquale Boemio 0.2.6
Permalink
Failed to load latest commit information.
example cleaning stuff Feb 4, 2017
img add example gif Dec 24, 2015
LICENSE Initial commit Nov 13, 2013
README.md update documentation format -- again. Jun 7, 2016
index.js cleaning stuff Feb 4, 2017
package.json 0.2.6 Feb 4, 2017
spinners.json Move spinners to JSON file Mar 27, 2016

README.md

node-spinner

A simple spinner for node cli.

NPM NPM


Installation

This package is available on npm as cli-spinner.

npm install cli-spinner

Example usage

var Spinner = require('cli-spinner').Spinner;

var spinner = new Spinner('processing.. %s');
spinner.setSpinnerString('|/-\\');
spinner.start();

API

var obj = new Spinner('processing.. %s')

var obj = new Spinner({
    text: 'processing.. %s',
    stream: process.stderr,
    onTick: function(msg){
        this.clearLine(this.stream);
        this.stream.write(msg);
    }
})

Create a new spinner object. The advanced options can be used in any combination, none of them are required.

obj.start()

Starts the spinner.

obj.stop(clean)

Stops the spinner. Accepts a Boolean parameter to clean the console.

obj.setSpinnerString(spinnerString)

Sets the spinner string. Accepts either a String or an Integer index to reference the built-in spinners.

obj.setSpinnerDelay(spinnerDelay)

Sets the spinner animation speed.

Spinner.setDefaultSpinnerString(spinnerString)

Sets the default spinner string for all newly created instances. Accepts either a String or an Integer index to reference the built-in spinners.

Spinner.setDefaultSpinnerDelay(spinnerDelay)

Sets the default spinner delay for all newly created instances.

Spinner.setSpinnerTitle(spinnerTitle)

Sets the spinner title. Use printf-style strings to position the spinner.

Spinner.isSpinning()

Returns true/false depending on whether the spinner is currently spinning.

##Demo

To see a demonstration of the built-in spinners, point your console at the example folder and run:

node spinner.js

preview