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