Skip to content

Commit

Permalink
Improve function name
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Dec 11, 2022
1 parent 7570fa0 commit e683147
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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 */

0 comments on commit e683147

Please sign in to comment.