forked from albert-gonzalez/easytimer.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
54 lines (47 loc) · 1.71 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
export interface TimerValues {
secondTenths?: number;
seconds?: number;
minutes?: number;
hours?: number;
days?: number;
}
export class TimeCounter implements TimerValues {
secondTenths: number;
seconds: number;
minutes: number;
hours: number;
days: number;
toString(units?: string[] | null, separator?: string, leftZeroPadding?: number): string;
}
export type Precision = 'secondTenths' | 'seconds' | 'minutes' | 'hours' | 'days';
export type TimerEventType = 'daysUpdated' | 'hoursUpdated' | 'minutesUpdated' | 'secondsUpdated' | 'secondTenthsUpdated' | 'targetAchieved' | 'stopped' | 'reset' | 'started' | 'paused';
export interface TimerEvent {
detail: {
timer: Timer
}
}
export interface TimerParams {
precision?: Precision;
callback?: (timer: Timer) => void;
countdown?: boolean;
target?: TimerValues | [number,number,number,number,number];
startValues?: TimerValues | [number,number,number,number,number];
}
export class Timer {
constructor(defaultParams?: TimerParams);
stop(): void;
start(params?: TimerParams): void;
reset(): void;
pause(): void;
addEventListener(eventType: TimerEventType, listener: (event: TimerEvent) => void): void;
on(eventType: TimerEventType, listener: (event: TimerEvent) => void): void;
removeEventListener(eventType: TimerEventType, listener: (event: TimerEvent) => void): void;
removeAllEventListeners(eventType?: TimerEventType): void;
off(eventType: TimerEventType, listener: (event: TimerEvent) => void): void;
isRunning(): boolean;
isPaused(): boolean;
getTimeValues(): TimeCounter;
getTotalTimeValues(): TimeCounter;
getConfig(): TimerParams
}
export default Timer;