/
index.d.ts
64 lines (63 loc) · 1.16 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
declare function ejectPromise<T extends any = void>(): Promise<T> & {
resolve: (_: T) => void
reject: (_: any) => void
}
declare function wait(
timeout: number,
): Promise<void> & {
resolve: (_: void) => void
reject: (_: any) => void
} & {
stop: () => void
}
interface WaitUntilOptions {
/**
* @default 10000
* */
timeout?: number
/**
* @desc whether resolve the promise that returned or not when timeout
* */
resolveTimeout?: boolean
/**
* @default 50
* */
interval?: number
}
interface WaitUntilCallbackParams {
/**
* @desc How many times has this until callback been executed, start with 0
* */
count: number
/**
* @desc The passed time since waitUntil been called
* */
passedTime: number
}
declare function waitUntil<T extends any>(
until: (params: WaitUntilCallbackParams) => T | Promise<T>,
options?: WaitUntilOptions,
): Promise<
| T
| {
timeout: true
}
> & {
resolve: (
_:
| T
| {
timeout: true
},
) => void
reject: (_: any) => void
} & {
cancel: () => void
}
export {
WaitUntilCallbackParams,
WaitUntilOptions,
ejectPromise,
wait,
waitUntil,
}