@oscarpalmer/timer 0.34.0 → 0.36.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.cjs +2 -0
- package/dist/constants.js +2 -1
- package/dist/get.cjs +7 -1
- package/dist/get.js +7 -2
- package/dist/repeat.cjs +2 -2
- package/dist/repeat.js +2 -2
- package/dist/timer.cjs +1 -0
- package/dist/timer.full.js +11 -5
- package/dist/timer.js +1 -0
- package/dist/when.cjs +1 -1
- package/dist/when.js +2 -2
- package/package.json +2 -2
- package/src/constants.ts +4 -0
- package/src/get.ts +9 -2
- package/src/models.ts +34 -26
- package/src/repeat.ts +2 -2
- package/src/when.ts +3 -2
- package/types/constants.d.cts +1 -0
- package/types/constants.d.ts +1 -0
- package/types/get.d.cts +1 -0
- package/types/get.d.ts +1 -0
- package/types/index.d.cts +10 -2
- package/types/is.d.cts +1 -1
- package/types/models.d.cts +10 -2
- package/types/models.d.ts +10 -2
- package/types/repeat.d.cts +9 -1
- package/types/when.d.cts +1 -1
package/dist/constants.cjs
CHANGED
|
@@ -13,6 +13,7 @@ function calculate() {
|
|
|
13
13
|
requestAnimationFrame(step);
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
+
const defaultTimeout = 3e4;
|
|
16
17
|
const activeTimers = /* @__PURE__ */ new Set();
|
|
17
18
|
const intervalBuffer = 5;
|
|
18
19
|
const destroyedMessage = "Timer has already been destroyed";
|
|
@@ -39,6 +40,7 @@ exports.WORK_RESTART = WORK_RESTART;
|
|
|
39
40
|
exports.WORK_START = WORK_START;
|
|
40
41
|
exports.WORK_STOP = WORK_STOP;
|
|
41
42
|
exports.activeTimers = activeTimers;
|
|
43
|
+
exports.defaultTimeout = defaultTimeout;
|
|
42
44
|
exports.destroyedMessage = destroyedMessage;
|
|
43
45
|
exports.hiddenTimers = hiddenTimers;
|
|
44
46
|
exports.intervalBuffer = intervalBuffer;
|
package/dist/constants.js
CHANGED
|
@@ -13,6 +13,7 @@ function calculate() {
|
|
|
13
13
|
requestAnimationFrame(step);
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
+
const defaultTimeout = 3e4;
|
|
16
17
|
const activeTimers = /* @__PURE__ */ new Set();
|
|
17
18
|
const intervalBuffer = 5;
|
|
18
19
|
const destroyedMessage = "Timer has already been destroyed";
|
|
@@ -30,4 +31,4 @@ let milliseconds = 1e3 / 60;
|
|
|
30
31
|
calculate().then((value) => {
|
|
31
32
|
milliseconds = value;
|
|
32
33
|
});
|
|
33
|
-
export { TYPE_REPEAT, TYPE_WAIT, TYPE_WHEN, WORK_CONTINUE, WORK_PAUSE, WORK_RESTART, WORK_START, WORK_STOP, activeTimers, destroyedMessage, hiddenTimers, intervalBuffer, milliseconds, startedMessage };
|
|
34
|
+
export { TYPE_REPEAT, TYPE_WAIT, TYPE_WHEN, WORK_CONTINUE, WORK_PAUSE, WORK_RESTART, WORK_START, WORK_STOP, activeTimers, defaultTimeout, destroyedMessage, hiddenTimers, intervalBuffer, milliseconds, startedMessage };
|
package/dist/get.cjs
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown_runtime.cjs");
|
|
2
|
+
const require_constants = require("./constants.cjs");
|
|
2
3
|
const __oscarpalmer_atoms_function = require_rolldown_runtime.__toESM(require("@oscarpalmer/atoms/function"));
|
|
3
4
|
function getCallback(value) {
|
|
4
5
|
return typeof value === "function" ? value : __oscarpalmer_atoms_function.noop;
|
|
5
6
|
}
|
|
7
|
+
function getValidTimeout(value) {
|
|
8
|
+
return typeof value === "number" && value > 0 ? value : require_constants.defaultTimeout;
|
|
9
|
+
}
|
|
6
10
|
function getValidNumber(value, defaultValue) {
|
|
7
|
-
|
|
11
|
+
const actualDefault = defaultValue ?? 0;
|
|
12
|
+
return typeof value === "number" && value > actualDefault ? value : actualDefault;
|
|
8
13
|
}
|
|
9
14
|
exports.getCallback = getCallback;
|
|
10
15
|
exports.getValidNumber = getValidNumber;
|
|
16
|
+
exports.getValidTimeout = getValidTimeout;
|
package/dist/get.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { defaultTimeout } from "./constants.js";
|
|
1
2
|
import { noop } from "@oscarpalmer/atoms/function";
|
|
2
3
|
function getCallback(value) {
|
|
3
4
|
return typeof value === "function" ? value : noop;
|
|
4
5
|
}
|
|
6
|
+
function getValidTimeout(value) {
|
|
7
|
+
return typeof value === "number" && value > 0 ? value : defaultTimeout;
|
|
8
|
+
}
|
|
5
9
|
function getValidNumber(value, defaultValue) {
|
|
6
|
-
|
|
10
|
+
const actualDefault = defaultValue ?? 0;
|
|
11
|
+
return typeof value === "number" && value > actualDefault ? value : actualDefault;
|
|
7
12
|
}
|
|
8
|
-
export { getCallback, getValidNumber };
|
|
13
|
+
export { getCallback, getValidNumber, getValidTimeout };
|
package/dist/repeat.cjs
CHANGED
|
@@ -9,10 +9,10 @@ function repeat(callback, options) {
|
|
|
9
9
|
trace: new require_models.TimerTrace().stack
|
|
10
10
|
}, {
|
|
11
11
|
onAfter: require_get.getCallback(options?.onAfter),
|
|
12
|
-
onError:
|
|
12
|
+
onError: require_get.getCallback(options?.onTimeout),
|
|
13
13
|
count: require_get.getValidNumber(options?.count),
|
|
14
14
|
interval: require_get.getValidNumber(options?.interval, require_constants.milliseconds),
|
|
15
|
-
timeout:
|
|
15
|
+
timeout: require_get.getValidNumber(options?.timeout)
|
|
16
16
|
}, true);
|
|
17
17
|
}
|
|
18
18
|
exports.repeat = repeat;
|
package/dist/repeat.js
CHANGED
|
@@ -9,10 +9,10 @@ function repeat(callback, options) {
|
|
|
9
9
|
trace: new TimerTrace().stack
|
|
10
10
|
}, {
|
|
11
11
|
onAfter: getCallback(options?.onAfter),
|
|
12
|
-
onError:
|
|
12
|
+
onError: getCallback(options?.onTimeout),
|
|
13
13
|
count: getValidNumber(options?.count),
|
|
14
14
|
interval: getValidNumber(options?.interval, milliseconds),
|
|
15
|
-
timeout:
|
|
15
|
+
timeout: getValidNumber(options?.timeout)
|
|
16
16
|
}, true);
|
|
17
17
|
}
|
|
18
18
|
export { repeat };
|
package/dist/timer.cjs
CHANGED
|
@@ -3,6 +3,7 @@ const require_constants = require("./constants.cjs");
|
|
|
3
3
|
const require_work = require("./work.cjs");
|
|
4
4
|
const __oscarpalmer_atoms_function = require_rolldown_runtime.__toESM(require("@oscarpalmer/atoms/function"));
|
|
5
5
|
var Timer = class {
|
|
6
|
+
state;
|
|
6
7
|
get active() {
|
|
7
8
|
return this.state.active;
|
|
8
9
|
}
|
package/dist/timer.full.js
CHANGED
|
@@ -22,6 +22,8 @@ function calculate$1() {
|
|
|
22
22
|
requestAnimationFrame(step);
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
+
//
|
|
26
|
+
const defaultTimeout = 30_000;
|
|
25
27
|
/**
|
|
26
28
|
* A set of all active timers
|
|
27
29
|
*/
|
|
@@ -98,10 +100,14 @@ calculate().then((value) => {
|
|
|
98
100
|
function getCallback(value) {
|
|
99
101
|
return typeof value === 'function' ? value : noop;
|
|
100
102
|
}
|
|
103
|
+
function getValidTimeout(value) {
|
|
104
|
+
return typeof value === 'number' && value > 0 ? value : defaultTimeout;
|
|
105
|
+
}
|
|
101
106
|
function getValidNumber(value, defaultValue) {
|
|
102
|
-
|
|
107
|
+
const actualDefault = defaultValue ?? 0;
|
|
108
|
+
return typeof value === 'number' && value > actualDefault
|
|
103
109
|
? value
|
|
104
|
-
:
|
|
110
|
+
: actualDefault;
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
/**
|
|
@@ -366,10 +372,10 @@ function repeat(callback, options) {
|
|
|
366
372
|
trace: new TimerTrace().stack,
|
|
367
373
|
}, {
|
|
368
374
|
onAfter: getCallback(options?.onAfter),
|
|
369
|
-
onError:
|
|
375
|
+
onError: getCallback(options?.onTimeout),
|
|
370
376
|
count: getValidNumber(options?.count),
|
|
371
377
|
interval: getValidNumber(options?.interval, milliseconds),
|
|
372
|
-
timeout:
|
|
378
|
+
timeout: getValidNumber(options?.timeout),
|
|
373
379
|
}, true);
|
|
374
380
|
}
|
|
375
381
|
|
|
@@ -462,7 +468,7 @@ class When {
|
|
|
462
468
|
},
|
|
463
469
|
count: getValidNumber(options?.count),
|
|
464
470
|
interval: getValidNumber(options?.interval, milliseconds),
|
|
465
|
-
timeout:
|
|
471
|
+
timeout: getValidTimeout(options?.timeout),
|
|
466
472
|
}, false);
|
|
467
473
|
}
|
|
468
474
|
/**
|
package/dist/timer.js
CHANGED
package/dist/when.cjs
CHANGED
|
@@ -57,7 +57,7 @@ var When = class {
|
|
|
57
57
|
},
|
|
58
58
|
count: require_get.getValidNumber(options?.count),
|
|
59
59
|
interval: require_get.getValidNumber(options?.interval, require_constants.milliseconds),
|
|
60
|
-
timeout: require_get.
|
|
60
|
+
timeout: require_get.getValidTimeout(options?.timeout)
|
|
61
61
|
}, false);
|
|
62
62
|
}
|
|
63
63
|
continue() {
|
package/dist/when.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TYPE_WHEN, destroyedMessage, milliseconds, startedMessage } from "./constants.js";
|
|
2
|
-
import { getValidNumber } from "./get.js";
|
|
2
|
+
import { getValidNumber, getValidTimeout } from "./get.js";
|
|
3
3
|
import "./global.js";
|
|
4
4
|
import { TimerTrace } from "./models.js";
|
|
5
5
|
import { Timer } from "./timer.js";
|
|
@@ -56,7 +56,7 @@ var When = class {
|
|
|
56
56
|
},
|
|
57
57
|
count: getValidNumber(options?.count),
|
|
58
58
|
interval: getValidNumber(options?.interval, milliseconds),
|
|
59
|
-
timeout:
|
|
59
|
+
timeout: getValidTimeout(options?.timeout)
|
|
60
60
|
}, false);
|
|
61
61
|
}
|
|
62
62
|
continue() {
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dts-bundle-generator": "^9.5",
|
|
17
17
|
"glob": "^11",
|
|
18
18
|
"jsdom": "^26.1",
|
|
19
|
-
"rollup": "^4.
|
|
19
|
+
"rollup": "^4.49",
|
|
20
20
|
"tslib": "^2.8",
|
|
21
21
|
"typescript": "^5.9",
|
|
22
22
|
"vite": "npm:rolldown-vite@latest",
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
},
|
|
96
96
|
"type": "module",
|
|
97
97
|
"types": "types/index.d.cts",
|
|
98
|
-
"version": "0.
|
|
98
|
+
"version": "0.36.0"
|
|
99
99
|
}
|
package/src/constants.ts
CHANGED
package/src/get.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import {noop} from '@oscarpalmer/atoms/function';
|
|
2
2
|
import type {GenericCallback} from '@oscarpalmer/atoms/models';
|
|
3
|
+
import {defaultTimeout} from './constants';
|
|
3
4
|
|
|
4
5
|
export function getCallback(value: unknown): GenericCallback {
|
|
5
6
|
return typeof value === 'function' ? (value as GenericCallback) : noop;
|
|
6
7
|
}
|
|
7
8
|
|
|
9
|
+
export function getValidTimeout(value: unknown): number {
|
|
10
|
+
return typeof value === 'number' && value > 0 ? value : defaultTimeout;
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
export function getValidNumber(value: unknown, defaultValue?: number): number {
|
|
9
|
-
|
|
14
|
+
const actualDefault = defaultValue ?? 0;
|
|
15
|
+
|
|
16
|
+
return typeof value === 'number' && value > actualDefault
|
|
10
17
|
? value
|
|
11
|
-
:
|
|
18
|
+
: actualDefault;
|
|
12
19
|
}
|
package/src/models.ts
CHANGED
|
@@ -4,19 +4,27 @@ import type {Timer} from './timer';
|
|
|
4
4
|
* Options for a repeating timer
|
|
5
5
|
*/
|
|
6
6
|
export type RepeatOptions = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Callback to be called when the timer has stopped, either manually or by completing its work
|
|
9
|
+
*/
|
|
10
|
+
onAfter: (finished: boolean) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Callback to be called after the timer has timed out
|
|
13
|
+
*/
|
|
14
|
+
onTimeout: () => void;
|
|
15
|
+
/**
|
|
16
|
+
* How many times the timer should repeat
|
|
17
|
+
*/
|
|
18
|
+
count: number;
|
|
19
|
+
/**
|
|
20
|
+
* The interval between each repeat
|
|
21
|
+
*/
|
|
22
|
+
interval: number;
|
|
23
|
+
/**
|
|
24
|
+
* The timeout for the timer _(any value above `0` will enable the timeout)_
|
|
25
|
+
*/
|
|
26
|
+
timeout: number;
|
|
27
|
+
};
|
|
20
28
|
|
|
21
29
|
export type TimerOptions = {
|
|
22
30
|
onAfter: ((finished: boolean) => void) | undefined;
|
|
@@ -52,19 +60,19 @@ export type TimerType = 'repeat' | 'wait' | 'when';
|
|
|
52
60
|
* Options for a conditional timer
|
|
53
61
|
*/
|
|
54
62
|
export type WhenOptions = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
};
|
|
63
|
+
/**
|
|
64
|
+
* How many times the timer should check the condition
|
|
65
|
+
*/
|
|
66
|
+
count: number;
|
|
67
|
+
/**
|
|
68
|
+
* Then interval between each condtional check
|
|
69
|
+
*/
|
|
70
|
+
interval: number;
|
|
71
|
+
/**
|
|
72
|
+
* The timeout for the timer _(any value above `0` will enable the timeout)_
|
|
73
|
+
*/
|
|
74
|
+
timeout: number;
|
|
75
|
+
};
|
|
68
76
|
|
|
69
77
|
export type WhenState = {
|
|
70
78
|
promise: Promise<void>;
|
package/src/repeat.ts
CHANGED
|
@@ -19,10 +19,10 @@ export function repeat(
|
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
onAfter: getCallback(options?.onAfter),
|
|
22
|
-
onError:
|
|
22
|
+
onError: getCallback(options?.onTimeout),
|
|
23
23
|
count: getValidNumber(options?.count),
|
|
24
24
|
interval: getValidNumber(options?.interval, milliseconds),
|
|
25
|
-
timeout:
|
|
25
|
+
timeout: getValidNumber(options?.timeout),
|
|
26
26
|
},
|
|
27
27
|
true,
|
|
28
28
|
);
|
package/src/when.ts
CHANGED
|
@@ -5,13 +5,14 @@ import {
|
|
|
5
5
|
startedMessage,
|
|
6
6
|
TYPE_WHEN,
|
|
7
7
|
} from './constants';
|
|
8
|
-
import {getValidNumber} from './get';
|
|
8
|
+
import {getValidNumber, getValidTimeout} from './get';
|
|
9
9
|
import './global';
|
|
10
10
|
import {TimerTrace, type WhenOptions, type WhenState} from './models';
|
|
11
11
|
import {Timer} from './timer';
|
|
12
12
|
|
|
13
13
|
class When {
|
|
14
14
|
private readonly $timer = TYPE_WHEN;
|
|
15
|
+
|
|
15
16
|
private readonly state: WhenState = {
|
|
16
17
|
promise: undefined as never,
|
|
17
18
|
rejecter: undefined as never,
|
|
@@ -93,7 +94,7 @@ class When {
|
|
|
93
94
|
},
|
|
94
95
|
count: getValidNumber(options?.count),
|
|
95
96
|
interval: getValidNumber(options?.interval, milliseconds),
|
|
96
|
-
timeout:
|
|
97
|
+
timeout: getValidTimeout(options?.timeout),
|
|
97
98
|
},
|
|
98
99
|
false,
|
|
99
100
|
);
|
package/types/constants.d.cts
CHANGED
|
@@ -67,6 +67,7 @@ export type TimerState = {
|
|
|
67
67
|
};
|
|
68
68
|
export type TimerType = "repeat" | "wait" | "when";
|
|
69
69
|
export type WorkHandlerType = "continue" | "pause" | "restart" | "start" | "stop";
|
|
70
|
+
export declare const defaultTimeout = 30000;
|
|
70
71
|
/**
|
|
71
72
|
* A set of all active timers
|
|
72
73
|
*/
|
package/types/constants.d.ts
CHANGED
package/types/get.d.cts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export type GenericCallback = (...args: any[]) => any;
|
|
7
7
|
export declare function getCallback(value: unknown): GenericCallback;
|
|
8
|
+
export declare function getValidTimeout(value: unknown): number;
|
|
8
9
|
export declare function getValidNumber(value: unknown, defaultValue?: number): number;
|
|
9
10
|
|
|
10
11
|
export {};
|
package/types/get.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { GenericCallback } from '@oscarpalmer/atoms/models';
|
|
2
2
|
export declare function getCallback(value: unknown): GenericCallback;
|
|
3
|
+
export declare function getValidTimeout(value: unknown): number;
|
|
3
4
|
export declare function getValidNumber(value: unknown, defaultValue?: number): number;
|
package/types/index.d.cts
CHANGED
|
@@ -54,7 +54,11 @@ export type RepeatOptions = {
|
|
|
54
54
|
/**
|
|
55
55
|
* Callback to be called when the timer has stopped, either manually or by completing its work
|
|
56
56
|
*/
|
|
57
|
-
onAfter: (
|
|
57
|
+
onAfter: (finished: boolean) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Callback to be called after the timer has timed out
|
|
60
|
+
*/
|
|
61
|
+
onTimeout: () => void;
|
|
58
62
|
/**
|
|
59
63
|
* How many times the timer should repeat
|
|
60
64
|
*/
|
|
@@ -63,6 +67,10 @@ export type RepeatOptions = {
|
|
|
63
67
|
* The interval between each repeat
|
|
64
68
|
*/
|
|
65
69
|
interval: number;
|
|
70
|
+
/**
|
|
71
|
+
* The timeout for the timer _(any value above `0` will enable the timeout)_
|
|
72
|
+
*/
|
|
73
|
+
timeout: number;
|
|
66
74
|
};
|
|
67
75
|
export type TimerOptions = {
|
|
68
76
|
onAfter: ((finished: boolean) => void) | undefined;
|
|
@@ -96,7 +104,7 @@ export type WhenOptions = {
|
|
|
96
104
|
*/
|
|
97
105
|
interval: number;
|
|
98
106
|
/**
|
|
99
|
-
* The timeout for the timer
|
|
107
|
+
* The timeout for the timer _(any value above `0` will enable the timeout)_
|
|
100
108
|
*/
|
|
101
109
|
timeout: number;
|
|
102
110
|
};
|
package/types/is.d.cts
CHANGED
package/types/models.d.cts
CHANGED
|
@@ -54,7 +54,11 @@ export type RepeatOptions = {
|
|
|
54
54
|
/**
|
|
55
55
|
* Callback to be called when the timer has stopped, either manually or by completing its work
|
|
56
56
|
*/
|
|
57
|
-
onAfter: (
|
|
57
|
+
onAfter: (finished: boolean) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Callback to be called after the timer has timed out
|
|
60
|
+
*/
|
|
61
|
+
onTimeout: () => void;
|
|
58
62
|
/**
|
|
59
63
|
* How many times the timer should repeat
|
|
60
64
|
*/
|
|
@@ -63,6 +67,10 @@ export type RepeatOptions = {
|
|
|
63
67
|
* The interval between each repeat
|
|
64
68
|
*/
|
|
65
69
|
interval: number;
|
|
70
|
+
/**
|
|
71
|
+
* The timeout for the timer _(any value above `0` will enable the timeout)_
|
|
72
|
+
*/
|
|
73
|
+
timeout: number;
|
|
66
74
|
};
|
|
67
75
|
export type TimerOptions = {
|
|
68
76
|
onAfter: ((finished: boolean) => void) | undefined;
|
|
@@ -99,7 +107,7 @@ export type WhenOptions = {
|
|
|
99
107
|
*/
|
|
100
108
|
interval: number;
|
|
101
109
|
/**
|
|
102
|
-
* The timeout for the timer
|
|
110
|
+
* The timeout for the timer _(any value above `0` will enable the timeout)_
|
|
103
111
|
*/
|
|
104
112
|
timeout: number;
|
|
105
113
|
};
|
package/types/models.d.ts
CHANGED
|
@@ -6,7 +6,11 @@ export type RepeatOptions = {
|
|
|
6
6
|
/**
|
|
7
7
|
* Callback to be called when the timer has stopped, either manually or by completing its work
|
|
8
8
|
*/
|
|
9
|
-
onAfter: (
|
|
9
|
+
onAfter: (finished: boolean) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Callback to be called after the timer has timed out
|
|
12
|
+
*/
|
|
13
|
+
onTimeout: () => void;
|
|
10
14
|
/**
|
|
11
15
|
* How many times the timer should repeat
|
|
12
16
|
*/
|
|
@@ -15,6 +19,10 @@ export type RepeatOptions = {
|
|
|
15
19
|
* The interval between each repeat
|
|
16
20
|
*/
|
|
17
21
|
interval: number;
|
|
22
|
+
/**
|
|
23
|
+
* The timeout for the timer _(any value above `0` will enable the timeout)_
|
|
24
|
+
*/
|
|
25
|
+
timeout: number;
|
|
18
26
|
};
|
|
19
27
|
export type TimerOptions = {
|
|
20
28
|
onAfter: ((finished: boolean) => void) | undefined;
|
|
@@ -51,7 +59,7 @@ export type WhenOptions = {
|
|
|
51
59
|
*/
|
|
52
60
|
interval: number;
|
|
53
61
|
/**
|
|
54
|
-
* The timeout for the timer
|
|
62
|
+
* The timeout for the timer _(any value above `0` will enable the timeout)_
|
|
55
63
|
*/
|
|
56
64
|
timeout: number;
|
|
57
65
|
};
|
package/types/repeat.d.cts
CHANGED
|
@@ -54,7 +54,11 @@ export type RepeatOptions = {
|
|
|
54
54
|
/**
|
|
55
55
|
* Callback to be called when the timer has stopped, either manually or by completing its work
|
|
56
56
|
*/
|
|
57
|
-
onAfter: (
|
|
57
|
+
onAfter: (finished: boolean) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Callback to be called after the timer has timed out
|
|
60
|
+
*/
|
|
61
|
+
onTimeout: () => void;
|
|
58
62
|
/**
|
|
59
63
|
* How many times the timer should repeat
|
|
60
64
|
*/
|
|
@@ -63,6 +67,10 @@ export type RepeatOptions = {
|
|
|
63
67
|
* The interval between each repeat
|
|
64
68
|
*/
|
|
65
69
|
interval: number;
|
|
70
|
+
/**
|
|
71
|
+
* The timeout for the timer _(any value above `0` will enable the timeout)_
|
|
72
|
+
*/
|
|
73
|
+
timeout: number;
|
|
66
74
|
};
|
|
67
75
|
export type TimerOptions = {
|
|
68
76
|
onAfter: ((finished: boolean) => void) | undefined;
|