@oscarpalmer/timer 0.46.0 → 0.48.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/dist/constants.d.mts +2 -1
- package/dist/constants.mjs +2 -1
- package/dist/global.mjs +3 -2
- package/dist/index.d.mts +18 -13
- package/dist/index.mjs +13 -6
- package/dist/is.d.mts +8 -4
- package/dist/is.mjs +8 -4
- package/dist/repeat.d.mts +1 -1
- package/dist/repeat.mjs +1 -1
- package/dist/wait.d.mts +1 -0
- package/dist/wait.mjs +1 -0
- package/package.json +8 -4
- package/src/constants.ts +2 -0
- package/src/global.ts +11 -6
- package/src/is.ts +8 -4
- package/src/repeat.ts +1 -1
- package/src/wait.ts +1 -0
package/dist/constants.d.mts
CHANGED
|
@@ -5,6 +5,7 @@ import { TimerName, TimerStates, WorkHandlerType } from "./models.mjs";
|
|
|
5
5
|
*/
|
|
6
6
|
declare const BUFFER_INTERVAL = 5;
|
|
7
7
|
declare const DEFAULT_TIMEOUT = 30000;
|
|
8
|
+
declare const GLOBAL_NAME = "_oscarpalmer_timers";
|
|
8
9
|
/**
|
|
9
10
|
* Message to show when a when-timer is started
|
|
10
11
|
*/
|
|
@@ -19,4 +20,4 @@ declare const WORK_RESTART: WorkHandlerType;
|
|
|
19
20
|
declare const WORK_START: WorkHandlerType;
|
|
20
21
|
declare const WORK_STOP: WorkHandlerType;
|
|
21
22
|
//#endregion
|
|
22
|
-
export { BUFFER_INTERVAL, DEFAULT_TIMEOUT, MESSAGE_STARTED, STATES, TYPE_REPEAT, TYPE_WAIT, TYPE_WHEN, WORK_CONTINUE, WORK_PAUSE, WORK_RESTART, WORK_START, WORK_STOP };
|
|
23
|
+
export { BUFFER_INTERVAL, DEFAULT_TIMEOUT, GLOBAL_NAME, MESSAGE_STARTED, STATES, TYPE_REPEAT, TYPE_WAIT, TYPE_WHEN, WORK_CONTINUE, WORK_PAUSE, WORK_RESTART, WORK_START, WORK_STOP };
|
package/dist/constants.mjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
const BUFFER_INTERVAL = 5;
|
|
6
6
|
const DEFAULT_TIMEOUT = 3e4;
|
|
7
|
+
const GLOBAL_NAME = "_oscarpalmer_timers";
|
|
7
8
|
/**
|
|
8
9
|
* Message to show when a when-timer is started
|
|
9
10
|
*/
|
|
@@ -21,4 +22,4 @@ const WORK_RESTART = "restart";
|
|
|
21
22
|
const WORK_START = "start";
|
|
22
23
|
const WORK_STOP = "stop";
|
|
23
24
|
//#endregion
|
|
24
|
-
export { BUFFER_INTERVAL, DEFAULT_TIMEOUT, MESSAGE_STARTED, STATES, TYPE_REPEAT, TYPE_WAIT, TYPE_WHEN, WORK_CONTINUE, WORK_PAUSE, WORK_RESTART, WORK_START, WORK_STOP };
|
|
25
|
+
export { BUFFER_INTERVAL, DEFAULT_TIMEOUT, GLOBAL_NAME, MESSAGE_STARTED, STATES, TYPE_REPEAT, TYPE_WAIT, TYPE_WHEN, WORK_CONTINUE, WORK_PAUSE, WORK_RESTART, WORK_START, WORK_STOP };
|
package/dist/global.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { STATES } from "./constants.mjs";
|
|
1
|
+
import { GLOBAL_NAME, STATES } from "./constants.mjs";
|
|
2
2
|
import { onVisibilityChange } from "./misc.mjs";
|
|
3
3
|
//#region src/global.ts
|
|
4
|
-
|
|
4
|
+
/* istanbul ignore next */
|
|
5
|
+
if (!("_oscarpalmer_timers" in globalThis)) Object.defineProperty(globalThis, GLOBAL_NAME, { get() {
|
|
5
6
|
return globalThis._oscarpalmer_timer_debug ? [...STATES.active].map((state) => state.timer) : [];
|
|
6
7
|
} });
|
|
7
8
|
document.addEventListener("visibilitychange", onVisibilityChange);
|
package/dist/index.d.mts
CHANGED
|
@@ -152,28 +152,32 @@ declare global {
|
|
|
152
152
|
//#region src/is.d.ts
|
|
153
153
|
/**
|
|
154
154
|
* Is the value a repeating timer?
|
|
155
|
+
*
|
|
155
156
|
* @param value Value to check
|
|
156
|
-
* @returns `true` if the value is a repeating timer
|
|
157
|
+
* @returns `true` if the value is a repeating timer, otherwise `false`
|
|
157
158
|
*/
|
|
158
|
-
declare function isRepeated(value: unknown): value is Timer;
|
|
159
|
+
export declare function isRepeated(value: unknown): value is Timer;
|
|
159
160
|
/**
|
|
160
161
|
* Is the value a timer?
|
|
162
|
+
*
|
|
161
163
|
* @param value Value to check
|
|
162
|
-
* @returns `true` if the value is a timer
|
|
164
|
+
* @returns `true` if the value is a timer, otherwise `false`
|
|
163
165
|
*/
|
|
164
|
-
declare function isTimer(value: unknown): value is Timer;
|
|
166
|
+
export declare function isTimer(value: unknown): value is Timer;
|
|
165
167
|
/**
|
|
166
168
|
* Is the value a waiting timer?
|
|
169
|
+
*
|
|
167
170
|
* @param value Value to check
|
|
168
|
-
* @returns `true` if the value is a waiting timer
|
|
171
|
+
* @returns `true` if the value is a waiting timer, otherwise `false`
|
|
169
172
|
*/
|
|
170
|
-
declare function isWaited(value: unknown): value is Timer;
|
|
173
|
+
export declare function isWaited(value: unknown): value is Timer;
|
|
171
174
|
/**
|
|
172
175
|
* Is the value a conditional timer?
|
|
176
|
+
*
|
|
173
177
|
* @param value Value to check
|
|
174
|
-
* @returns `true` if the value is a conditional timer
|
|
178
|
+
* @returns `true` if the value is a conditional timer, otherwise `false`
|
|
175
179
|
*/
|
|
176
|
-
declare function isWhen(value: unknown): value is When;
|
|
180
|
+
export declare function isWhen(value: unknown): value is When;
|
|
177
181
|
//#endregion
|
|
178
182
|
//#region src/repeat.d.ts
|
|
179
183
|
/**
|
|
@@ -181,9 +185,9 @@ declare function isWhen(value: unknown): value is When;
|
|
|
181
185
|
*
|
|
182
186
|
* @param callback Callback to run on each interval
|
|
183
187
|
* @param options Timer options
|
|
184
|
-
* @returns
|
|
188
|
+
* @returns Repeating timer
|
|
185
189
|
*/
|
|
186
|
-
declare function repeat(callback: (index: number) => void, options?: Partial<RepeatOptions>): Timer;
|
|
190
|
+
export declare function repeat(callback: (index: number) => void, options?: Partial<RepeatOptions>): Timer;
|
|
187
191
|
//#endregion
|
|
188
192
|
//#region src/wait.d.ts
|
|
189
193
|
/**
|
|
@@ -191,8 +195,9 @@ declare function repeat(callback: (index: number) => void, options?: Partial<Rep
|
|
|
191
195
|
*
|
|
192
196
|
* @param callback Callback to run when the timer has finished
|
|
193
197
|
* @param time How long to wait for _(in milliseconds; defaults to screen refresh rate)_
|
|
198
|
+
* @returns Waiting timer
|
|
194
199
|
*/
|
|
195
|
-
declare function wait(callback: () => void, time?: number): Timer;
|
|
200
|
+
export declare function wait(callback: () => void, time?: number): Timer;
|
|
196
201
|
//#endregion
|
|
197
202
|
//#region src/when.d.ts
|
|
198
203
|
/**
|
|
@@ -201,6 +206,6 @@ declare function wait(callback: () => void, time?: number): Timer;
|
|
|
201
206
|
* @param options Timer options
|
|
202
207
|
* @returns Timer instance
|
|
203
208
|
*/
|
|
204
|
-
declare function when(condition: () => boolean, options?: Partial<WhenOptions>): When;
|
|
209
|
+
export declare function when(condition: () => boolean, options?: Partial<WhenOptions>): When;
|
|
205
210
|
//#endregion
|
|
206
|
-
export {
|
|
211
|
+
export type { RepeatOptions, Timer, TimerOptions, When, WhenOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region src/constants.ts
|
|
2
2
|
const DEFAULT_TIMEOUT = 3e4;
|
|
3
|
+
const GLOBAL_NAME = "_oscarpalmer_timers";
|
|
3
4
|
/**
|
|
4
5
|
* Message to show when a when-timer is started
|
|
5
6
|
*/
|
|
@@ -129,7 +130,8 @@ function updateStates(state, hide) {
|
|
|
129
130
|
}
|
|
130
131
|
//#endregion
|
|
131
132
|
//#region src/global.ts
|
|
132
|
-
|
|
133
|
+
/* istanbul ignore next */
|
|
134
|
+
if (!("_oscarpalmer_timers" in globalThis)) Object.defineProperty(globalThis, GLOBAL_NAME, { get() {
|
|
133
135
|
return globalThis._oscarpalmer_timer_debug ? [...STATES.active].map((state) => state.timer) : [];
|
|
134
136
|
} });
|
|
135
137
|
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
@@ -140,32 +142,36 @@ function is(names, value) {
|
|
|
140
142
|
}
|
|
141
143
|
/**
|
|
142
144
|
* Is the value a repeating timer?
|
|
145
|
+
*
|
|
143
146
|
* @param value Value to check
|
|
144
|
-
* @returns `true` if the value is a repeating timer
|
|
147
|
+
* @returns `true` if the value is a repeating timer, otherwise `false`
|
|
145
148
|
*/
|
|
146
149
|
function isRepeated(value) {
|
|
147
150
|
return is([TYPE_REPEAT], value);
|
|
148
151
|
}
|
|
149
152
|
/**
|
|
150
153
|
* Is the value a timer?
|
|
154
|
+
*
|
|
151
155
|
* @param value Value to check
|
|
152
|
-
* @returns `true` if the value is a timer
|
|
156
|
+
* @returns `true` if the value is a timer, otherwise `false`
|
|
153
157
|
*/
|
|
154
158
|
function isTimer(value) {
|
|
155
159
|
return is([TYPE_REPEAT, TYPE_WAIT], value);
|
|
156
160
|
}
|
|
157
161
|
/**
|
|
158
162
|
* Is the value a waiting timer?
|
|
163
|
+
*
|
|
159
164
|
* @param value Value to check
|
|
160
|
-
* @returns `true` if the value is a waiting timer
|
|
165
|
+
* @returns `true` if the value is a waiting timer, otherwise `false`
|
|
161
166
|
*/
|
|
162
167
|
function isWaited(value) {
|
|
163
168
|
return is([TYPE_WAIT], value);
|
|
164
169
|
}
|
|
165
170
|
/**
|
|
166
171
|
* Is the value a conditional timer?
|
|
172
|
+
*
|
|
167
173
|
* @param value Value to check
|
|
168
|
-
* @returns `true` if the value is a conditional timer
|
|
174
|
+
* @returns `true` if the value is a conditional timer, otherwise `false`
|
|
169
175
|
*/
|
|
170
176
|
function isWhen(value) {
|
|
171
177
|
return is(["when"], value) && typeof value.start === "function";
|
|
@@ -235,7 +241,7 @@ function createTimer(name, pick, options, start) {
|
|
|
235
241
|
*
|
|
236
242
|
* @param callback Callback to run on each interval
|
|
237
243
|
* @param options Timer options
|
|
238
|
-
* @returns
|
|
244
|
+
* @returns Repeating timer
|
|
239
245
|
*/
|
|
240
246
|
function repeat(callback, options) {
|
|
241
247
|
return createTimer(TYPE_REPEAT, {
|
|
@@ -256,6 +262,7 @@ function repeat(callback, options) {
|
|
|
256
262
|
*
|
|
257
263
|
* @param callback Callback to run when the timer has finished
|
|
258
264
|
* @param time How long to wait for _(in milliseconds; defaults to screen refresh rate)_
|
|
265
|
+
* @returns Waiting timer
|
|
259
266
|
*/
|
|
260
267
|
function wait(callback, time) {
|
|
261
268
|
return createTimer(TYPE_WAIT, {
|
package/dist/is.d.mts
CHANGED
|
@@ -2,26 +2,30 @@ import { Timer, When } from "./models.mjs";
|
|
|
2
2
|
//#region src/is.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Is the value a repeating timer?
|
|
5
|
+
*
|
|
5
6
|
* @param value Value to check
|
|
6
|
-
* @returns `true` if the value is a repeating timer
|
|
7
|
+
* @returns `true` if the value is a repeating timer, otherwise `false`
|
|
7
8
|
*/
|
|
8
9
|
declare function isRepeated(value: unknown): value is Timer;
|
|
9
10
|
/**
|
|
10
11
|
* Is the value a timer?
|
|
12
|
+
*
|
|
11
13
|
* @param value Value to check
|
|
12
|
-
* @returns `true` if the value is a timer
|
|
14
|
+
* @returns `true` if the value is a timer, otherwise `false`
|
|
13
15
|
*/
|
|
14
16
|
declare function isTimer(value: unknown): value is Timer;
|
|
15
17
|
/**
|
|
16
18
|
* Is the value a waiting timer?
|
|
19
|
+
*
|
|
17
20
|
* @param value Value to check
|
|
18
|
-
* @returns `true` if the value is a waiting timer
|
|
21
|
+
* @returns `true` if the value is a waiting timer, otherwise `false`
|
|
19
22
|
*/
|
|
20
23
|
declare function isWaited(value: unknown): value is Timer;
|
|
21
24
|
/**
|
|
22
25
|
* Is the value a conditional timer?
|
|
26
|
+
*
|
|
23
27
|
* @param value Value to check
|
|
24
|
-
* @returns `true` if the value is a conditional timer
|
|
28
|
+
* @returns `true` if the value is a conditional timer, otherwise `false`
|
|
25
29
|
*/
|
|
26
30
|
declare function isWhen(value: unknown): value is When;
|
|
27
31
|
//#endregion
|
package/dist/is.mjs
CHANGED
|
@@ -5,32 +5,36 @@ function is(names, value) {
|
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Is the value a repeating timer?
|
|
8
|
+
*
|
|
8
9
|
* @param value Value to check
|
|
9
|
-
* @returns `true` if the value is a repeating timer
|
|
10
|
+
* @returns `true` if the value is a repeating timer, otherwise `false`
|
|
10
11
|
*/
|
|
11
12
|
function isRepeated(value) {
|
|
12
13
|
return is([TYPE_REPEAT], value);
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Is the value a timer?
|
|
17
|
+
*
|
|
16
18
|
* @param value Value to check
|
|
17
|
-
* @returns `true` if the value is a timer
|
|
19
|
+
* @returns `true` if the value is a timer, otherwise `false`
|
|
18
20
|
*/
|
|
19
21
|
function isTimer(value) {
|
|
20
22
|
return is([TYPE_REPEAT, TYPE_WAIT], value);
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Is the value a waiting timer?
|
|
26
|
+
*
|
|
24
27
|
* @param value Value to check
|
|
25
|
-
* @returns `true` if the value is a waiting timer
|
|
28
|
+
* @returns `true` if the value is a waiting timer, otherwise `false`
|
|
26
29
|
*/
|
|
27
30
|
function isWaited(value) {
|
|
28
31
|
return is([TYPE_WAIT], value);
|
|
29
32
|
}
|
|
30
33
|
/**
|
|
31
34
|
* Is the value a conditional timer?
|
|
35
|
+
*
|
|
32
36
|
* @param value Value to check
|
|
33
|
-
* @returns `true` if the value is a conditional timer
|
|
37
|
+
* @returns `true` if the value is a conditional timer, otherwise `false`
|
|
34
38
|
*/
|
|
35
39
|
function isWhen(value) {
|
|
36
40
|
return is(["when"], value) && typeof value.start === "function";
|
package/dist/repeat.d.mts
CHANGED
|
@@ -6,7 +6,7 @@ import "./global.mjs";
|
|
|
6
6
|
*
|
|
7
7
|
* @param callback Callback to run on each interval
|
|
8
8
|
* @param options Timer options
|
|
9
|
-
* @returns
|
|
9
|
+
* @returns Repeating timer
|
|
10
10
|
*/
|
|
11
11
|
declare function repeat(callback: (index: number) => void, options?: Partial<RepeatOptions>): Timer;
|
|
12
12
|
//#endregion
|
package/dist/repeat.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { createTimer } from "./timer.mjs";
|
|
|
9
9
|
*
|
|
10
10
|
* @param callback Callback to run on each interval
|
|
11
11
|
* @param options Timer options
|
|
12
|
-
* @returns
|
|
12
|
+
* @returns Repeating timer
|
|
13
13
|
*/
|
|
14
14
|
function repeat(callback, options) {
|
|
15
15
|
return createTimer(TYPE_REPEAT, {
|
package/dist/wait.d.mts
CHANGED
|
@@ -6,6 +6,7 @@ import "./global.mjs";
|
|
|
6
6
|
*
|
|
7
7
|
* @param callback Callback to run when the timer has finished
|
|
8
8
|
* @param time How long to wait for _(in milliseconds; defaults to screen refresh rate)_
|
|
9
|
+
* @returns Waiting timer
|
|
9
10
|
*/
|
|
10
11
|
declare function wait(callback: () => void, time?: number): Timer;
|
|
11
12
|
//#endregion
|
package/dist/wait.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { createTimer } from "./timer.mjs";
|
|
|
9
9
|
*
|
|
10
10
|
* @param callback Callback to run when the timer has finished
|
|
11
11
|
* @param time How long to wait for _(in milliseconds; defaults to screen refresh rate)_
|
|
12
|
+
* @returns Waiting timer
|
|
12
13
|
*/
|
|
13
14
|
function wait(callback, time) {
|
|
14
15
|
return createTimer(TYPE_WAIT, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oscarpalmer/timer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"description": "A better solution for timeout- and interval-based timers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"requestAnimationFrame",
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"types": "./dist/index.d.mts",
|
|
31
31
|
"default": "./dist/index.mjs"
|
|
32
32
|
},
|
|
33
|
+
"./is": {
|
|
34
|
+
"types": "./dist/is.d.mts",
|
|
35
|
+
"default": "./dist/is.mjs"
|
|
36
|
+
},
|
|
33
37
|
"./models": {
|
|
34
38
|
"types": "./dist/models.d.mts",
|
|
35
39
|
"default": "./dist/models.mjs"
|
|
@@ -56,14 +60,14 @@
|
|
|
56
60
|
"watch": "npx vite build --watch"
|
|
57
61
|
},
|
|
58
62
|
"dependencies": {
|
|
59
|
-
"@oscarpalmer/atoms": "^0.
|
|
63
|
+
"@oscarpalmer/atoms": "^0.199"
|
|
60
64
|
},
|
|
61
65
|
"devDependencies": {
|
|
62
|
-
"@oxlint/plugins": "^1.
|
|
66
|
+
"@oxlint/plugins": "^1.81",
|
|
63
67
|
"@types/node": "^26.4",
|
|
64
68
|
"@vitest/coverage-istanbul": "^4.1",
|
|
65
69
|
"jsdom": "^30",
|
|
66
|
-
"tsdown": "^0.
|
|
70
|
+
"tsdown": "^0.23",
|
|
67
71
|
"typescript": "^6",
|
|
68
72
|
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
|
|
69
73
|
"vite-plus": "latest",
|
package/src/constants.ts
CHANGED
package/src/global.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {STATES} from './constants';
|
|
1
|
+
import {GLOBAL_NAME, STATES} from './constants';
|
|
2
2
|
import {onVisibilityChange} from './misc';
|
|
3
3
|
import type {Timer} from './models';
|
|
4
4
|
|
|
@@ -10,10 +10,15 @@ declare global {
|
|
|
10
10
|
var _oscarpalmer_timers: Timer[] | undefined;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
/* istanbul ignore next */
|
|
14
|
+
if (!(GLOBAL_NAME in globalThis)) {
|
|
15
|
+
Object.defineProperty(globalThis, GLOBAL_NAME, {
|
|
16
|
+
get() {
|
|
17
|
+
return globalThis._oscarpalmer_timer_debug
|
|
18
|
+
? [...STATES.active].map(state => state.timer)
|
|
19
|
+
: [];
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
18
23
|
|
|
19
24
|
document.addEventListener('visibilitychange', onVisibilityChange);
|
package/src/is.ts
CHANGED
|
@@ -8,8 +8,9 @@ function is(names: string[], value: unknown) {
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Is the value a repeating timer?
|
|
11
|
+
*
|
|
11
12
|
* @param value Value to check
|
|
12
|
-
* @returns `true` if the value is a repeating timer
|
|
13
|
+
* @returns `true` if the value is a repeating timer, otherwise `false`
|
|
13
14
|
*/
|
|
14
15
|
export function isRepeated(value: unknown): value is Timer {
|
|
15
16
|
return is([TYPE_REPEAT], value);
|
|
@@ -17,8 +18,9 @@ export function isRepeated(value: unknown): value is Timer {
|
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Is the value a timer?
|
|
21
|
+
*
|
|
20
22
|
* @param value Value to check
|
|
21
|
-
* @returns `true` if the value is a timer
|
|
23
|
+
* @returns `true` if the value is a timer, otherwise `false`
|
|
22
24
|
*/
|
|
23
25
|
export function isTimer(value: unknown): value is Timer {
|
|
24
26
|
return is([TYPE_REPEAT, TYPE_WAIT], value);
|
|
@@ -26,8 +28,9 @@ export function isTimer(value: unknown): value is Timer {
|
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* Is the value a waiting timer?
|
|
31
|
+
*
|
|
29
32
|
* @param value Value to check
|
|
30
|
-
* @returns `true` if the value is a waiting timer
|
|
33
|
+
* @returns `true` if the value is a waiting timer, otherwise `false`
|
|
31
34
|
*/
|
|
32
35
|
export function isWaited(value: unknown): value is Timer {
|
|
33
36
|
return is([TYPE_WAIT], value);
|
|
@@ -35,8 +38,9 @@ export function isWaited(value: unknown): value is Timer {
|
|
|
35
38
|
|
|
36
39
|
/**
|
|
37
40
|
* Is the value a conditional timer?
|
|
41
|
+
*
|
|
38
42
|
* @param value Value to check
|
|
39
|
-
* @returns `true` if the value is a conditional timer
|
|
43
|
+
* @returns `true` if the value is a conditional timer, otherwise `false`
|
|
40
44
|
*/
|
|
41
45
|
export function isWhen(value: unknown): value is When {
|
|
42
46
|
return is([TYPE_WHEN], value) && typeof (value as When).start === 'function';
|
package/src/repeat.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {createTimer} from './timer';
|
|
|
9
9
|
*
|
|
10
10
|
* @param callback Callback to run on each interval
|
|
11
11
|
* @param options Timer options
|
|
12
|
-
* @returns
|
|
12
|
+
* @returns Repeating timer
|
|
13
13
|
*/
|
|
14
14
|
export function repeat(callback: (index: number) => void, options?: Partial<RepeatOptions>): Timer {
|
|
15
15
|
return createTimer(
|
package/src/wait.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {createTimer} from './timer';
|
|
|
9
9
|
*
|
|
10
10
|
* @param callback Callback to run when the timer has finished
|
|
11
11
|
* @param time How long to wait for _(in milliseconds; defaults to screen refresh rate)_
|
|
12
|
+
* @returns Waiting timer
|
|
12
13
|
*/
|
|
13
14
|
export function wait(callback: () => void, time?: number): Timer {
|
|
14
15
|
return createTimer(
|