@@ -87,7 +87,7 @@ class AsyncHook {
87
87
// enable()/disable() are run during their execution. The following
88
88
// references are reassigned to the tmp arrays if a hook is currently being
89
89
// processed.
90
- const [ hooks_array , hook_fields ] = getHookArrays ( ) ;
90
+ const { 0 : hooks_array , 1 : hook_fields } = getHookArrays ( ) ;
91
91
92
92
// Each hook is only allowed to be added once.
93
93
if ( ArrayPrototypeIncludes ( hooks_array , this ) )
@@ -116,7 +116,7 @@ class AsyncHook {
116
116
}
117
117
118
118
disable ( ) {
119
- const [ hooks_array , hook_fields ] = getHookArrays ( ) ;
119
+ const { 0 : hooks_array , 1 : hook_fields } = getHookArrays ( ) ;
120
120
121
121
const index = ArrayPrototypeIndexOf ( hooks_array , this ) ;
122
122
if ( index === - 1 )
@@ -193,8 +193,7 @@ class AsyncResource {
193
193
emitBefore ( asyncId , this [ trigger_async_id_symbol ] , this ) ;
194
194
195
195
try {
196
- const ret = thisArg === undefined ?
197
- fn ( ...args ) :
196
+ const ret =
198
197
ReflectApply ( fn , thisArg , args ) ;
199
198
200
199
return ret ;
@@ -302,25 +301,25 @@ class AsyncLocalStorage {
302
301
run ( store , callback , ...args ) {
303
302
// Avoid creation of an AsyncResource if store is already active
304
303
if ( ObjectIs ( store , this . getStore ( ) ) ) {
305
- return callback ( ... args ) ;
304
+ return ReflectApply ( callback , null , args ) ;
306
305
}
307
306
const resource = new AsyncResource ( 'AsyncLocalStorage' ,
308
307
defaultAlsResourceOpts ) ;
309
308
// Calling emitDestroy before runInAsyncScope avoids a try/finally
310
309
// It is ok because emitDestroy only schedules calling the hook
311
310
return resource . emitDestroy ( ) . runInAsyncScope ( ( ) => {
312
311
this . enterWith ( store ) ;
313
- return callback ( ... args ) ;
312
+ return ReflectApply ( callback , null , args ) ;
314
313
} ) ;
315
314
}
316
315
317
316
exit ( callback , ...args ) {
318
317
if ( ! this . enabled ) {
319
- return callback ( ... args ) ;
318
+ return ReflectApply ( callback , null , args ) ;
320
319
}
321
320
this . disable ( ) ;
322
321
try {
323
- return callback ( ... args ) ;
322
+ return ReflectApply ( callback , null , args ) ;
324
323
} finally {
325
324
this . _enable ( ) ;
326
325
}
0 commit comments