-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit abe4ad8
Showing
13 changed files
with
838 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: CI | ||
on: | ||
- push | ||
- pull_request | ||
jobs: | ||
test: | ||
name: Node.js ${{ matrix.node-version }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: | ||
- 22 | ||
- 20 | ||
- 18 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import yoctoSpinner from './index.js'; | ||
|
||
const spinner = yoctoSpinner({ | ||
text: 'Loading unicorns\n (And rainbows)', | ||
}).start(); | ||
|
||
setTimeout(() => { | ||
spinner.text = 'Calculating splines'; | ||
}, 2000); | ||
|
||
setTimeout(() => { | ||
spinner.success('Finished!'); | ||
}, 5000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import {type Writable} from 'node:stream'; | ||
|
||
export type SpinnerStyle = { | ||
readonly interval?: number; | ||
readonly frames: string[]; | ||
}; | ||
|
||
export type Color = | ||
| 'black' | ||
| 'red' | ||
| 'green' | ||
| 'yellow' | ||
| 'blue' | ||
| 'magenta' | ||
| 'cyan' | ||
| 'white' | ||
| 'gray'; | ||
|
||
export type Options = { | ||
/** | ||
Text to display next to the spinner. | ||
@default '' | ||
*/ | ||
readonly text?: string; | ||
|
||
/** | ||
Customize the spinner animation with a custom set of frames and interval. | ||
``` | ||
{ | ||
frames: ['-', '\\', '|', '/'], | ||
interval: 100, | ||
} | ||
``` | ||
Pass in any spinner from [`cli-spinners`](https://github.com/sindresorhus/cli-spinners). | ||
*/ | ||
readonly spinner?: SpinnerStyle; | ||
|
||
/** | ||
The color of the spinner. | ||
@default 'cyan' | ||
*/ | ||
readonly color?: Color; | ||
|
||
/** | ||
The stream to which the spinner is written. | ||
@default process.stderr | ||
*/ | ||
readonly stream?: Writable; | ||
}; | ||
|
||
export type Spinner = { | ||
/** | ||
Change the text displayed next to the spinner. | ||
@example | ||
``` | ||
spinner.text = 'New text'; | ||
``` | ||
*/ | ||
text: string; | ||
|
||
/** | ||
Change the spinner color. | ||
*/ | ||
color: Color; | ||
|
||
/** | ||
Starts the spinner. | ||
Optionally, updates the text. | ||
@param text - The text to display next to the spinner. | ||
@returns The spinner instance. | ||
*/ | ||
start(text?: string): Spinner; | ||
|
||
/** | ||
Stops the spinner. | ||
Optionally displays a final message. | ||
@param finalText - The final text to display after stopping the spinner. | ||
@returns The spinner instance. | ||
*/ | ||
stop(finalText?: string): Spinner; | ||
|
||
/** | ||
Stops the spinner and displays a success symbol with the message. | ||
@param text - The success message to display. | ||
@returns The spinner instance. | ||
*/ | ||
success(text?: string): Spinner; | ||
|
||
/** | ||
Stops the spinner and displays an error symbol with the message. | ||
@param text - The error message to display. | ||
@returns The spinner instance. | ||
*/ | ||
error(text?: string): Spinner; | ||
|
||
/** | ||
Stops the spinner and displays a warning symbol with the message. | ||
@param text - The warning message to display. | ||
@returns The spinner instance. | ||
*/ | ||
warning(text?: string): Spinner; | ||
|
||
/** | ||
Stops the spinner and displays an info symbol with the message. | ||
@param text - The info message to display. | ||
@returns The spinner instance. | ||
*/ | ||
info(text?: string): Spinner; | ||
|
||
/** | ||
Clears the spinner. | ||
@returns The spinner instance. | ||
*/ | ||
clear(): Spinner; | ||
|
||
/** | ||
Returns whether the spinner is currently spinning. | ||
*/ | ||
get isSpinning(): boolean; | ||
}; | ||
|
||
/** | ||
Creates a new spinner instance. | ||
@returns A new spinner instance. | ||
@example | ||
``` | ||
import yoctoSpinner from 'yocto-spinner'; | ||
const spinner = yoctoSpinner({text: 'Loading…'}).start(); | ||
setTimeout(() => { | ||
spinner.success('Success!'); | ||
}, 2000); | ||
``` | ||
*/ | ||
export default function yoctoSpinner(options?: Options): Spinner; |
Oops, something went wrong.