File tree 13 files changed +32
-25
lines changed
13 files changed +32
-25
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,8 @@ const COMPILE = function(options) {
71
71
return factory . create ( options ) ;
72
72
} ;
73
73
74
- function AsyncParallelBailHook ( args = [ ] ) {
75
- const hook = new Hook ( args ) ;
74
+ function AsyncParallelBailHook ( args = [ ] , name = undefined ) {
75
+ const hook = new Hook ( args , name ) ;
76
76
hook . constructor = AsyncParallelBailHook ;
77
77
hook . compile = COMPILE ;
78
78
hook . _call = undefined ;
Original file line number Diff line number Diff line change @@ -23,8 +23,8 @@ const COMPILE = function(options) {
23
23
return factory . create ( options ) ;
24
24
} ;
25
25
26
- function AsyncParallelHook ( args = [ ] ) {
27
- const hook = new Hook ( args ) ;
26
+ function AsyncParallelHook ( args = [ ] , name = undefined ) {
27
+ const hook = new Hook ( args , name ) ;
28
28
hook . constructor = AsyncParallelHook ;
29
29
hook . compile = COMPILE ;
30
30
hook . _call = undefined ;
Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ const COMPILE = function(options) {
28
28
return factory . create ( options ) ;
29
29
} ;
30
30
31
- function AsyncSeriesBailHook ( args = [ ] ) {
32
- const hook = new Hook ( args ) ;
31
+ function AsyncSeriesBailHook ( args = [ ] , name = undefined ) {
32
+ const hook = new Hook ( args , name ) ;
33
33
hook . constructor = AsyncSeriesBailHook ;
34
34
hook . compile = COMPILE ;
35
35
hook . _call = undefined ;
Original file line number Diff line number Diff line change @@ -23,8 +23,8 @@ const COMPILE = function(options) {
23
23
return factory . create ( options ) ;
24
24
} ;
25
25
26
- function AsyncSeriesHook ( args = [ ] ) {
27
- const hook = new Hook ( args ) ;
26
+ function AsyncSeriesHook ( args = [ ] , name = undefined ) {
27
+ const hook = new Hook ( args , name ) ;
28
28
hook . constructor = AsyncSeriesHook ;
29
29
hook . compile = COMPILE ;
30
30
hook . _call = undefined ;
Original file line number Diff line number Diff line change @@ -23,8 +23,8 @@ const COMPILE = function(options) {
23
23
return factory . create ( options ) ;
24
24
} ;
25
25
26
- function AsyncSeriesLoopHook ( args = [ ] ) {
27
- const hook = new Hook ( args ) ;
26
+ function AsyncSeriesLoopHook ( args = [ ] , name = undefined ) {
27
+ const hook = new Hook ( args , name ) ;
28
28
hook . constructor = AsyncSeriesLoopHook ;
29
29
hook . compile = COMPILE ;
30
30
hook . _call = undefined ;
Original file line number Diff line number Diff line change @@ -31,10 +31,10 @@ const COMPILE = function(options) {
31
31
return factory . create ( options ) ;
32
32
} ;
33
33
34
- function AsyncSeriesWaterfallHook ( args = [ ] ) {
34
+ function AsyncSeriesWaterfallHook ( args = [ ] , name = undefined ) {
35
35
if ( args . length < 1 )
36
36
throw new Error ( "Waterfall hooks must have at least one argument" ) ;
37
- const hook = new Hook ( args ) ;
37
+ const hook = new Hook ( args , name ) ;
38
38
hook . constructor = AsyncSeriesWaterfallHook ;
39
39
hook . compile = COMPILE ;
40
40
hook . _call = undefined ;
Original file line number Diff line number Diff line change @@ -9,8 +9,9 @@ const util = require("util");
9
9
const defaultFactory = ( key , hook ) => hook ;
10
10
11
11
class HookMap {
12
- constructor ( factory ) {
12
+ constructor ( factory , name = undefined ) {
13
13
this . _map = new Map ( ) ;
14
+ this . name = name ;
14
15
this . _factory = factory ;
15
16
this . _interceptors = [ ] ;
16
17
}
Original file line number Diff line number Diff line change 7
7
const Hook = require ( "./Hook" ) ;
8
8
9
9
class MultiHook {
10
- constructor ( hooks ) {
10
+ constructor ( hooks , name = undefined ) {
11
11
this . hooks = hooks ;
12
+ this . name = name ;
12
13
}
13
14
14
15
tap ( options , fn ) {
@@ -43,7 +44,10 @@ class MultiHook {
43
44
}
44
45
45
46
withOptions ( options ) {
46
- return new MultiHook ( this . hooks . map ( h => h . withOptions ( options ) ) ) ;
47
+ return new MultiHook (
48
+ this . hooks . map ( h => h . withOptions ( options ) ) ,
49
+ this . name
50
+ ) ;
47
51
}
48
52
}
49
53
Original file line number Diff line number Diff line change @@ -37,8 +37,8 @@ const COMPILE = function(options) {
37
37
return factory . create ( options ) ;
38
38
} ;
39
39
40
- function SyncBailHook ( args = [ ] ) {
41
- const hook = new Hook ( args ) ;
40
+ function SyncBailHook ( args = [ ] , name = undefined ) {
41
+ const hook = new Hook ( args , name ) ;
42
42
hook . constructor = SyncBailHook ;
43
43
hook . tapAsync = TAP_ASYNC ;
44
44
hook . tapPromise = TAP_PROMISE ;
Original file line number Diff line number Diff line change @@ -32,8 +32,8 @@ const COMPILE = function(options) {
32
32
return factory . create ( options ) ;
33
33
} ;
34
34
35
- function SyncHook ( args = [ ] ) {
36
- const hook = new Hook ( args ) ;
35
+ function SyncHook ( args = [ ] , name = undefined ) {
36
+ const hook = new Hook ( args , name ) ;
37
37
hook . constructor = SyncHook ;
38
38
hook . tapAsync = TAP_ASYNC ;
39
39
hook . tapPromise = TAP_PROMISE ;
Original file line number Diff line number Diff line change @@ -32,8 +32,8 @@ const COMPILE = function(options) {
32
32
return factory . create ( options ) ;
33
33
} ;
34
34
35
- function SyncLoopHook ( args = [ ] ) {
36
- const hook = new Hook ( args ) ;
35
+ function SyncLoopHook ( args = [ ] , name = undefined ) {
36
+ const hook = new Hook ( args , name ) ;
37
37
hook . constructor = SyncLoopHook ;
38
38
hook . tapAsync = TAP_ASYNC ;
39
39
hook . tapPromise = TAP_PROMISE ;
Original file line number Diff line number Diff line change @@ -41,10 +41,10 @@ const COMPILE = function(options) {
41
41
return factory . create ( options ) ;
42
42
} ;
43
43
44
- function SyncWaterfallHook ( args = [ ] ) {
44
+ function SyncWaterfallHook ( args = [ ] , name = undefined ) {
45
45
if ( args . length < 1 )
46
46
throw new Error ( "Waterfall hooks must have at least one argument" ) ;
47
- const hook = new Hook ( args ) ;
47
+ const hook = new Hook ( args , name ) ;
48
48
hook . constructor = SyncWaterfallHook ;
49
49
hook . tapAsync = TAP_ASYNC ;
50
50
hook . tapPromise = TAP_PROMISE ;
Original file line number Diff line number Diff line change @@ -85,14 +85,16 @@ interface HookMapInterceptor<H> {
85
85
}
86
86
87
87
export class HookMap < H > {
88
- constructor ( factory : HookFactory < H > ) ;
88
+ constructor ( factory : HookFactory < H > , name ?: string ) ;
89
+ name : string | undefined ;
89
90
get ( key : any ) : H | undefined ;
90
91
for ( key : any ) : H ;
91
92
intercept ( interceptor : HookMapInterceptor < H > ) : void ;
92
93
}
93
94
94
95
export class MultiHook < H > {
95
- constructor ( hooks : H [ ] ) ;
96
+ constructor ( hooks : H [ ] , name ?: string ) ;
97
+ name : string | undefined ;
96
98
tap ( options : string | Tap , fn ?: Function ) : void ;
97
99
tapAsync ( options : string | Tap , fn ?: Function ) : void ;
98
100
tapPromise ( options : string | Tap , fn ?: Function ) : void ;
You can’t perform that action at this time.
0 commit comments