Skip to content

Commit fb0fced

Browse files
committed
Minor tweaks
1 parent 3c63d5e commit fb0fced

File tree

5 files changed

+34
-31
lines changed

5 files changed

+34
-31
lines changed

index.d.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export type SuffixTextGenerator = () => string;
2222

2323
export type Options = {
2424
/**
25-
Text to display after the spinner.
25+
The text to display next to the spinner.
2626
*/
2727
readonly text?: string;
2828

@@ -37,7 +37,7 @@ export type Options = {
3737
readonly suffixText?: string | SuffixTextGenerator;
3838

3939
/**
40-
Name of one of the provided spinners. See [`example.js`](https://github.com/BendingBender/ora/blob/main/example.js) in this repo if you want to test out different spinners. On Windows, it will always use the line spinner as the Windows command-line doesn't have proper Unicode support.
40+
The name of one of the provided spinners. See [`example.js`](https://github.com/BendingBender/ora/blob/main/example.js) in this repo if you want to test out different spinners. On Windows (expect for Windows Terminal), it will always use the line spinner as the Windows command-line doesn't have proper Unicode support.
4141
4242
@default 'dots'
4343
@@ -46,8 +46,8 @@ export type Options = {
4646
@example
4747
```
4848
{
49-
interval: 80, // Optional
50-
frames: ['-', '+', '-']
49+
frames: ['-', '+', '-'],
50+
interval: 80 // Optional
5151
}
5252
```
5353
*/
@@ -204,7 +204,7 @@ export interface Ora {
204204
set spinner(spinner: SpinnerName | Spinner);
205205

206206
/**
207-
A boolean of whether the instance is currently spinning.
207+
A boolean indicating whether the instance is currently spinning.
208208
*/
209209
get isSpinning(): boolean;
210210

index.js

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class Ora {
2525
#text;
2626
#prefixText;
2727
#suffixText;
28-
2928
color;
3029

3130
constructor(options) {

package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@
4444
],
4545
"dependencies": {
4646
"chalk": "^5.3.0",
47-
"cli-cursor": "^4.0.0",
47+
"cli-cursor": "^5.0.0",
4848
"cli-spinners": "^2.9.2",
4949
"is-interactive": "^2.0.0",
5050
"is-unicode-supported": "^2.0.0",
5151
"log-symbols": "^6.0.0",
52-
"stdin-discarder": "^0.2.1",
53-
"string-width": "^7.0.0",
52+
"stdin-discarder": "^0.2.2",
53+
"string-width": "^7.2.0",
5454
"strip-ansi": "^7.1.0"
5555
},
5656
"devDependencies": {
57-
"@types/node": "^20.10.5",
57+
"@types/node": "^22.5.0",
5858
"ava": "^5.3.1",
59-
"get-stream": "^8.0.1",
59+
"get-stream": "^9.0.1",
6060
"transform-tty": "^1.0.11",
61-
"tsd": "^0.30.0",
62-
"xo": "^0.56.0"
61+
"tsd": "^0.31.1",
62+
"xo": "^0.59.3"
6363
}
6464
}

readme.md

+18-14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
npm install ora
1515
```
1616

17+
*Check out [`yocto-spinner`](https://github.com/sindresorhus/yocto-spinner) for a smaller alternative.*
18+
1719
## Usage
1820

1921
```js
@@ -42,7 +44,7 @@ Type: `object`
4244

4345
Type: `string`
4446

45-
Text to display after the spinner.
47+
The text to display next to the spinner.
4648

4749
##### prefixText
4850

@@ -61,14 +63,14 @@ Text or a function that returns text to display after the spinner text. No suffi
6163
Type: `string | object`\
6264
Default: `'dots'` <img src="screenshot-spinner.gif" width="14">
6365

64-
Name of one of the [provided spinners](#spinners). See `example.js` in this repo if you want to test out different spinners. On Windows, it will always use the `line` spinner as the Windows command-line doesn't have proper Unicode support.
66+
The name of one of the [provided spinners](#spinners). See `example.js` in this repo if you want to test out different spinners. On Windows (except for Windows Terminal), it will always use the `line` spinner as the Windows command-line doesn't have proper Unicode support.
6567

6668
Or an object like:
6769

6870
```js
6971
{
70-
interval: 80, // Optional
71-
frames: ['-', '+', '-']
72+
frames: ['-', '+', '-'],
73+
interval: 80 // Optional
7274
}
7375
```
7476

@@ -140,7 +142,7 @@ This has no effect on Windows as there is no good way to implement discarding st
140142

141143
#### .text <sup>get/set</sup>
142144

143-
Change the text after the spinner.
145+
Change the text displayed after the spinner.
144146

145147
#### .prefixText <sup>get/set</sup>
146148

@@ -168,7 +170,7 @@ Change the spinner indent.
168170

169171
#### .isSpinning <sup>get</sup>
170172

171-
A boolean of whether the instance is currently spinning.
173+
A boolean indicating whether the instance is currently spinning.
172174

173175
#### .interval <sup>get</sup>
174176

@@ -224,17 +226,17 @@ Text to be persisted after the symbol.
224226

225227
###### prefixText
226228

227-
Type: `string`\
229+
Type: `string | () => string`\
228230
Default: Current `prefixText`
229231

230-
Text to be persisted before the symbol. No prefix text will be displayed if set to an empty string.
232+
Text or a function that returns text to be persisted before the symbol. No prefix text will be displayed if set to an empty string.
231233

232234
###### suffixText
233235

234-
Type: `string`\
236+
Type: `string | () => string`\
235237
Default: Current `suffixText`
236238

237-
Text to be persisted after the text after the symbol. No suffix text will be displayed if set to an empty string.
239+
Text or a function that returns text to be persisted after the text after the symbol. No suffix text will be displayed if set to an empty string.
238240

239241
<img src="screenshot-2.gif" width="480">
240242

@@ -297,7 +299,7 @@ All [provided spinners](https://github.com/sindresorhus/cli-spinners/blob/main/s
297299

298300
### How do I change the color of the text?
299301

300-
Use [Chalk](https://github.com/chalk/chalk):
302+
Use [`chalk`](https://github.com/chalk/chalk) or [`yoctocolors`](https://github.com/sindresorhus/yoctocolors):
301303

302304
```js
303305
import ora from 'ora';
@@ -308,18 +310,20 @@ const spinner = ora(`Loading ${chalk.red('unicorns')}`).start();
308310

309311
### Why does the spinner freeze?
310312

311-
JavaScript is single-threaded, so synchronous operations blocks the thread, including the spinner animation. Prefer asynchronous operations whenever possible.
313+
JavaScript is single-threaded, so any synchronous operations will block the spinner's animation. To avoid this, prefer using asynchronous operations.
312314

313315
## Related
314316

317+
- [yocto-spinner](https://github.com/sindresorhus/yocto-spinner) - Tiny terminal spinner
315318
- [cli-spinners](https://github.com/sindresorhus/cli-spinners) - Spinners for use in the terminal
316-
- [listr](https://github.com/SamVerschueren/listr) - Terminal task list
319+
320+
**Ports**
321+
317322
- [CLISpinner](https://github.com/kiliankoe/CLISpinner) - Terminal spinner library for Swift
318323
- [halo](https://github.com/ManrajGrover/halo) - Python port
319324
- [spinners](https://github.com/FGRibreau/spinners) - Terminal spinners for Rust
320325
- [marquee-ora](https://github.com/joeycozza/marquee-ora) - Scrolling marquee spinner for Ora
321326
- [briandowns/spinner](https://github.com/briandowns/spinner) - Terminal spinner/progress indicator for Go
322327
- [tj/go-spin](https://github.com/tj/go-spin) - Terminal spinner package for Go
323328
- [observablehq.com/@victordidenko/ora](https://observablehq.com/@victordidenko/ora) - Ora port to Observable notebooks
324-
- [spinnies](https://github.com/jcarpanelli/spinnies) - Terminal multi-spinner library for Node.js
325329
- [kia](https://github.com/HarryPeach/kia) - Simple terminal spinners for Deno 🦕

test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const getPassThroughStream = () => {
1717
return stream;
1818
};
1919

20-
const doSpinner = async (fn, extraOptions = {}) => {
20+
const doSpinner = async (function_, extraOptions = {}) => {
2121
const stream = getPassThroughStream();
2222
const output = getStream(stream);
2323

@@ -31,14 +31,14 @@ const doSpinner = async (fn, extraOptions = {}) => {
3131
});
3232

3333
spinner.start();
34-
fn(spinner);
34+
function_(spinner);
3535
stream.end();
3636

3737
return stripAnsi(await output);
3838
};
3939

40-
const macro = async (t, fn, expected, extraOptions = {}) => {
41-
t.regex(await doSpinner(fn, extraOptions), expected);
40+
const macro = async (t, function_, expected, extraOptions = {}) => {
41+
t.regex(await doSpinner(function_, extraOptions), expected);
4242
};
4343

4444
test('main', macro, spinner => {

0 commit comments

Comments
 (0)