Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: helloIAmPau/node-spinner
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ddd3ebfadef021509feabf619e7267f566de1dc2
Choose a base ref
...
head repository: helloIAmPau/node-spinner
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3601c682678c0c15753c9add6319b1028ba6de40
Choose a head ref
  • 10 commits
  • 5 files changed
  • 3 contributors

Commits on Aug 21, 2017

  1. Fix API docs

    The README states that `setSpinnerTitle` and `isSpinning` are on the `Spinner` object, whereas it's actually on [`Spinner.prototype`](https://github.com/helloIAmPau/node-spinner/blob/master/index.js#L65).
    janslow committed Aug 21, 2017
    Copy the full SHA
    e92a076 View commit details

Commits on Jun 14, 2018

  1. Emoji support

    brutalchrist committed Jun 14, 2018
    Copy the full SHA
    57258bf View commit details
  2. Clock spinner

    brutalchrist committed Jun 14, 2018
    Copy the full SHA
    3558ed9 View commit details
  3. increment version

    brutalchrist committed Jun 14, 2018
    Copy the full SHA
    1846a70 View commit details
  4. Fix example

    brutalchrist committed Jun 14, 2018
    Copy the full SHA
    0bee246 View commit details

Commits on Aug 15, 2018

  1. Merge pull request #26 from janslow/fix-docs

    Fix `#setSpinnerTitle` docs
    helloIAmPau authored Aug 15, 2018
    Copy the full SHA
    433ae45 View commit details

Commits on Aug 17, 2018

  1. Merge pull request #30 from brutalchrist/emoji_support

    Emoji Support 🎉
    helloIAmPau authored Aug 17, 2018
    Copy the full SHA
    86cc7d9 View commit details

Commits on Mar 1, 2019

  1. Copy the full SHA
    c2124a0 View commit details
  2. Copy the full SHA
    cd58415 View commit details
  3. 0.2.10

    helloIAmPau committed Mar 1, 2019
    Copy the full SHA
    3601c68 View commit details
Showing with 26 additions and 16 deletions.
  1. +10 −11 README.md
  2. +1 −1 example/spinner.js
  3. +11 −1 index.js
  4. +1 −1 package.json
  5. +3 −2 spinners.json
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ A simple spinner for node cli.

[![NPM](https://nodei.co/npm/cli-spinner.png?downloads=true&downloadRank=true)](https://nodei.co/npm/cli-spinner/) [![NPM](https://nodei.co/npm-dl/cli-spinner.png?months=6&height=3)](https://nodei.co/npm/cli-spinner/)

[![gitcheese.com](https://s3.amazonaws.com/gitcheese-ui-master/images/badge.svg)](https://www.gitcheese.com/donate/users/1024472/repos/14378143)
---

## Installation
@@ -53,6 +52,11 @@ Starts the spinner.
Stops the spinner. Accepts a Boolean parameter to clean the console.


**`obj.isSpinning()`**

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


**`obj.setSpinnerString(spinnerString)`**

Sets the spinner string. Accepts either a String or an Integer index to reference the [built-in spinners](#demo).
@@ -63,6 +67,11 @@ Sets the spinner string. Accepts either a String or an Integer index to referenc
Sets the spinner animation speed.


**`obj.setSpinnerTitle(spinnerTitle)`**

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


**`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](#demo).
@@ -72,16 +81,6 @@ Sets the default spinner string for all newly created instances. Accepts either

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:
2 changes: 1 addition & 1 deletion example/spinner.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ var index = 0;
var delay = 5000;

function nextSpinner(d) {
d = d || delay;
d = (d === 0) ? d : delay;

setTimeout(function() {
if (spinner !== null) {
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -39,6 +39,10 @@ Spinner.setDefaultSpinnerDelay = function(value) {
};

Spinner.prototype.start = function() {
if(this.stream === process.stdout && this.stream.isTTY !== true) {
return this;
}

var current = 0;
var self = this;

@@ -69,7 +73,8 @@ Spinner.prototype.setSpinnerDelay = function(n) {
};

Spinner.prototype.setSpinnerString = function(str) {
this.chars = mapToSpinner(str, this.spinners).split('');
const map = mapToSpinner(str, this.spinners);
this.chars = Array.isArray(map) ? map : map.split('');

return this;
};
@@ -81,8 +86,13 @@ Spinner.prototype.setSpinnerTitle = function(str) {
}

Spinner.prototype.stop = function(clear) {
if(this.isSpinning === false) {
return this;
}

clearInterval(this.id);
this.id = undefined;

if (clear) {
this.clearLine(this.stream);
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cli-spinner",
"version": "0.2.8",
"version": "0.2.10",
"author": "Pasquale Boemio <boemianrapsodi@gmail.com>",
"contributors": [
{
5 changes: 3 additions & 2 deletions spinners.json
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
"◢◣◤◥",
".oO°Oo.",
".oO@*",
"🌍🌎🌏",
["🌍", "🌎", "🌏"],
"◡◡ ⊙⊙ ◠◠",
"☱☲☴",
"⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏",
@@ -28,5 +28,6 @@
"⢹⢺⢼⣸⣇⡧⡗⡏",
"⣾⣽⣻⢿⡿⣟⣯⣷",
"⠁⠂⠄⡀⢀⠠⠐⠈",
"🌑🌒🌓🌔🌕🌝🌖🌗🌘🌚"
["🌑", "🌒", "🌓", "🌔", "🌕", "🌝", "🌖", "🌗", "🌘", "🌚"],
["🕛", "🕐", "🕑", "🕒", "🕓", "🕔", "🕕", "🕖", "🕗", "🕘", "🕙", "🕚"]
]