You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const Hook = require("./Hook");
  7. class MultiHook {
  8. constructor(hooks) {
  9. this.hooks = hooks;
  10. }
  11. tap(options, fn) {
  12. for (const hook of this.hooks) {
  13. hook.tap(options, fn);
  14. }
  15. }
  16. tapAsync(options, fn) {
  17. for (const hook of this.hooks) {
  18. hook.tapAsync(options, fn);
  19. }
  20. }
  21. tapPromise(options, fn) {
  22. for (const hook of this.hooks) {
  23. hook.tapPromise(options, fn);
  24. }
  25. }
  26. isUsed() {
  27. for (const hook of this.hooks) {
  28. if (hook.isUsed()) return true;
  29. }
  30. return false;
  31. }
  32. intercept(interceptor) {
  33. for (const hook of this.hooks) {
  34. hook.intercept(interceptor);
  35. }
  36. }
  37. withOptions(options) {
  38. return new MultiHook(this.hooks.map(h => h.withOptions(options)));
  39. }
  40. }
  41. module.exports = MultiHook;