@@ -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 ;
@@ -308,25 +307,25 @@ class AsyncLocalStorage {
308
307
run ( store , callback , ...args ) {
309
308
// Avoid creation of an AsyncResource if store is already active
310
309
if ( ObjectIs ( store , this . getStore ( ) ) ) {
311
- return callback ( ... args ) ;
310
+ return ReflectApply ( callback , null , args ) ;
312
311
}
313
312
const resource = new AsyncResource ( 'AsyncLocalStorage' ,
314
313
defaultAlsResourceOpts ) ;
315
314
// Calling emitDestroy before runInAsyncScope avoids a try/finally
316
315
// It is ok because emitDestroy only schedules calling the hook
317
316
return resource . emitDestroy ( ) . runInAsyncScope ( ( ) => {
318
317
this . enterWith ( store ) ;
319
- return callback ( ... args ) ;
318
+ return ReflectApply ( callback , null , args ) ;
320
319
} ) ;
321
320
}
322
321
323
322
exit ( callback , ...args ) {
324
323
if ( ! this . enabled ) {
325
- return callback ( ... args ) ;
324
+ return ReflectApply ( callback , null , args ) ;
326
325
}
327
326
this . disable ( ) ;
328
327
try {
329
- return callback ( ... args ) ;
328
+ return ReflectApply ( callback , null , args ) ;
330
329
} finally {
331
330
this . _enable ( ) ;
332
331
}
0 commit comments