Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Feb 21, 2022
1 parent 447812b commit 6a4150a
Show file tree
Hide file tree
Showing 6 changed files with 309 additions and 269 deletions.
51 changes: 29 additions & 22 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface Options {
readonly spinner?: SpinnerName | Spinner;

/**
Color of the spinner.
The color of the spinner.
@default 'cyan'
*/
Expand Down Expand Up @@ -149,110 +149,117 @@ export interface PromiseOptions<T> extends Options {
}

export interface Ora {
/**
A boolean of whether the instance is currently spinning.
*/
readonly isSpinning: boolean;

/**
Change the text after the spinner.
*/
text: string;

/**
Change the text or function that returns text before the spinner. No prefix text will be displayed if set to an empty string.
Change the text or function that returns text before the spinner.
No prefix text will be displayed if set to an empty string.
*/
prefixText: string | PrefixTextGenerator;
prefixText: string;

/**
Change the spinner color.
*/
color: Color;

/**
Change the spinner.
Change the spinner indent.
*/
spinner: SpinnerName | Spinner;
indent: number;

/**
Change the spinner indent.
Get the spinner.
*/
indent: number;
get spinner(): Spinner;

/**
Set the spinner.
*/
set spinner(spinner: SpinnerName | Spinner);

/**
A boolean of whether the instance is currently spinning.
*/
get isSpinning(): boolean;

/**
The interval between each frame.
The interval is decided by the chosen spinner.
*/
readonly interval: number;
get interval(): number;

/**
Start the spinner.
@param text - Set the current text.
@returns The spinner instance.
*/
start(text?: string): Ora;
start(text?: string): this;

/**
Stop and clear the spinner.
@returns The spinner instance.
*/
stop(): Ora;
stop(): this;

/**
Stop the spinner, change it to a green `✔` and persist the current text, or `text` if provided.
@param text - Will persist text if provided.
@returns The spinner instance.
*/
succeed(text?: string): Ora;
succeed(text?: string): this;

/**
Stop the spinner, change it to a red `✖` and persist the current text, or `text` if provided.
@param text - Will persist text if provided.
@returns The spinner instance.
*/
fail(text?: string): Ora;
fail(text?: string): this;

/**
Stop the spinner, change it to a yellow `⚠` and persist the current text, or `text` if provided.
@param text - Will persist text if provided.
@returns The spinner instance.
*/
warn(text?: string): Ora;
warn(text?: string): this;

/**
Stop the spinner, change it to a blue `ℹ` and persist the current text, or `text` if provided.
@param text - Will persist text if provided.
@returns The spinner instance.
*/
info(text?: string): Ora;
info(text?: string): this;

/**
Stop the spinner and change the symbol or text.
@returns The spinner instance.
*/
stopAndPersist(options?: PersistOptions): Ora;
stopAndPersist(options?: PersistOptions): this;

/**
Clear the spinner.
@returns The spinner instance.
*/
clear(): Ora;
clear(): this;

/**
Manually render a new frame.
@returns The spinner instance.
*/
render(): Ora;
render(): this;

/**
Get a new frame.
Expand Down
Loading

0 comments on commit 6a4150a

Please sign in to comment.