@@ -89,7 +89,7 @@ class AsyncHook {
8989// enable()/disable() are run during their execution. The following
9090// references are reassigned to the tmp arrays if a hook is currently being
9191// processed.
92- const [ hooks_array , hook_fields ] = getHookArrays ( ) ;
92+ const { 0 : hooks_array , 1 : hook_fields } = getHookArrays ( ) ;
9393
9494// Each hook is only allowed to be added once.
9595if ( ArrayPrototypeIncludes ( hooks_array , this ) )
@@ -118,7 +118,7 @@ class AsyncHook {
118118}
119119
120120disable ( ) {
121- const [ hooks_array , hook_fields ] = getHookArrays ( ) ;
121+ const { 0 : hooks_array , 1 : hook_fields } = getHookArrays ( ) ;
122122
123123const index = ArrayPrototypeIndexOf ( hooks_array , this ) ;
124124if ( index === - 1 )
@@ -195,8 +195,7 @@ class AsyncResource {
195195emitBefore ( asyncId , this [ trigger_async_id_symbol ] , this ) ;
196196
197197try {
198- const ret = thisArg === undefined ?
199- fn ( ...args ) :
198+ const ret =
200199ReflectApply ( fn , thisArg , args ) ;
201200
202201return ret ;
@@ -303,25 +302,25 @@ class AsyncLocalStorage {
303302run ( store , callback , ...args ) {
304303// Avoid creation of an AsyncResource if store is already active
305304if ( ObjectIs ( store , this . getStore ( ) ) ) {
306- return callback ( ... args ) ;
305+ return ReflectApply ( callback , null , args ) ;
307306}
308307const resource = new AsyncResource ( 'AsyncLocalStorage' ,
309308defaultAlsResourceOpts ) ;
310309// Calling emitDestroy before runInAsyncScope avoids a try/finally
311310// It is ok because emitDestroy only schedules calling the hook
312311return resource . emitDestroy ( ) . runInAsyncScope ( ( ) => {
313312this . enterWith ( store ) ;
314- return callback ( ... args ) ;
313+ return ReflectApply ( callback , null , args ) ;
315314} ) ;
316315}
317316
318317exit ( callback , ...args ) {
319318if ( ! this . enabled ) {
320- return callback ( ... args ) ;
319+ return ReflectApply ( callback , null , args ) ;
321320}
322321this . disable ( ) ;
323322try {
324- return callback ( ... args ) ;
323+ return ReflectApply ( callback , null , args ) ;
325324} finally {
326325this . _enable ( ) ;
327326}
0 commit comments