Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
898 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | Author Tobias Koppers @sokra
|
---|
| 4 | */
|
---|
| 5 | "use strict";
|
---|
| 6 |
|
---|
| 7 | const Hook = require("./Hook");
|
---|
| 8 |
|
---|
| 9 | class MultiHook {
|
---|
| 10 | constructor(hooks, name = undefined) {
|
---|
| 11 | this.hooks = hooks;
|
---|
| 12 | this.name = name;
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | tap(options, fn) {
|
---|
| 16 | for (const hook of this.hooks) {
|
---|
| 17 | hook.tap(options, fn);
|
---|
| 18 | }
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | tapAsync(options, fn) {
|
---|
| 22 | for (const hook of this.hooks) {
|
---|
| 23 | hook.tapAsync(options, fn);
|
---|
| 24 | }
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | tapPromise(options, fn) {
|
---|
| 28 | for (const hook of this.hooks) {
|
---|
| 29 | hook.tapPromise(options, fn);
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | isUsed() {
|
---|
| 34 | for (const hook of this.hooks) {
|
---|
| 35 | if (hook.isUsed()) return true;
|
---|
| 36 | }
|
---|
| 37 | return false;
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | intercept(interceptor) {
|
---|
| 41 | for (const hook of this.hooks) {
|
---|
| 42 | hook.intercept(interceptor);
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | withOptions(options) {
|
---|
| 47 | return new MultiHook(
|
---|
| 48 | this.hooks.map(h => h.withOptions(options)),
|
---|
| 49 | this.name
|
---|
| 50 | );
|
---|
| 51 | }
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | module.exports = MultiHook;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.