Files
med-notes/.pnpm-store/v10/files/c6/609f8e0ba91059003c7ab004b8d4c6c85061d9a2cb9d2209ddba01a309375e5c3038a0aad8cc63d4f38d21504e9da77bb7c15eb99929e06cb9db76355376b1
2025-05-09 05:30:08 +02:00

55 lines
898 B
Plaintext

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const Hook = require("./Hook");
class MultiHook {
constructor(hooks, name = undefined) {
this.hooks = hooks;
this.name = name;
}
tap(options, fn) {
for (const hook of this.hooks) {
hook.tap(options, fn);
}
}
tapAsync(options, fn) {
for (const hook of this.hooks) {
hook.tapAsync(options, fn);
}
}
tapPromise(options, fn) {
for (const hook of this.hooks) {
hook.tapPromise(options, fn);
}
}
isUsed() {
for (const hook of this.hooks) {
if (hook.isUsed()) return true;
}
return false;
}
intercept(interceptor) {
for (const hook of this.hooks) {
hook.intercept(interceptor);
}
}
withOptions(options) {
return new MultiHook(
this.hooks.map(h => h.withOptions(options)),
this.name
);
}
}
module.exports = MultiHook;