File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { emptyFunction , tTable } from './constants' ;
2
2
import type { Fn , Statistics } from './types' ;
3
3
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
5
+ const isBrowser = ! ! ( globalThis as any ) . navigator ;
6
+
4
7
/**
5
8
* Converts nanoseconds to milliseconds.
6
9
*
@@ -17,7 +20,14 @@ export const nToMs = (ns: number) => ns / 1e6;
17
20
*/
18
21
export const mToNs = ( ms : number ) => ms * 1e6 ;
19
22
20
- const hrtimeBigint = process . hrtime . bigint . bind ( process . hrtime ) ;
23
+ let hrtimeBigint : ( ) => bigint ;
24
+ if ( isBrowser ) {
25
+ hrtimeBigint = ( ) => {
26
+ throw new Error ( 'hrtime.bigint() is not supported in this JS environment' ) ;
27
+ } ;
28
+ } else {
29
+ hrtimeBigint = process . hrtime . bigint . bind ( process . hrtime ) ;
30
+ }
21
31
export const hrtimeNow = ( ) => nToMs ( Number ( hrtimeBigint ( ) ) ) ;
22
32
23
33
const performanceNow = performance . now . bind ( performance ) ;
You can’t perform that action at this time.
0 commit comments