22
33const {
44 ObjectDefineProperties,
5- ReflectConstruct,
65 Symbol,
76} = primordials ;
87
@@ -25,14 +24,17 @@ const kEntryType = Symbol('PerformanceEntry.EntryType');
2524const kStartTime = Symbol ( 'PerformanceEntry.StartTime' ) ;
2625const kDuration = Symbol ( 'PerformanceEntry.Duration' ) ;
2726const kDetail = Symbol ( 'NodePerformanceEntry.Detail' ) ;
27+ const kSkipThrow = Symbol ( 'kSkipThrow' ) ;
2828
2929function isPerformanceEntry ( obj ) {
3030 return obj ?. [ kName ] !== undefined ;
3131}
3232
3333class PerformanceEntry {
34- constructor ( ) {
35- throw new ERR_ILLEGAL_CONSTRUCTOR ( ) ;
34+ constructor ( skipThrowSymbol = undefined ) {
35+ if ( skipThrowSymbol !== kSkipThrow ) {
36+ throw new ERR_ILLEGAL_CONSTRUCTOR ( ) ;
37+ }
3638 }
3739
3840 get name ( ) {
@@ -92,9 +94,11 @@ function initPerformanceEntry(entry, name, type, start, duration) {
9294}
9395
9496function createPerformanceEntry ( name , type , start , duration ) {
95- return ReflectConstruct ( function PerformanceEntry ( ) {
96- initPerformanceEntry ( this , name , type , start , duration ) ;
97- } , [ ] , PerformanceEntry ) ;
97+ const entry = new PerformanceEntry ( kSkipThrow ) ;
98+
99+ initPerformanceEntry ( entry , name , type , start , duration ) ;
100+
101+ return entry ;
98102}
99103
100104/**
@@ -119,10 +123,12 @@ class PerformanceNodeEntry extends PerformanceEntry {
119123}
120124
121125function createPerformanceNodeEntry ( name , type , start , duration , detail ) {
122- return ReflectConstruct ( function PerformanceNodeEntry ( ) {
123- initPerformanceEntry ( this , name , type , start , duration ) ;
124- this [ kDetail ] = detail ;
125- } , [ ] , PerformanceNodeEntry ) ;
126+ const entry = new PerformanceNodeEntry ( kSkipThrow ) ;
127+
128+ initPerformanceEntry ( entry , name , type , start , duration ) ;
129+ entry [ kDetail ] = detail ;
130+
131+ return entry ;
126132}
127133
128134module . exports = {
0 commit comments