https://github.com/ascorbic/tiny-spin
A CLI spinner in under 1kB
https://github.com/ascorbic/tiny-spin
Last synced: 9 months ago
JSON representation
A CLI spinner in under 1kB
- Host: GitHub
- URL: https://github.com/ascorbic/tiny-spin
- Owner: ascorbic
- Created: 2020-11-09T10:33:50.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-03-26T07:08:13.000Z (almost 2 years ago)
- Last Synced: 2025-03-29T06:51:10.468Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 16
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tiny-spin

## A tiny, zero-dependency CLI spinner
[Try it out](https://repl.it/@ascorbic/tiny-spin-demo)
When you want a CLI spinner in just a few bytes. Installation:
```shell
npm i tiny-spin
```
or
```shell
yarn add tiny-spin
```
Usage:
```js
// CommonJS
const { spin } = require("tiny-spin");
const stop = spin("Doing stuff");
// Do stuff
stop();
```
```js
// ESM
import { spin } from "tiny-spin";
const stop = spin("Doing stuff");
// Do stuff
stop();
```
## API
### `spin(message, frames, interval)`
- `message`: the message displayed after the spinner. Default empty
- `frames`: an array of strings that are the frames displayed by the spinner. Default `["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]`
- `interval`: the interval between frames. Default 80ms.
Returns a function that you call to stop the spinner.
Author: [Matt Kane](https://github.com/ascorbic). MIT licence.