|
| 1 | +/// <reference types="node"/> |
| 2 | + |
| 3 | +declare namespace loading { |
| 4 | + interface Options { |
| 5 | + text?: string; |
| 6 | + color?: string; |
| 7 | + interval?: number; |
| 8 | + stream?: NodeJS.WritableStream; |
| 9 | + frames?: string[]; |
| 10 | + } |
| 11 | + interface Loading { |
| 12 | + /** |
| 13 | + * Change the text after the spinner. |
| 14 | + */ |
| 15 | + text: string; |
| 16 | + /** |
| 17 | + * Change the spinner color. |
| 18 | + */ |
| 19 | + color: string; |
| 20 | + /** |
| 21 | + * Start the spinner. |
| 22 | + * @param text - Set the current text. |
| 23 | + */ |
| 24 | + start(text?: string): Loading; |
| 25 | + /** |
| 26 | + * Stop and clear the spinner. |
| 27 | + * @returns The spinner instance. |
| 28 | + */ |
| 29 | + stop(): Loading; |
| 30 | + /** |
| 31 | + * Clear the spinner. |
| 32 | + * @returns The spinner instance. |
| 33 | + */ |
| 34 | + clear(): Loading; |
| 35 | + /** |
| 36 | + * Stop the spinner, change it to a green `✔` and persist the current text, or `text` if provided. |
| 37 | + * @param text - Will persist text if provided. |
| 38 | + * @returns The spinner instance. |
| 39 | + */ |
| 40 | + succeed(text?: string): Loading; |
| 41 | + |
| 42 | + /** |
| 43 | + * Stop the spinner, change it to a red `✖` and persist the current text, or `text` if provided. |
| 44 | + * @param text - Will persist text if provided. |
| 45 | + * @returns The spinner instance. |
| 46 | + */ |
| 47 | + fail(text?: string): Loading; |
| 48 | + /** |
| 49 | + * Stop the spinner, change it to a yellow `⚠` and persist the current text, or `text` if provided. |
| 50 | + * @param text - Will persist text if provided. |
| 51 | + * @returns The spinner instance. |
| 52 | + */ |
| 53 | + warn(text?: string): Loading; |
| 54 | + |
| 55 | + /** |
| 56 | + * Stop the spinner, change it to a blue `ℹ` and persist the current text, or `text` if provided. |
| 57 | + * @param text - Will persist text if provided. |
| 58 | + * @returns The spinner instance. |
| 59 | + */ |
| 60 | + info(text?: string): Loading; |
| 61 | + |
| 62 | + /** |
| 63 | + * Manually render a new frame. |
| 64 | + * @returns The spinner instance. |
| 65 | + */ |
| 66 | + render(): Loading; |
| 67 | + /** |
| 68 | + * Get a new frame. |
| 69 | + * @returns The spinner instance text. |
| 70 | + */ |
| 71 | + frame(): string; |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +declare const loading: { |
| 76 | + (options?: loading.Options | string): loading.Loading; |
| 77 | +} |
| 78 | + |
| 79 | + |
| 80 | +export = loading; |
0 commit comments