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