Create and manage multiple spinners in command-line interface programs
npm install spinnies



```
$ npm i spinnies
`js
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);
`
This library follows a non-error-throwing philosophy. If you provide an invalid option or an invalid value for a valid option it will be ignored.
#### new Spinnies([options])
Parameters
- options - object:string
- color - : Any valid chalk color. The default value is white.string
- succeedColor - : Any valid chalk color. The default value is green.string
- failColor - : Any valid chalk color. The default value is red.string
- spinnerColor - : Any valid chalk color. The default value is greenBright.string
- succeedPrefix - : The default value is ✓.string
- failPrefix- : The default value is ✖.object
- spinner- :number
- interval - string[]
- frames -
You can see the already provided spinner here.
- disableSpins - boolean: Disable spins (will still print raw messages).
Note: If you are working in any win32 platform, the default spin animation will be overriden. You can get rid of this defining a different spinner animation manually, or by using the integrated VSCode terminal or Windows Terminal.
Example:
`js`
const spinner = { interval: 80, frames: ['🍇', '🍈', '🍉', '🍋'] }
const spinnies = new Spinnies({ color: 'blue', succeedColor: 'green', spinner });
#### add(name, [options])
Adds a new spinner with the given name.
Parameters:
- name - string: spinner reference name.object
- options - :string
- text: - : Optional text to show in the spinner. If none is provided, the name field will be shown.number
- indent: - : Optional, indent the spinner with the given number of spaces.string
- status - : Initial status of the spinner. Valid statuses are: succeed, fail, spinning, non-spinnableand stopped.string
- color - : Any valid chalk color.string
- succeedColor - : Any valid chalk color.string
- failColor - : Any valid chalk color.
Return value: Returns the spinner's options.
Example:
`js
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.
#### remove(name)
Removes a spinner.
Parameters:
- name - string: spinner reference name.
Return value: Returns the spinner's options.
#### update(name, [options])
Updates the spinner with name name with the provided options.
Parameters:
- name - string: spinner reference name.object
- options - :string
- text: - : Optional text to show in the spinner. If none is provided, the name field will be shown.string
- status - : New status of the spinner. Valid statuses are: succeed, fail, spinning, non-spinnableand stopped.string
- color - : Any valid chalk color.string
- succeedColor - : Any valid chalk color.string
- failColor - : Any valid chalk color.
Return value: Returns the spinner's options.
Example:
`js
const spinnies = new Spinnies();
spinnies.add('spinner-1', { text: 'Hello! I am the initial text', color: 'green' });
// some code
spinnies.update('spinner-1', { text: 'Hello, I am an updated text!', color: 'blue' });
`
#### succeed(name, [options])
Sets the specified spinner status as succeed.
Parameters:
- name - string: spinner reference name.object
- options - :string
- text: - : Optional text to show in the spinner. If none is provided, the name field will be shown.string
- succeedColor - : Any valid chalk color.
Return value: Returns the spinner's options.
Example:
`js
const spinnies = new Spinnies();
spinnies.add('spinner-1', { text: 'Hello! I am the initial text', color: 'green' });
// some code
spinnies.succeed('spinner-1', { text: 'Success!', successColor: 'greenBright' });
`
#### fail(name, [options])
Sets the specified spinner status as fail.
Parameters:
- name - string: spinner reference name.object
- options - :string
- text: - : Optional text to show in the spinner. If none is provided, the name field will be shown.string
- failColor - : Any valid chalk color.
Return value: Returns the spinner's options.
Example:
`js
const spinnies = new Spinnies();
spinnies.add('spinner-1', { text: 'Hello! I am the initial text', color: 'green' });
// some code
spinnies.fail('spinner-1', { text: 'I failed', failColor: 'redBright' });
`
#### stopAll([status])
Stops the spinners and sets the non-succeeded and non-failed ones to the provided status, which can be succeed, fail or stopped. You can see an example here.
#### hasActiveSpinners()
Return value: returns false` if all spinners have succeeded, failed or have been stopped.
Star it, fork it, improve it, PR it! :raised_hands:.
Thanks to chalk for helping making this lib colorful :rainbow: and to ora which was a great inspiration :unicorn:.