File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ const {
19
19
}
20
20
} = require ( 'internal/errors' ) ;
21
21
22
- const perf_hooks = require ( 'perf_hooks' ) ;
23
22
const { customInspectSymbol } = require ( 'internal/util' ) ;
24
23
const { inspect } = require ( 'util' ) ;
25
24
@@ -30,11 +29,19 @@ const kTarget = Symbol('kTarget');
30
29
const kNewListener = Symbol ( 'kNewListener' ) ;
31
30
const kRemoveListener = Symbol ( 'kRemoveListener' ) ;
32
31
32
+ // Lazy load perf_hooks to avoid the additional overhead on startup
33
+ let perf_hooks ;
34
+ function lazyNow ( ) {
35
+ if ( perf_hooks === undefined )
36
+ perf_hooks = require ( 'perf_hooks' ) ;
37
+ return perf_hooks . performance . now ( ) ;
38
+ }
39
+
33
40
class Event {
34
41
#type = undefined ;
35
42
#defaultPrevented = false ;
36
43
#cancelable = false ;
37
- #timestamp = perf_hooks . performance . now ( ) ;
44
+ #timestamp = lazyNow ( ) ;
38
45
39
46
// None of these are currently used in the Node.js implementation
40
47
// of EventTarget because there is no concept of bubbling or
You can’t perform that action at this time.
0 commit comments