Projekt

Obecné

Profil

Stáhnout (839 Bajtů) Statistiky
| Větev: | Revize:
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) {
11
		this.hooks = hooks;
12
	}
13

    
14
	tap(options, fn) {
15
		for (const hook of this.hooks) {
16
			hook.tap(options, fn);
17
		}
18
	}
19

    
20
	tapAsync(options, fn) {
21
		for (const hook of this.hooks) {
22
			hook.tapAsync(options, fn);
23
		}
24
	}
25

    
26
	tapPromise(options, fn) {
27
		for (const hook of this.hooks) {
28
			hook.tapPromise(options, fn);
29
		}
30
	}
31

    
32
	isUsed() {
33
		for (const hook of this.hooks) {
34
			if (hook.isUsed()) return true;
35
		}
36
		return false;
37
	}
38

    
39
	intercept(interceptor) {
40
		for (const hook of this.hooks) {
41
			hook.intercept(interceptor);
42
		}
43
	}
44

    
45
	withOptions(options) {
46
		return new MultiHook(this.hooks.map(h => h.withOptions(options)));
47
	}
48
}
49

    
50
module.exports = MultiHook;
(10-10/16)