File tree 2 files changed +22
-2
lines changed
2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ class AsyncHook {
96
96
97
97
// Each hook is only allowed to be added once.
98
98
if ( hooks_array . includes ( this ) )
99
- return ;
99
+ return this ;
100
100
101
101
if ( ! setupHooksCalled ) {
102
102
setupHooksCalled = true ;
@@ -124,7 +124,7 @@ class AsyncHook {
124
124
125
125
const index = hooks_array . indexOf ( this ) ;
126
126
if ( index === - 1 )
127
- return ;
127
+ return this ;
128
128
129
129
hook_fields [ kInit ] -= + ! ! this [ init_symbol ] ;
130
130
hook_fields [ kBefore ] -= + ! ! this [ before_symbol ] ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const common = require ( '../common' ) ;
3
+ const assert = require ( 'assert' ) ;
4
+ const async_hooks = require ( 'async_hooks' ) ;
5
+
6
+ const hook = async_hooks . createHook ( {
7
+ init : common . mustCall ( ( ) => { } , 1 ) ,
8
+ before : common . mustNotCall ( ) ,
9
+ after : common . mustNotCall ( ) ,
10
+ destroy : common . mustNotCall ( )
11
+ } ) ;
12
+
13
+ assert . strictEqual ( hook . enable ( ) , hook ) ;
14
+ assert . strictEqual ( hook . enable ( ) , hook ) ;
15
+
16
+ setImmediate ( common . mustCall ( ) ) ;
17
+
18
+ assert . strictEqual ( hook . disable ( ) , hook ) ;
19
+ assert . strictEqual ( hook . disable ( ) , hook ) ;
20
+ assert . strictEqual ( hook . disable ( ) , hook ) ;
You can’t perform that action at this time.
0 commit comments