diff --git a/src/main.ts b/src/main.ts index 9567ffa..219122c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -38,16 +38,6 @@ const nowFunc = () => { return dateNow.bind(undefined, Date.now()) } -const hrtime = (start: bigint) => - Number(globalThis.process.hrtime.bigint() - start) - -const performanceNow = (start: number) => - Math.round((globalThis.performance.now() - start) * NANOSECS_TO_MILLISECS) - -const dateNow = (start: number) => (Date.now() - start) * NANOSECS_TO_MILLISECS - -const NANOSECS_TO_MILLISECS = 1e6 - /** * Return the number of nanoseconds since the time origin. * @@ -58,5 +48,17 @@ const NANOSECS_TO_MILLISECS = 1e6 * const duration = end - start * ``` */ -export default nowFunc() +const preciseNow = nowFunc() + +export default preciseNow + +const hrtime = (start: bigint) => + Number(globalThis.process.hrtime.bigint() - start) + +const performanceNow = (start: number) => + Math.round((globalThis.performance.now() - start) * NANOSECS_TO_MILLISECS) + +const dateNow = (start: number) => (Date.now() - start) * NANOSECS_TO_MILLISECS + +const NANOSECS_TO_MILLISECS = 1e6 /* eslint-enable @typescript-eslint/no-unnecessary-condition, n/prefer-global/process */