@oscarpalmer/timer 0.31.0 → 0.32.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 +23 -19
- package/dist/constants.js +23 -20
- package/dist/delay.cjs +1 -1
- package/dist/delay.js +2 -2
- package/dist/repeat.cjs +1 -2
- package/dist/repeat.js +1 -2
- package/dist/timer.cjs +14 -5
- package/dist/timer.full.js +189 -155
- package/dist/timer.js +14 -5
- package/dist/wait.cjs +1 -2
- package/dist/wait.js +1 -2
- package/dist/when.cjs +65 -62
- package/dist/when.js +65 -62
- package/dist/work.cjs +39 -24
- package/dist/work.js +40 -26
- package/package.json +1 -1
- package/src/constants.ts +36 -27
- package/src/delay.ts +5 -2
- package/src/repeat.ts +1 -2
- package/src/timer.ts +14 -6
- package/src/wait.ts +1 -2
- package/src/when.ts +74 -71
- package/src/work.ts +72 -40
- package/types/constants.d.cts +5 -7
- package/types/constants.d.ts +4 -0
- package/types/index.d.cts +2 -16
- package/types/is.d.cts +18 -15
- package/types/models.d.cts +1 -2
- package/types/repeat.d.cts +1 -8
- package/types/repeat.d.ts +1 -0
- package/types/timer.d.cts +1 -8
- package/types/timer.d.ts +2 -3
- package/types/wait.d.cts +1 -8
- package/types/wait.d.ts +1 -0
- package/types/when.d.cts +1 -81
- package/types/when.d.ts +3 -2
- package/types/work.d.cts +6 -3
- package/types/work.d.ts +1 -0
package/types/timer.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { TimerOptions, TimerState, TimerType
|
|
1
|
+
import type { TimerOptions, TimerState, TimerType } from './models';
|
|
2
2
|
export declare class Timer {
|
|
3
3
|
#private;
|
|
4
|
-
protected readonly worker: WorkHandler;
|
|
5
4
|
protected readonly options: TimerOptions;
|
|
6
5
|
private readonly $timer;
|
|
7
6
|
protected readonly state: TimerState;
|
|
@@ -21,7 +20,7 @@ export declare class Timer {
|
|
|
21
20
|
* Get the timer's origin _(if debugging is enabled)_
|
|
22
21
|
*/
|
|
23
22
|
get trace(): string | undefined;
|
|
24
|
-
constructor(type: TimerType,
|
|
23
|
+
constructor(type: TimerType, state: Pick<TimerState, 'callback' | 'trace'>, options: TimerOptions, start: boolean);
|
|
25
24
|
/**
|
|
26
25
|
* Continue running the timer _(if it's paused)_
|
|
27
26
|
*/
|
package/types/wait.d.cts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
export declare class Timer {
|
|
4
4
|
#private;
|
|
5
|
-
protected readonly worker: WorkHandler;
|
|
6
5
|
protected readonly options: TimerOptions;
|
|
7
6
|
private readonly $timer;
|
|
8
7
|
protected readonly state: TimerState;
|
|
@@ -22,7 +21,7 @@ export declare class Timer {
|
|
|
22
21
|
* Get the timer's origin _(if debugging is enabled)_
|
|
23
22
|
*/
|
|
24
23
|
get trace(): string | undefined;
|
|
25
|
-
constructor(type: TimerType,
|
|
24
|
+
constructor(type: TimerType, state: Pick<TimerState, "callback" | "trace">, options: TimerOptions, start: boolean);
|
|
26
25
|
/**
|
|
27
26
|
* Continue running the timer _(if it's paused)_
|
|
28
27
|
*/
|
|
@@ -67,12 +66,6 @@ export type TimerState = {
|
|
|
67
66
|
trace: string | undefined;
|
|
68
67
|
};
|
|
69
68
|
export type TimerType = "repeat" | "wait" | "when";
|
|
70
|
-
export type WorkHandler = (type: WorkHandlerType, timer: WorkHandlerTimer, state: TimerState, options: TimerOptions) => Timer;
|
|
71
|
-
export type WorkHandlerTimer = {
|
|
72
|
-
instance: Timer;
|
|
73
|
-
type: TimerType;
|
|
74
|
-
};
|
|
75
|
-
export type WorkHandlerType = "continue" | "pause" | "restart" | "start" | "stop";
|
|
76
69
|
/**
|
|
77
70
|
* Create a waiting timer
|
|
78
71
|
* @param callback Callback to run when the timer has finished
|
package/types/wait.d.ts
CHANGED
package/types/when.d.cts
CHANGED
|
@@ -1,72 +1,5 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
declare class Timer {
|
|
4
|
-
#private;
|
|
5
|
-
protected readonly worker: WorkHandler;
|
|
6
|
-
protected readonly options: TimerOptions;
|
|
7
|
-
private readonly $timer;
|
|
8
|
-
protected readonly state: TimerState;
|
|
9
|
-
/**
|
|
10
|
-
* Is the timer active?
|
|
11
|
-
*/
|
|
12
|
-
get active(): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Is the timer destroyed?
|
|
15
|
-
*/
|
|
16
|
-
get destroyed(): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Is the timer paused?
|
|
19
|
-
*/
|
|
20
|
-
get paused(): boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Get the timer's origin _(if debugging is enabled)_
|
|
23
|
-
*/
|
|
24
|
-
get trace(): string | undefined;
|
|
25
|
-
constructor(type: TimerType, worker: WorkHandler, state: Pick<TimerState, "callback" | "trace">, options: TimerOptions, start: boolean);
|
|
26
|
-
/**
|
|
27
|
-
* Continue running the timer _(if it's paused)_
|
|
28
|
-
*/
|
|
29
|
-
continue(): Timer;
|
|
30
|
-
/**
|
|
31
|
-
* Destroy the timer
|
|
32
|
-
*/
|
|
33
|
-
destroy(): void;
|
|
34
|
-
/**
|
|
35
|
-
* Pause the timer _(if it's running)_
|
|
36
|
-
*/
|
|
37
|
-
pause(): Timer;
|
|
38
|
-
/**
|
|
39
|
-
* Restart the timer _(or start it, if it's not running)_
|
|
40
|
-
*/
|
|
41
|
-
restart(): Timer;
|
|
42
|
-
/**
|
|
43
|
-
* Start the timer _(if it's not running)_
|
|
44
|
-
*/
|
|
45
|
-
start(): Timer;
|
|
46
|
-
/**
|
|
47
|
-
* Stop the timer _(if it's running)_
|
|
48
|
-
*/
|
|
49
|
-
stop(): Timer;
|
|
50
|
-
}
|
|
51
|
-
export type TimerOptions = {
|
|
52
|
-
onAfter: ((finished: boolean) => void) | undefined;
|
|
53
|
-
onError: (() => void) | undefined;
|
|
54
|
-
count: number;
|
|
55
|
-
interval: number;
|
|
56
|
-
timeout: number;
|
|
57
|
-
};
|
|
58
|
-
export type TimerState = {
|
|
59
|
-
active: boolean;
|
|
60
|
-
callback: () => void;
|
|
61
|
-
destroyed: boolean;
|
|
62
|
-
elapsed: number;
|
|
63
|
-
frame: number | undefined;
|
|
64
|
-
index: number;
|
|
65
|
-
paused: boolean;
|
|
66
|
-
total: number;
|
|
67
|
-
trace: string | undefined;
|
|
68
|
-
};
|
|
69
|
-
export type TimerType = "repeat" | "wait" | "when";
|
|
70
3
|
/**
|
|
71
4
|
* Options for a conditional timer
|
|
72
5
|
*/
|
|
@@ -84,19 +17,6 @@ export type WhenOptions = {
|
|
|
84
17
|
*/
|
|
85
18
|
timeout: number;
|
|
86
19
|
};
|
|
87
|
-
export type WhenState = {
|
|
88
|
-
promise: Promise<void>;
|
|
89
|
-
rejecter?: () => void;
|
|
90
|
-
resolver?: () => void;
|
|
91
|
-
started: boolean;
|
|
92
|
-
timer: Timer;
|
|
93
|
-
};
|
|
94
|
-
export type WorkHandler = (type: WorkHandlerType, timer: WorkHandlerTimer, state: TimerState, options: TimerOptions) => Timer;
|
|
95
|
-
export type WorkHandlerTimer = {
|
|
96
|
-
instance: Timer;
|
|
97
|
-
type: TimerType;
|
|
98
|
-
};
|
|
99
|
-
export type WorkHandlerType = "continue" | "pause" | "restart" | "start" | "stop";
|
|
100
20
|
export declare class When {
|
|
101
21
|
private readonly $timer;
|
|
102
22
|
private readonly state;
|
|
@@ -116,7 +36,7 @@ export declare class When {
|
|
|
116
36
|
* Get the timer's origin _(if debugging is enabled)_
|
|
117
37
|
*/
|
|
118
38
|
get trace(): string | undefined;
|
|
119
|
-
constructor(
|
|
39
|
+
constructor(condition: () => boolean, options?: Partial<WhenOptions>);
|
|
120
40
|
/**
|
|
121
41
|
* Continues the timer _(if it was paused)_
|
|
122
42
|
*/
|
package/types/when.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './global';
|
|
2
|
+
import { type WhenOptions } from './models';
|
|
2
3
|
declare class When {
|
|
3
4
|
private readonly $timer;
|
|
4
5
|
private readonly state;
|
|
@@ -18,7 +19,7 @@ declare class When {
|
|
|
18
19
|
* Get the timer's origin _(if debugging is enabled)_
|
|
19
20
|
*/
|
|
20
21
|
get trace(): string | undefined;
|
|
21
|
-
constructor(
|
|
22
|
+
constructor(condition: () => boolean, options?: Partial<WhenOptions>);
|
|
22
23
|
/**
|
|
23
24
|
* Continues the timer _(if it was paused)_
|
|
24
25
|
*/
|
package/types/work.d.cts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
declare class Timer {
|
|
4
4
|
#private;
|
|
5
|
-
protected readonly worker: WorkHandler;
|
|
6
5
|
protected readonly options: TimerOptions;
|
|
7
6
|
private readonly $timer;
|
|
8
7
|
protected readonly state: TimerState;
|
|
@@ -22,7 +21,7 @@ declare class Timer {
|
|
|
22
21
|
* Get the timer's origin _(if debugging is enabled)_
|
|
23
22
|
*/
|
|
24
23
|
get trace(): string | undefined;
|
|
25
|
-
constructor(type: TimerType,
|
|
24
|
+
constructor(type: TimerType, state: Pick<TimerState, "callback" | "trace">, options: TimerOptions, start: boolean);
|
|
26
25
|
/**
|
|
27
26
|
* Continue running the timer _(if it's paused)_
|
|
28
27
|
*/
|
|
@@ -67,12 +66,16 @@ export type TimerState = {
|
|
|
67
66
|
trace: string | undefined;
|
|
68
67
|
};
|
|
69
68
|
export type TimerType = "repeat" | "wait" | "when";
|
|
70
|
-
export type WorkHandler = (type: WorkHandlerType, timer: WorkHandlerTimer, state: TimerState, options: TimerOptions) => Timer;
|
|
71
69
|
export type WorkHandlerTimer = {
|
|
72
70
|
instance: Timer;
|
|
73
71
|
type: TimerType;
|
|
74
72
|
};
|
|
75
73
|
export type WorkHandlerType = "continue" | "pause" | "restart" | "start" | "stop";
|
|
74
|
+
declare function stop$1(timer: WorkHandlerTimer, state: TimerState, options: TimerOptions): void;
|
|
76
75
|
export declare function work(type: WorkHandlerType, timer: WorkHandlerTimer, state: TimerState, options: TimerOptions): Timer;
|
|
77
76
|
|
|
77
|
+
export {
|
|
78
|
+
stop$1 as stop,
|
|
79
|
+
};
|
|
80
|
+
|
|
78
81
|
export {};
|
package/types/work.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { TimerOptions, TimerState, WorkHandlerTimer, WorkHandlerType } from './models';
|
|
2
2
|
import type { Timer } from './timer';
|
|
3
|
+
export declare function stop(timer: WorkHandlerTimer, state: TimerState, options: TimerOptions): void;
|
|
3
4
|
export declare function work(type: WorkHandlerType, timer: WorkHandlerTimer, state: TimerState, options: TimerOptions): Timer;
|