UNPKG

@thi.ng/timestamp

Version:

Timestamp getter wrapping (in order of preference) `process.hrtime.bigint()`, `performance.now()` or `Date.now()`

24 lines 874 B
export type Timestamp = number | bigint; /** * If available, returns wrapper for `process.hrtime.bigint()` else falls back * to `performance.now()` or lacking that to `Date.now()`. In all cases, returns * a nanosec-scale timestamp, either as `bigint` or `number`. */ export declare const now: () => Timestamp; /** * Returns the difference in milliseconds between 2 given {@link Timestamp}s, * e.g. obtained via {@link now}. `a` is assumed to be older than `b`, the * latter defaults to result of {@link now}. * * @param a * @param b */ export declare const timeDiff: (a: Timestamp, b?: Timestamp) => number; /** * Takes a duration (either a number or bigint) in nanosec-scale (see * {@link now}) and converts it to a JS number in milliseconds. * * @param t */ export declare const asMillis: (t: number | bigint) => number; //# sourceMappingURL=index.d.ts.map