cli-spinners
Advanced tools
Comparing version 2.9.2 to 3.0.0
229
index.d.ts
@@ -1,101 +0,100 @@ | ||
declare namespace cliSpinners { | ||
type SpinnerName = | ||
| 'dots' | ||
| 'dots2' | ||
| 'dots3' | ||
| 'dots4' | ||
| 'dots5' | ||
| 'dots6' | ||
| 'dots7' | ||
| 'dots8' | ||
| 'dots9' | ||
| 'dots10' | ||
| 'dots11' | ||
| 'dots12' | ||
| 'dots8Bit' | ||
| 'sand' | ||
| 'line' | ||
| 'line2' | ||
| 'pipe' | ||
| 'simpleDots' | ||
| 'simpleDotsScrolling' | ||
| 'star' | ||
| 'star2' | ||
| 'flip' | ||
| 'hamburger' | ||
| 'growVertical' | ||
| 'growHorizontal' | ||
| 'balloon' | ||
| 'balloon2' | ||
| 'noise' | ||
| 'bounce' | ||
| 'boxBounce' | ||
| 'boxBounce2' | ||
| 'binary' | ||
| 'triangle' | ||
| 'arc' | ||
| 'circle' | ||
| 'squareCorners' | ||
| 'circleQuarters' | ||
| 'circleHalves' | ||
| 'squish' | ||
| 'toggle' | ||
| 'toggle2' | ||
| 'toggle3' | ||
| 'toggle4' | ||
| 'toggle5' | ||
| 'toggle6' | ||
| 'toggle7' | ||
| 'toggle8' | ||
| 'toggle9' | ||
| 'toggle10' | ||
| 'toggle11' | ||
| 'toggle12' | ||
| 'toggle13' | ||
| 'arrow' | ||
| 'arrow2' | ||
| 'arrow3' | ||
| 'bouncingBar' | ||
| 'bouncingBall' | ||
| 'smiley' | ||
| 'monkey' | ||
| 'hearts' | ||
| 'clock' | ||
| 'earth' | ||
| 'material' | ||
| 'moon' | ||
| 'runner' | ||
| 'pong' | ||
| 'shark' | ||
| 'dqpb' | ||
| 'weather' | ||
| 'christmas' | ||
| 'grenade' | ||
| 'point' | ||
| 'layer' | ||
| 'betaWave' | ||
| 'fingerDance' | ||
| 'fistBump' | ||
| 'soccerHeader' | ||
| 'mindblown' | ||
| 'speaker' | ||
| 'orangePulse' | ||
| 'bluePulse' | ||
| 'orangeBluePulse' | ||
| 'timeTravel' | ||
| 'aesthetic' | ||
| 'dwarfFortress'; | ||
// TODO: Load the spinner names from the JSON file. | ||
export type SpinnerName = | ||
| 'dots' | ||
| 'dots2' | ||
| 'dots3' | ||
| 'dots4' | ||
| 'dots5' | ||
| 'dots6' | ||
| 'dots7' | ||
| 'dots8' | ||
| 'dots9' | ||
| 'dots10' | ||
| 'dots11' | ||
| 'dots12' | ||
| 'dots8Bit' | ||
| 'sand' | ||
| 'line' | ||
| 'line2' | ||
| 'pipe' | ||
| 'simpleDots' | ||
| 'simpleDotsScrolling' | ||
| 'star' | ||
| 'star2' | ||
| 'flip' | ||
| 'hamburger' | ||
| 'growVertical' | ||
| 'growHorizontal' | ||
| 'balloon' | ||
| 'balloon2' | ||
| 'noise' | ||
| 'bounce' | ||
| 'boxBounce' | ||
| 'boxBounce2' | ||
| 'binary' | ||
| 'triangle' | ||
| 'arc' | ||
| 'circle' | ||
| 'squareCorners' | ||
| 'circleQuarters' | ||
| 'circleHalves' | ||
| 'squish' | ||
| 'toggle' | ||
| 'toggle2' | ||
| 'toggle3' | ||
| 'toggle4' | ||
| 'toggle5' | ||
| 'toggle6' | ||
| 'toggle7' | ||
| 'toggle8' | ||
| 'toggle9' | ||
| 'toggle10' | ||
| 'toggle11' | ||
| 'toggle12' | ||
| 'toggle13' | ||
| 'arrow' | ||
| 'arrow2' | ||
| 'arrow3' | ||
| 'bouncingBar' | ||
| 'bouncingBall' | ||
| 'smiley' | ||
| 'monkey' | ||
| 'hearts' | ||
| 'clock' | ||
| 'earth' | ||
| 'material' | ||
| 'moon' | ||
| 'runner' | ||
| 'pong' | ||
| 'shark' | ||
| 'dqpb' | ||
| 'weather' | ||
| 'christmas' | ||
| 'grenade' | ||
| 'point' | ||
| 'layer' | ||
| 'betaWave' | ||
| 'fingerDance' | ||
| 'fistBump' | ||
| 'soccerHeader' | ||
| 'mindblown' | ||
| 'speaker' | ||
| 'orangePulse' | ||
| 'bluePulse' | ||
| 'orangeBluePulse' | ||
| 'timeTravel' | ||
| 'aesthetic' | ||
| 'dwarfFortress'; | ||
interface Spinner { | ||
/** | ||
Recommended interval. | ||
*/ | ||
readonly interval: number; | ||
export type Spinner = { | ||
/** | ||
The recommended interval. | ||
*/ | ||
readonly interval: number; | ||
/** | ||
A list of frames to show for the spinner. | ||
*/ | ||
readonly frames: string[]; | ||
} | ||
} | ||
/** | ||
A list of frames to show for the spinner. | ||
*/ | ||
readonly frames: string[]; | ||
}; | ||
@@ -107,8 +106,8 @@ /** | ||
``` | ||
import cliSpinners = require('cli-spinners'); | ||
import cliSpinners from 'cli-spinners'; | ||
console.log(cliSpinners.dots); | ||
// { | ||
// interval: 80, | ||
// frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'] | ||
// interval: 80, | ||
// frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'] | ||
// } | ||
@@ -118,13 +117,21 @@ ``` | ||
declare const cliSpinners: { | ||
readonly [spinnerName in cliSpinners.SpinnerName]: cliSpinners.Spinner; | ||
} & { | ||
/** | ||
Returns a random spinner each time it's called. | ||
*/ | ||
readonly random: cliSpinners.Spinner; | ||
// TODO: Remove this for the next major release | ||
default: typeof cliSpinners; | ||
readonly [spinnerName in SpinnerName]: Spinner; | ||
}; | ||
export = cliSpinners; | ||
export default cliSpinners; | ||
/** | ||
Get a random spinner. | ||
@example | ||
``` | ||
import {randomSpinner} from 'cli-spinners'; | ||
console.log(randomSpinner()); | ||
// { | ||
// interval: 80, | ||
// frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'] | ||
// } | ||
``` | ||
*/ | ||
export function randomSpinner(): Spinner; |
18
index.js
@@ -1,15 +0,11 @@ | ||
'use strict'; | ||
import spinners from './spinners.json' with {type: 'json'}; | ||
const spinners = Object.assign({}, require('./spinners.json')); // eslint-disable-line import/extensions | ||
export default spinners; | ||
const spinnersList = Object.keys(spinners); | ||
Object.defineProperty(spinners, 'random', { | ||
get() { | ||
const randomIndex = Math.floor(Math.random() * spinnersList.length); | ||
const spinnerName = spinnersList[randomIndex]; | ||
return spinners[spinnerName]; | ||
} | ||
}); | ||
module.exports = spinners; | ||
export function randomSpinner() { | ||
const randomIndex = Math.floor(Math.random() * spinnersList.length); | ||
const spinnerName = spinnersList[randomIndex]; | ||
return spinners[spinnerName]; | ||
} |
{ | ||
"name": "cli-spinners", | ||
"version": "2.9.2", | ||
"version": "3.0.0", | ||
"description": "Spinners for use in the terminal", | ||
@@ -13,7 +13,14 @@ "license": "MIT", | ||
}, | ||
"type": "module", | ||
"exports": { | ||
"types": "./index.d.ts", | ||
"default": "./index.js" | ||
}, | ||
"sideEffects": false, | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=18.20" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd", | ||
"//test": "xo && ava && tsc --noEmit index.d.ts", | ||
"test": "ava && tsc --noEmit index.d.ts", | ||
"asciicast": "asciinema rec --command='node example-all.js' --title='cli-spinner' --quiet" | ||
@@ -44,9 +51,8 @@ }, | ||
"devDependencies": { | ||
"@types/node": "^17.0.41", | ||
"ava": "^1.4.1", | ||
"log-update": "^3.2.0", | ||
"string-length": "^4.0.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
"ava": "^6.1.2", | ||
"log-update": "^6.0.0", | ||
"string-length": "^6.0.0", | ||
"typescript": "^5.4.5", | ||
"xo": "^0.58.0" | ||
} | ||
} |
@@ -14,3 +14,3 @@ # cli-spinners | ||
You probably want to use one of these spinners through the [`ora`](https://github.com/sindresorhus/ora) module. | ||
You probably want to use one of these spinners through the [`ora`](https://github.com/sindresorhus/ora) package. | ||
@@ -26,3 +26,3 @@ ## Install | ||
```js | ||
const cliSpinners = require('cli-spinners'); | ||
import cliSpinners from 'cli-spinners'; | ||
@@ -44,2 +44,4 @@ console.log(cliSpinners.dots); | ||
### cliSpinners | ||
Each spinner comes with a recommended `interval` and an array of `frames`. | ||
@@ -49,4 +51,18 @@ | ||
The `random` spinner will return a random spinner each time it's called. | ||
### randomSpinner() | ||
Get a random spinner. | ||
```js | ||
import {randomSpinner} from 'cli-spinners'; | ||
console.log(randomSpinner()); | ||
/* | ||
{ | ||
interval: 80, | ||
frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'] | ||
} | ||
*/ | ||
``` | ||
## Related | ||
@@ -53,0 +69,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32364
5
1756
71
Yes