diff --git a/lib/AsyncParallelBailHook.js b/lib/AsyncParallelBailHook.js index 0ff3293..c2d08e5 100644 --- a/lib/AsyncParallelBailHook.js +++ b/lib/AsyncParallelBailHook.js @@ -71,8 +71,8 @@ const COMPILE = function(options) { return factory.create(options); }; -function AsyncParallelBailHook(args = []) { - const hook = new Hook(args); +function AsyncParallelBailHook(args = [], name = undefined) { + const hook = new Hook(args, name); hook.constructor = AsyncParallelBailHook; hook.compile = COMPILE; hook._call = undefined; diff --git a/lib/AsyncParallelHook.js b/lib/AsyncParallelHook.js index 7a52eb7..b7a3631 100644 --- a/lib/AsyncParallelHook.js +++ b/lib/AsyncParallelHook.js @@ -23,8 +23,8 @@ const COMPILE = function(options) { return factory.create(options); }; -function AsyncParallelHook(args = []) { - const hook = new Hook(args); +function AsyncParallelHook(args = [], name = undefined) { + const hook = new Hook(args, name); hook.constructor = AsyncParallelHook; hook.compile = COMPILE; hook._call = undefined; diff --git a/lib/AsyncSeriesBailHook.js b/lib/AsyncSeriesBailHook.js index 8f29c3a..e450111 100644 --- a/lib/AsyncSeriesBailHook.js +++ b/lib/AsyncSeriesBailHook.js @@ -28,8 +28,8 @@ const COMPILE = function(options) { return factory.create(options); }; -function AsyncSeriesBailHook(args = []) { - const hook = new Hook(args); +function AsyncSeriesBailHook(args = [], name = undefined) { + const hook = new Hook(args, name); hook.constructor = AsyncSeriesBailHook; hook.compile = COMPILE; hook._call = undefined; diff --git a/lib/AsyncSeriesHook.js b/lib/AsyncSeriesHook.js index bba8d5b..3edad00 100644 --- a/lib/AsyncSeriesHook.js +++ b/lib/AsyncSeriesHook.js @@ -23,8 +23,8 @@ const COMPILE = function(options) { return factory.create(options); }; -function AsyncSeriesHook(args = []) { - const hook = new Hook(args); +function AsyncSeriesHook(args = [], name = undefined) { + const hook = new Hook(args, name); hook.constructor = AsyncSeriesHook; hook.compile = COMPILE; hook._call = undefined; diff --git a/lib/AsyncSeriesLoopHook.js b/lib/AsyncSeriesLoopHook.js index 4a4aa79..fb5f067 100644 --- a/lib/AsyncSeriesLoopHook.js +++ b/lib/AsyncSeriesLoopHook.js @@ -23,8 +23,8 @@ const COMPILE = function(options) { return factory.create(options); }; -function AsyncSeriesLoopHook(args = []) { - const hook = new Hook(args); +function AsyncSeriesLoopHook(args = [], name = undefined) { + const hook = new Hook(args, name); hook.constructor = AsyncSeriesLoopHook; hook.compile = COMPILE; hook._call = undefined; diff --git a/lib/AsyncSeriesWaterfallHook.js b/lib/AsyncSeriesWaterfallHook.js index 55f57a5..910b536 100644 --- a/lib/AsyncSeriesWaterfallHook.js +++ b/lib/AsyncSeriesWaterfallHook.js @@ -31,10 +31,10 @@ const COMPILE = function(options) { return factory.create(options); }; -function AsyncSeriesWaterfallHook(args = []) { +function AsyncSeriesWaterfallHook(args = [], name = undefined) { if (args.length < 1) throw new Error("Waterfall hooks must have at least one argument"); - const hook = new Hook(args); + const hook = new Hook(args, name); hook.constructor = AsyncSeriesWaterfallHook; hook.compile = COMPILE; hook._call = undefined; diff --git a/lib/HookMap.js b/lib/HookMap.js index 22568eb..129ad6a 100644 --- a/lib/HookMap.js +++ b/lib/HookMap.js @@ -9,8 +9,9 @@ const util = require("util"); const defaultFactory = (key, hook) => hook; class HookMap { - constructor(factory) { + constructor(factory, name = undefined) { this._map = new Map(); + this.name = name; this._factory = factory; this._interceptors = []; } diff --git a/lib/MultiHook.js b/lib/MultiHook.js index cddd917..e4fc2ce 100644 --- a/lib/MultiHook.js +++ b/lib/MultiHook.js @@ -7,8 +7,9 @@ const Hook = require("./Hook"); class MultiHook { - constructor(hooks) { + constructor(hooks, name = undefined) { this.hooks = hooks; + this.name = name; } tap(options, fn) { @@ -43,7 +44,10 @@ class MultiHook { } withOptions(options) { - return new MultiHook(this.hooks.map(h => h.withOptions(options))); + return new MultiHook( + this.hooks.map(h => h.withOptions(options)), + this.name + ); } } diff --git a/lib/SyncBailHook.js b/lib/SyncBailHook.js index a0ca14b..bdd5b45 100644 --- a/lib/SyncBailHook.js +++ b/lib/SyncBailHook.js @@ -37,8 +37,8 @@ const COMPILE = function(options) { return factory.create(options); }; -function SyncBailHook(args = []) { - const hook = new Hook(args); +function SyncBailHook(args = [], name = undefined) { + const hook = new Hook(args, name); hook.constructor = SyncBailHook; hook.tapAsync = TAP_ASYNC; hook.tapPromise = TAP_PROMISE; diff --git a/lib/SyncHook.js b/lib/SyncHook.js index 3009099..e2512be 100644 --- a/lib/SyncHook.js +++ b/lib/SyncHook.js @@ -32,8 +32,8 @@ const COMPILE = function(options) { return factory.create(options); }; -function SyncHook(args = []) { - const hook = new Hook(args); +function SyncHook(args = [], name = undefined) { + const hook = new Hook(args, name); hook.constructor = SyncHook; hook.tapAsync = TAP_ASYNC; hook.tapPromise = TAP_PROMISE; diff --git a/lib/SyncLoopHook.js b/lib/SyncLoopHook.js index b3375ad..be0e4fd 100644 --- a/lib/SyncLoopHook.js +++ b/lib/SyncLoopHook.js @@ -32,8 +32,8 @@ const COMPILE = function(options) { return factory.create(options); }; -function SyncLoopHook(args = []) { - const hook = new Hook(args); +function SyncLoopHook(args = [], name = undefined) { + const hook = new Hook(args, name); hook.constructor = SyncLoopHook; hook.tapAsync = TAP_ASYNC; hook.tapPromise = TAP_PROMISE; diff --git a/lib/SyncWaterfallHook.js b/lib/SyncWaterfallHook.js index b880535..c878b7f 100644 --- a/lib/SyncWaterfallHook.js +++ b/lib/SyncWaterfallHook.js @@ -41,10 +41,10 @@ const COMPILE = function(options) { return factory.create(options); }; -function SyncWaterfallHook(args = []) { +function SyncWaterfallHook(args = [], name = undefined) { if (args.length < 1) throw new Error("Waterfall hooks must have at least one argument"); - const hook = new Hook(args); + const hook = new Hook(args, name); hook.constructor = SyncWaterfallHook; hook.tapAsync = TAP_ASYNC; hook.tapPromise = TAP_PROMISE; diff --git a/tapable.d.ts b/tapable.d.ts index d3e7834..e87b34e 100644 --- a/tapable.d.ts +++ b/tapable.d.ts @@ -85,14 +85,16 @@ interface HookMapInterceptor { } export class HookMap { - constructor(factory: HookFactory); + constructor(factory: HookFactory, name?: string); + name: string | undefined; get(key: any): H | undefined; for(key: any): H; intercept(interceptor: HookMapInterceptor): void; } export class MultiHook { - constructor(hooks: H[]); + constructor(hooks: H[], name?: string); + name: string | undefined; tap(options: string | Tap, fn?: Function): void; tapAsync(options: string | Tap, fn?: Function): void; tapPromise(options: string | Tap, fn?: Function): void;