-
Notifications
You must be signed in to change notification settings - Fork 1
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 8670cfa
Showing
14 changed files
with
1,799 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,8 @@ | ||
{ | ||
"reporter": [ | ||
"lcov" | ||
], | ||
"exclude": [ | ||
"dist/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,3 @@ | ||
dist | ||
node_modules | ||
coverage |
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,10 @@ | ||
{ | ||
"bracketSpacing": false, | ||
"printWidth": 80, | ||
"semi": true, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "none", | ||
"useTabs": false, | ||
"arrowParens": "always" | ||
} |
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,9 @@ | ||
{ | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"[javascript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
} | ||
} |
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,20 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 PondWader | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
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,106 @@ | ||
# picospinner | ||
|
||
<img src="assets/demo.gif" width="522" alt="Demo"> | ||
|
||
A lightweight, no dependency, pluggable CLI spinner library. | ||
|
||
## Install | ||
|
||
``` | ||
npm i picospinner | ||
``` | ||
|
||
## Usage | ||
|
||
### Basic | ||
|
||
```js | ||
import {Spinner} from 'picospinner'; | ||
|
||
const spinner = new Spinner('Loading...'); | ||
spinner.start(); | ||
setTimeout(() => { | ||
spinner.succeed('Finished.'); | ||
}, 5000); | ||
``` | ||
|
||
### Custom symbols | ||
|
||
```js | ||
import {Spinner} from 'picospinner'; | ||
|
||
const spinner = new Spinner('Loading...', { | ||
symbols: { | ||
warn: '⚠' | ||
} | ||
}); | ||
spinner.start(); | ||
setTimeout(() => { | ||
spinner.warn("Something didn't go quite right."); | ||
}, 5000); | ||
``` | ||
|
||
### Custom frames | ||
|
||
```js | ||
import {Spinner} from 'picospinner'; | ||
|
||
const spinner = new Spinner('Loading...', { | ||
frames: ['-', '\\', '|', '/'] | ||
}); | ||
spinner.start(); | ||
setTimeout(() => { | ||
spinner.info('Finished.'); | ||
}, 5000); | ||
``` | ||
|
||
### Removing the spinner | ||
|
||
Calling `spinner.stop();` will stop the spinner and remove it. | ||
|
||
### Colours | ||
|
||
Colours can be achieved by using a formatter such as picocolors or chalk. First install picocolors: | ||
|
||
``` | ||
npm i picocolors | ||
``` | ||
|
||
Text can be formatted by passing pre-formatted text: | ||
|
||
```js | ||
import {Spinner} from 'picospinner'; | ||
import pc from 'picocolors'; | ||
|
||
const spinner = new Spinner(pc.blue('Loading...')); | ||
spinner.start(); | ||
setTimeout(() => spinner.setText(pc.magenta("Now it's magenta!")), 1000); | ||
``` | ||
|
||
Symbols can be formatted by passing a symbol formatter. | ||
|
||
```js | ||
import {Spinner} from 'picospinner'; | ||
import pc from 'picocolors'; | ||
|
||
const spinner = new Spinner({ | ||
text: pc.blue('Loading...'), | ||
symbolFormatter: pc.green | ||
}); | ||
spinner.start(); | ||
spinner.fail({ | ||
text: 'Disaster!', | ||
symbolFormatter: pc.red | ||
}); | ||
``` | ||
|
||
### Custom rotation speed | ||
|
||
A custom tick speed (how often the spinner rotates) in milliseconds can be passed to `spinner.start`: | ||
|
||
```js | ||
import {Spinner} from 'picospinner'; | ||
|
||
const spinner = new Spinner(); | ||
spinner.start(10); | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.