-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.d.ts
More file actions
66 lines (59 loc) · 1.87 KB
/
index.d.ts
File metadata and controls
66 lines (59 loc) · 1.87 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
/**
* node-epoch — High-precision absolute epoch timer for Node.js on Windows.
* TypeScript declarations.
*/
/** Time unit accepted by the API. */
export type TimeUnit = 's' | 'ms' | 'us' | 'ns';
/**
* Schedule a callback at an **absolute** epoch timestamp.
*
* @param unit Time unit of `value`.
* @param value Absolute Unix timestamp expressed in `unit`.
* @param callback Invoked when the target time is reached.
* @returns An opaque handle usable with `clearEpochTimer`.
*
* @example
* // Fire 5 seconds from now
* const h = setEpochTimer('ms', Date.now() + 5000, () => {
* console.log('tick');
* });
*/
export function setEpochTimer(
unit: TimeUnit,
value: number,
callback: () => void,
): bigint;
/**
* Cancel a pending timer.
* Safe to call after the timer has already fired.
*
* @param handle The value returned by `setEpochTimer`.
*/
export function clearEpochTimer(handle: bigint): void;
/**
* Return the current wall-clock time in the requested unit using the
* highest-resolution source available on the current platform.
*
* @param unit Defaults to `"ms"`.
*/
export function getTime(unit?: TimeUnit): number;
/**
* Adjust the Windows system timer resolution (Windows only).
* Lower values give tighter jitter at the cost of CPU wake frequency.
*
* @param ms Resolution in milliseconds, clamped to [1, 16]. Defaults to 1.
*/
export function setResolution(ms?: number): void;
/** Diagnostic snapshot about the current addon state. */
export interface Diagnostics {
/** Current OS platform string (e.g. `"win32"`). */
platform: string;
/** Whether the native Windows addon was loaded successfully. */
nativeLoaded: boolean;
/** Error message if the native addon failed to load, otherwise `null`. */
nativeError: string | null;
}
/**
* Returns diagnostic information about the addon.
*/
export function diagnostics(): Diagnostics;