-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
153 lines (117 loc) · 2.61 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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;