Skip to content

Commit a51a351

Browse files
committed
Add type file.
1 parent d4cd3a3 commit a51a351

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

index.d.ts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"command-line"
3232
],
3333
"files": [
34-
"lib"
34+
"lib",
35+
"index.d.ts"
3536
],
3637
"author": "kenny wang <[email protected]>",
3738
"license": "MIT",

0 commit comments

Comments
 (0)