@oscarpalmer/timer 0.41.4 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/constants.d.mts +35 -0
- package/dist/{constants.js → constants.mjs} +2 -0
- package/dist/delay.d.mts +3 -0
- package/dist/delay.mjs +2 -0
- package/dist/get.d.mts +8 -0
- package/dist/{get.js → get.mjs} +3 -1
- package/dist/global.d.mts +7 -0
- package/dist/{global.js → global.mjs} +4 -1
- package/dist/index.d.mts +249 -0
- package/dist/{timer.full.js → index.mjs} +84 -55
- package/{types/is.d.ts → dist/is.d.mts} +10 -6
- package/dist/{is.js → is.mjs} +4 -2
- package/dist/models.d.mts +82 -0
- package/dist/{models.js → models.mjs} +2 -0
- package/dist/repeat.d.mts +13 -0
- package/dist/{repeat.js → repeat.mjs} +8 -5
- package/dist/timer.d.mts +52 -0
- package/dist/{timer.js → timer.mjs} +4 -2
- package/{types/wait.d.ts → dist/wait.d.mts} +6 -4
- package/dist/{wait.js → wait.mjs} +8 -5
- package/dist/when.d.mts +55 -0
- package/dist/{when.js → when.mjs} +10 -18
- package/dist/work.d.mts +8 -0
- package/dist/{work.js → work.mjs} +3 -1
- package/package.json +50 -52
- package/src/delay.ts +2 -1
- package/src/get.ts +1 -1
- package/src/is.ts +2 -2
- package/src/repeat.ts +1 -0
- package/src/wait.ts +1 -0
- package/src/when.ts +3 -15
- package/dist/delay.js +0 -2
- package/dist/index.js +0 -7
- package/types/constants.d.ts +0 -31
- package/types/delay.d.ts +0 -1
- package/types/get.d.ts +0 -4
- package/types/global.d.ts +0 -5
- package/types/index.d.ts +0 -235
- package/types/models.d.ts +0 -78
- package/types/repeat.d.ts +0 -11
- package/types/timer.d.ts +0 -48
- package/types/when.d.ts +0 -62
- package/types/work.d.ts +0 -4
package/types/constants.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { TimerType, WorkHandlerType } from './models';
|
|
2
|
-
import type { Timer } from './timer';
|
|
3
|
-
/**
|
|
4
|
-
* Buffer value to use when evaluating if a specific time is within a certain range
|
|
5
|
-
*/
|
|
6
|
-
export declare const BUFFER_INTERVAL = 5;
|
|
7
|
-
export declare const DEFAULT_TIMEOUT = 30000;
|
|
8
|
-
/**
|
|
9
|
-
* Message to show when a when-timer is destroyed
|
|
10
|
-
*/
|
|
11
|
-
export declare const MESSAGE_DESTROYED = "Timer has already been destroyed";
|
|
12
|
-
/**
|
|
13
|
-
* Message to show when a when-timer is started
|
|
14
|
-
*/
|
|
15
|
-
export declare const MESSAGE_STARTED = "Timer has already been started";
|
|
16
|
-
/**
|
|
17
|
-
* A set of all active timers
|
|
18
|
-
*/
|
|
19
|
-
export declare const TIMERS_ACTIVE: Set<Timer>;
|
|
20
|
-
/**
|
|
21
|
-
* A set of timers that were paused due to the document being hidden
|
|
22
|
-
*/
|
|
23
|
-
export declare const TIMERS_HIDDEN: Set<Timer>;
|
|
24
|
-
export declare const TYPE_REPEAT: TimerType;
|
|
25
|
-
export declare const TYPE_WAIT: TimerType;
|
|
26
|
-
export declare const TYPE_WHEN: TimerType;
|
|
27
|
-
export declare const WORK_CONTINUE: WorkHandlerType;
|
|
28
|
-
export declare const WORK_PAUSE: WorkHandlerType;
|
|
29
|
-
export declare const WORK_RESTART: WorkHandlerType;
|
|
30
|
-
export declare const WORK_START: WorkHandlerType;
|
|
31
|
-
export declare const WORK_STOP: WorkHandlerType;
|
package/types/delay.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { delay, type PromiseOptions } from '@oscarpalmer/atoms/promise';
|
package/types/get.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { GenericCallback } from '@oscarpalmer/atoms';
|
|
2
|
-
export declare function getCallback(value: unknown): GenericCallback;
|
|
3
|
-
export declare function getValidTimeout(value: unknown): number;
|
|
4
|
-
export declare function getValidNumber(value: unknown, defaultValue?: number): number;
|
package/types/global.d.ts
DELETED
package/types/index.d.ts
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
var _oscarpalmer_timer_debug: boolean | undefined;
|
|
3
|
-
var _oscarpalmer_timers: Timer[] | undefined;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
// Generated by dts-bundle-generator v9.5.1
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Options for a repeating timer
|
|
10
|
-
*/
|
|
11
|
-
export type RepeatOptions = {
|
|
12
|
-
/**
|
|
13
|
-
* Callback to be called when the timer has stopped, either manually or by completing its work
|
|
14
|
-
*/
|
|
15
|
-
onAfter: (finished: boolean) => void;
|
|
16
|
-
/**
|
|
17
|
-
* Callback to be called after the timer has timed out
|
|
18
|
-
*/
|
|
19
|
-
onTimeout: () => void;
|
|
20
|
-
/**
|
|
21
|
-
* How many times the timer should repeat
|
|
22
|
-
*/
|
|
23
|
-
count: number;
|
|
24
|
-
/**
|
|
25
|
-
* The interval between each repeat
|
|
26
|
-
*/
|
|
27
|
-
interval: number;
|
|
28
|
-
/**
|
|
29
|
-
* The timeout for the timer _(any value above `0` will enable the timeout)_
|
|
30
|
-
*/
|
|
31
|
-
timeout: number;
|
|
32
|
-
};
|
|
33
|
-
export type TimerOptions = {
|
|
34
|
-
onAfter: ((finished: boolean) => void) | undefined;
|
|
35
|
-
onError: (() => void) | undefined;
|
|
36
|
-
count: number;
|
|
37
|
-
interval: number;
|
|
38
|
-
timeout: number;
|
|
39
|
-
};
|
|
40
|
-
export type TimerState = {
|
|
41
|
-
active: boolean;
|
|
42
|
-
callback: () => void;
|
|
43
|
-
destroyed: boolean;
|
|
44
|
-
elapsed: number;
|
|
45
|
-
frame: number | undefined;
|
|
46
|
-
index: number;
|
|
47
|
-
paused: boolean;
|
|
48
|
-
total: number;
|
|
49
|
-
trace: string | undefined;
|
|
50
|
-
};
|
|
51
|
-
export type TimerType = "repeat" | "wait" | "when";
|
|
52
|
-
/**
|
|
53
|
-
* Options for a conditional timer
|
|
54
|
-
*/
|
|
55
|
-
export type WhenOptions = {
|
|
56
|
-
/**
|
|
57
|
-
* How many times the timer should check the condition
|
|
58
|
-
*/
|
|
59
|
-
count: number;
|
|
60
|
-
/**
|
|
61
|
-
* Then interval between each condtional check
|
|
62
|
-
*/
|
|
63
|
-
interval: number;
|
|
64
|
-
/**
|
|
65
|
-
* The timeout for the timer _(any value above `0` will enable the timeout)_
|
|
66
|
-
*/
|
|
67
|
-
timeout: number;
|
|
68
|
-
};
|
|
69
|
-
export declare class Timer {
|
|
70
|
-
#private;
|
|
71
|
-
protected readonly options: TimerOptions;
|
|
72
|
-
private readonly $timer;
|
|
73
|
-
protected readonly state: TimerState;
|
|
74
|
-
/**
|
|
75
|
-
* Is the timer active?
|
|
76
|
-
*/
|
|
77
|
-
get active(): boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Is the timer destroyed?
|
|
80
|
-
*/
|
|
81
|
-
get destroyed(): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Is the timer paused?
|
|
84
|
-
*/
|
|
85
|
-
get paused(): boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Get the timer's origin _(if debugging is enabled)_
|
|
88
|
-
*/
|
|
89
|
-
get trace(): string | undefined;
|
|
90
|
-
constructor(type: TimerType, state: Pick<TimerState, "callback" | "trace">, options: TimerOptions, start: boolean);
|
|
91
|
-
/**
|
|
92
|
-
* Continue running the timer _(if it's paused)_
|
|
93
|
-
*/
|
|
94
|
-
continue(): Timer;
|
|
95
|
-
/**
|
|
96
|
-
* Destroy the timer
|
|
97
|
-
*/
|
|
98
|
-
destroy(): void;
|
|
99
|
-
/**
|
|
100
|
-
* Pause the timer _(if it's running)_
|
|
101
|
-
*/
|
|
102
|
-
pause(): Timer;
|
|
103
|
-
/**
|
|
104
|
-
* Restart the timer _(or start it, if it's not running)_
|
|
105
|
-
*/
|
|
106
|
-
restart(): Timer;
|
|
107
|
-
/**
|
|
108
|
-
* Start the timer _(if it's not running)_
|
|
109
|
-
*/
|
|
110
|
-
start(): Timer;
|
|
111
|
-
/**
|
|
112
|
-
* Stop the timer _(if it's running)_
|
|
113
|
-
*/
|
|
114
|
-
stop(): Timer;
|
|
115
|
-
}
|
|
116
|
-
export type PromiseOptions = {
|
|
117
|
-
/**
|
|
118
|
-
* AbortSignal for aborting the promise; when aborted, the promise will reject with the reason of the signal
|
|
119
|
-
*/
|
|
120
|
-
signal?: AbortSignal;
|
|
121
|
-
/**
|
|
122
|
-
* How long to wait for (in milliseconds; defaults to `0`)
|
|
123
|
-
*/
|
|
124
|
-
time?: number;
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* Create a delayed promise that resolves after a certain amount of time, or rejects if aborted
|
|
128
|
-
* @param options Options for the delay
|
|
129
|
-
* @returns Delayed promise
|
|
130
|
-
*/
|
|
131
|
-
export declare function delay(options?: PromiseOptions): Promise<void>;
|
|
132
|
-
/**
|
|
133
|
-
* Create a delayed promise that resolves after a certain amount of time
|
|
134
|
-
* @param time How long to wait for _(in milliseconds; defaults to `0`)_
|
|
135
|
-
* @returns Delayed promise
|
|
136
|
-
*/
|
|
137
|
-
export declare function delay(time?: number): Promise<void>;
|
|
138
|
-
export declare class When {
|
|
139
|
-
private readonly $timer;
|
|
140
|
-
private readonly state;
|
|
141
|
-
/**
|
|
142
|
-
* Is the timer active?
|
|
143
|
-
*/
|
|
144
|
-
get active(): boolean;
|
|
145
|
-
/**
|
|
146
|
-
* Is the timer destroyed?
|
|
147
|
-
*/
|
|
148
|
-
get destroyed(): boolean;
|
|
149
|
-
/**
|
|
150
|
-
* Is the timer paused?
|
|
151
|
-
*/
|
|
152
|
-
get paused(): boolean;
|
|
153
|
-
/**
|
|
154
|
-
* Get the timer's origin _(if debugging is enabled)_
|
|
155
|
-
*/
|
|
156
|
-
get trace(): string | undefined;
|
|
157
|
-
constructor(condition: () => boolean, options?: Partial<WhenOptions>);
|
|
158
|
-
/**
|
|
159
|
-
* Continues the timer _(if it was paused)_
|
|
160
|
-
*/
|
|
161
|
-
continue(): When;
|
|
162
|
-
/**
|
|
163
|
-
* Destroys the timer _(and stops it,if it was running)_
|
|
164
|
-
*/
|
|
165
|
-
destroy(): void;
|
|
166
|
-
/**
|
|
167
|
-
* Pauses the timer _(if it was running)_
|
|
168
|
-
*/
|
|
169
|
-
pause(): When;
|
|
170
|
-
/**
|
|
171
|
-
* Start the timer
|
|
172
|
-
* @param resolve Optional resolve callback
|
|
173
|
-
* @param reject Optional reject callback
|
|
174
|
-
* @returns Promise that resolves when the condition is met
|
|
175
|
-
*/
|
|
176
|
-
start(resolve?: (() => void) | null, reject?: (() => void) | null): Promise<void>;
|
|
177
|
-
/**
|
|
178
|
-
* Stops the timer _(if it was running)_
|
|
179
|
-
*/
|
|
180
|
-
stop(): When;
|
|
181
|
-
/**
|
|
182
|
-
* Start the timer
|
|
183
|
-
* @deprecated Use `start()` instead
|
|
184
|
-
* @param resolve Optional resolve callback
|
|
185
|
-
* @param reject Optional reject callback
|
|
186
|
-
* @returns Promise that resolves when the condition is met
|
|
187
|
-
*/
|
|
188
|
-
then(resolve?: (() => void) | null, reject?: (() => void) | null): Promise<void>;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Create a conditional timer
|
|
192
|
-
* @param condition Condition to check
|
|
193
|
-
* @param options Timer options
|
|
194
|
-
* @returns Timer instance
|
|
195
|
-
*/
|
|
196
|
-
export declare function when(condition: () => boolean, options?: Partial<WhenOptions>): When;
|
|
197
|
-
/**
|
|
198
|
-
* Is the value a repeating timer?
|
|
199
|
-
* @param value Value to check
|
|
200
|
-
* @returns `true` if the value is a repeating timer
|
|
201
|
-
*/
|
|
202
|
-
export declare function isRepeated(value: unknown): value is Timer;
|
|
203
|
-
/**
|
|
204
|
-
* Is the value a timer?
|
|
205
|
-
* @param value Value to check
|
|
206
|
-
* @returns `true` if the value is a timer
|
|
207
|
-
*/
|
|
208
|
-
export declare function isTimer(value: unknown): value is Timer;
|
|
209
|
-
/**
|
|
210
|
-
* Is the value a waiting timer?
|
|
211
|
-
* @param value Value to check
|
|
212
|
-
* @returns `true` if the value is a waiting timer
|
|
213
|
-
*/
|
|
214
|
-
export declare function isWaited(value: unknown): value is Timer;
|
|
215
|
-
/**
|
|
216
|
-
* Is the value a conditional timer?
|
|
217
|
-
* @param value Value to check
|
|
218
|
-
* @returns `true` if the value is a conditional timer
|
|
219
|
-
*/
|
|
220
|
-
export declare function isWhen(value: unknown): value is When;
|
|
221
|
-
/**
|
|
222
|
-
* Create a repeating timer
|
|
223
|
-
* @param callback Callback to run on each interval
|
|
224
|
-
* @param options Timer options
|
|
225
|
-
* @returns Timer instance
|
|
226
|
-
*/
|
|
227
|
-
export declare function repeat(callback: (index: number) => void, options?: Partial<RepeatOptions>): Timer;
|
|
228
|
-
/**
|
|
229
|
-
* Create a waiting timer
|
|
230
|
-
* @param callback Callback to run when the timer has finished
|
|
231
|
-
* @param time How long to wait for _(in milliseconds; defaults to screen refresh rate)_
|
|
232
|
-
*/
|
|
233
|
-
export declare function wait(callback: () => void, time?: number): Timer;
|
|
234
|
-
|
|
235
|
-
export {};
|
package/types/models.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { Timer } from './timer';
|
|
2
|
-
/**
|
|
3
|
-
* Options for a repeating timer
|
|
4
|
-
*/
|
|
5
|
-
export type RepeatOptions = {
|
|
6
|
-
/**
|
|
7
|
-
* Callback to be called when the timer has stopped, either manually or by completing its work
|
|
8
|
-
*/
|
|
9
|
-
onAfter: (finished: boolean) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Callback to be called after the timer has timed out
|
|
12
|
-
*/
|
|
13
|
-
onTimeout: () => void;
|
|
14
|
-
/**
|
|
15
|
-
* How many times the timer should repeat
|
|
16
|
-
*/
|
|
17
|
-
count: number;
|
|
18
|
-
/**
|
|
19
|
-
* The interval between each repeat
|
|
20
|
-
*/
|
|
21
|
-
interval: number;
|
|
22
|
-
/**
|
|
23
|
-
* The timeout for the timer _(any value above `0` will enable the timeout)_
|
|
24
|
-
*/
|
|
25
|
-
timeout: number;
|
|
26
|
-
};
|
|
27
|
-
export type TimerOptions = {
|
|
28
|
-
onAfter: ((finished: boolean) => void) | undefined;
|
|
29
|
-
onError: (() => void) | undefined;
|
|
30
|
-
count: number;
|
|
31
|
-
interval: number;
|
|
32
|
-
timeout: number;
|
|
33
|
-
};
|
|
34
|
-
export type TimerState = {
|
|
35
|
-
active: boolean;
|
|
36
|
-
callback: () => void;
|
|
37
|
-
destroyed: boolean;
|
|
38
|
-
elapsed: number;
|
|
39
|
-
frame: number | undefined;
|
|
40
|
-
index: number;
|
|
41
|
-
paused: boolean;
|
|
42
|
-
total: number;
|
|
43
|
-
trace: string | undefined;
|
|
44
|
-
};
|
|
45
|
-
export declare class TimerTrace extends Error {
|
|
46
|
-
constructor();
|
|
47
|
-
}
|
|
48
|
-
export type TimerType = 'repeat' | 'wait' | 'when';
|
|
49
|
-
/**
|
|
50
|
-
* Options for a conditional timer
|
|
51
|
-
*/
|
|
52
|
-
export type WhenOptions = {
|
|
53
|
-
/**
|
|
54
|
-
* How many times the timer should check the condition
|
|
55
|
-
*/
|
|
56
|
-
count: number;
|
|
57
|
-
/**
|
|
58
|
-
* Then interval between each condtional check
|
|
59
|
-
*/
|
|
60
|
-
interval: number;
|
|
61
|
-
/**
|
|
62
|
-
* The timeout for the timer _(any value above `0` will enable the timeout)_
|
|
63
|
-
*/
|
|
64
|
-
timeout: number;
|
|
65
|
-
};
|
|
66
|
-
export type WhenState = {
|
|
67
|
-
promise: Promise<void>;
|
|
68
|
-
rejecter?: () => void;
|
|
69
|
-
resolver?: () => void;
|
|
70
|
-
started: boolean;
|
|
71
|
-
timer: Timer;
|
|
72
|
-
};
|
|
73
|
-
export type WorkHandler = (type: WorkHandlerType, timer: WorkHandlerTimer, state: TimerState, options: TimerOptions) => Timer;
|
|
74
|
-
export type WorkHandlerTimer = {
|
|
75
|
-
instance: Timer;
|
|
76
|
-
type: TimerType;
|
|
77
|
-
};
|
|
78
|
-
export type WorkHandlerType = 'continue' | 'pause' | 'restart' | 'start' | 'stop';
|
package/types/repeat.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import './global';
|
|
2
|
-
import { type RepeatOptions } from './models';
|
|
3
|
-
import { Timer } from './timer';
|
|
4
|
-
/**
|
|
5
|
-
* Create a repeating timer
|
|
6
|
-
* @param callback Callback to run on each interval
|
|
7
|
-
* @param options Timer options
|
|
8
|
-
* @returns Timer instance
|
|
9
|
-
*/
|
|
10
|
-
export declare function repeat(callback: (index: number) => void, options?: Partial<RepeatOptions>): Timer;
|
|
11
|
-
export type { RepeatOptions, Timer };
|
package/types/timer.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { TimerOptions, TimerState, TimerType } from './models';
|
|
2
|
-
export declare class Timer {
|
|
3
|
-
#private;
|
|
4
|
-
protected readonly options: TimerOptions;
|
|
5
|
-
private readonly $timer;
|
|
6
|
-
protected readonly state: TimerState;
|
|
7
|
-
/**
|
|
8
|
-
* Is the timer active?
|
|
9
|
-
*/
|
|
10
|
-
get active(): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Is the timer destroyed?
|
|
13
|
-
*/
|
|
14
|
-
get destroyed(): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Is the timer paused?
|
|
17
|
-
*/
|
|
18
|
-
get paused(): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Get the timer's origin _(if debugging is enabled)_
|
|
21
|
-
*/
|
|
22
|
-
get trace(): string | undefined;
|
|
23
|
-
constructor(type: TimerType, state: Pick<TimerState, 'callback' | 'trace'>, options: TimerOptions, start: boolean);
|
|
24
|
-
/**
|
|
25
|
-
* Continue running the timer _(if it's paused)_
|
|
26
|
-
*/
|
|
27
|
-
continue(): Timer;
|
|
28
|
-
/**
|
|
29
|
-
* Destroy the timer
|
|
30
|
-
*/
|
|
31
|
-
destroy(): void;
|
|
32
|
-
/**
|
|
33
|
-
* Pause the timer _(if it's running)_
|
|
34
|
-
*/
|
|
35
|
-
pause(): Timer;
|
|
36
|
-
/**
|
|
37
|
-
* Restart the timer _(or start it, if it's not running)_
|
|
38
|
-
*/
|
|
39
|
-
restart(): Timer;
|
|
40
|
-
/**
|
|
41
|
-
* Start the timer _(if it's not running)_
|
|
42
|
-
*/
|
|
43
|
-
start(): Timer;
|
|
44
|
-
/**
|
|
45
|
-
* Stop the timer _(if it's running)_
|
|
46
|
-
*/
|
|
47
|
-
stop(): Timer;
|
|
48
|
-
}
|
package/types/when.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import './global';
|
|
2
|
-
import { type WhenOptions } from './models';
|
|
3
|
-
declare class When {
|
|
4
|
-
private readonly $timer;
|
|
5
|
-
private readonly state;
|
|
6
|
-
/**
|
|
7
|
-
* Is the timer active?
|
|
8
|
-
*/
|
|
9
|
-
get active(): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Is the timer destroyed?
|
|
12
|
-
*/
|
|
13
|
-
get destroyed(): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Is the timer paused?
|
|
16
|
-
*/
|
|
17
|
-
get paused(): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Get the timer's origin _(if debugging is enabled)_
|
|
20
|
-
*/
|
|
21
|
-
get trace(): string | undefined;
|
|
22
|
-
constructor(condition: () => boolean, options?: Partial<WhenOptions>);
|
|
23
|
-
/**
|
|
24
|
-
* Continues the timer _(if it was paused)_
|
|
25
|
-
*/
|
|
26
|
-
continue(): When;
|
|
27
|
-
/**
|
|
28
|
-
* Destroys the timer _(and stops it,if it was running)_
|
|
29
|
-
*/
|
|
30
|
-
destroy(): void;
|
|
31
|
-
/**
|
|
32
|
-
* Pauses the timer _(if it was running)_
|
|
33
|
-
*/
|
|
34
|
-
pause(): When;
|
|
35
|
-
/**
|
|
36
|
-
* Start the timer
|
|
37
|
-
* @param resolve Optional resolve callback
|
|
38
|
-
* @param reject Optional reject callback
|
|
39
|
-
* @returns Promise that resolves when the condition is met
|
|
40
|
-
*/
|
|
41
|
-
start(resolve?: (() => void) | null, reject?: (() => void) | null): Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* Stops the timer _(if it was running)_
|
|
44
|
-
*/
|
|
45
|
-
stop(): When;
|
|
46
|
-
/**
|
|
47
|
-
* Start the timer
|
|
48
|
-
* @deprecated Use `start()` instead
|
|
49
|
-
* @param resolve Optional resolve callback
|
|
50
|
-
* @param reject Optional reject callback
|
|
51
|
-
* @returns Promise that resolves when the condition is met
|
|
52
|
-
*/
|
|
53
|
-
then(resolve?: (() => void) | null, reject?: (() => void) | null): Promise<void>;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Create a conditional timer
|
|
57
|
-
* @param condition Condition to check
|
|
58
|
-
* @param options Timer options
|
|
59
|
-
* @returns Timer instance
|
|
60
|
-
*/
|
|
61
|
-
export declare function when(condition: () => boolean, options?: Partial<WhenOptions>): When;
|
|
62
|
-
export type { When };
|
package/types/work.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { TimerOptions, TimerState, WorkHandlerTimer, WorkHandlerType } from './models';
|
|
2
|
-
import type { Timer } from './timer';
|
|
3
|
-
export declare function stop(timer: WorkHandlerTimer, state: TimerState, options: TimerOptions): Timer;
|
|
4
|
-
export declare function work(type: WorkHandlerType, timer: WorkHandlerTimer, state: TimerState, options: TimerOptions): Timer;
|