JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 72540
  • Score
    100M100P100Q150021F
  • License MIT

Create and manage multiple spinners in command-line interface programs

Package Exports

  • spinnies

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (spinnies) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

spin Spinnies spin

Node.js module to create and manage multiple spinners in command-line interface programs

CircleCI standard-readme compliant License: MIT


Installation

$ npm i spinnies

Usage & Example

const spinnies = new Spinnies();

spinnies.add('spinner-1', { text: 'I am a spinner' });
spinnies.add('spinner-2', { text: 'I am another spinner' });

setTimeout(() => {
  spinnies.succeed('spinner-1', { text: 'Success!' });
  spinnies.fail('spinner-2', { text: 'Fail :(' });
}, 2000);

API

Initialization:

new Spinnies([options])

Parameters

  • options - object:
    • color - string: Any valid chalk color. Default value is white

    • succeedColor - string: Any valid chalk color. Default value is green.

    • failColor - string: Any valid chalk color. Default value is red.

    • spinnerColor- string: Any valid chalk color. Default value is greenBright.

    • spinner- object:

      • interval - number
      • frames - string[]

      You can see the already provided spinner here.

    • disableSpins - boolean: Disable spins (will still print raw messages).

Example:

const spinner = { interval: 80, frames: ['🍇', '🍈', '🍉', '🍋'] }
const spinnies = new Spinnies({ color: 'blue', succeedColor: 'green', spinner });

Instance methods:

add(name, [options])

Adds a new spinner with the given name.

Parameters:

  • name - string: spinner reference name.
  • options - object:
    • text: - string: Optional text to show in the spinner. If none is provided, the name field will be shown.
    • status - string: Sets the initial status of the spinner. Valid statuses are: succeed, fail, spinning, non-spinnableand stopped.
    • color - string: Any valid chalk color.
    • succeedColor - string: Any valid chalk color.
    • failColor - string: Any valid chalk color.

Return value: Returns the spinner's options.

Example:

const spinnies = new Spinnies();
spinnies.add('spinner-1');
spinnies.add('another-spinner', { text: 'Hello, I am a spinner!', color: 'greenBright' });

pick(name)

Picks a spinner.

Parameters:

  • name - string: spinner reference name.

Return value: Returns the spinner's options.

update(name, [options])

Updates the spinner with name name.

Parameters:

  • name - string: spinner reference name.
  • options - object:
    • text: - string: Optional text to show in the spinner. If none is provided, the name field will be shown.
    • status - string: Sets the initial status of the spinner. Valid statuses are: succeed, fail, spinning, non-spinnableand stopped.
    • color - string: Any valid chalk color.
    • succeedColor - string: Any valid chalk color.
    • failColor - string: Any valid chalk color.

Return value: Returns the spinner's options.

Example:

const spinnies = new Spinnies();
spinnies.add('spinner-1', { text: 'Hello! I am the initial text`, color: 'green' });
...
spinnies.update('spinner-1', { text: 'Hello, I am an updated text!', color: 'blue' });

succeed(name, [options])

Sets the specified spinner as succeed.

Parameters:

  • name - string: spinner reference name.
  • options - object:
    • text: - string: Optional text to show in the spinner. If none is provided, the name field will be shown.
    • succeedColor - string: Any valid chalk color.

Return value: Returns the spinner's options.

Example:

const spinnies = new Spinnies();
spinnies.add('spinner-1', { text: 'Hello! I am the initial text`, color: 'green' });
...
spinnies.succeed('spinner-1', { text: 'Success!', successColor: 'greenBright' });

fail(name, [options])

Sets the specified spinner as fail.

Parameters:

  • name - string: spinner reference name.
  • options - object:
    • text: - string: Optional text to show in the spinner. If none is provided, the name field will be shown.
    • failColor - string: Any valid chalk color.

Return value: Returns the spinner's options.

Example:

const spinnies = new Spinnies();
spinnies.add('spinner-1', { text: 'Hello! I am the initial text`, color: 'green' });
...
spinnies.fail('spinner-1', { text: 'I failed', failColor: 'redBright' });

stopAll()

Stops the spinners and sets the non-succeeded and non-failed ones to stopped. You can see an example here.

hasActiveSpinners()

Return value: returns false if all spinners have succeeded, failed or have been stopped.

Contribute

Star it, fork it, improve it, PR it!

Acknowledgements

Thanks to chalk for helping making this lib colorful 🌈 and to ora which was a great inspiration 🦄.

License

MIT