source: trip-planner-front/node_modules/webpack/lib/MultiWatching.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const asyncLib = require("neo-async");
9
10/** @typedef {import("./MultiCompiler")} MultiCompiler */
11/** @typedef {import("./Watching")} Watching */
12
13/**
14 * @template T
15 * @callback Callback
16 * @param {Error=} err
17 * @param {T=} result
18 */
19
20class MultiWatching {
21 /**
22 * @param {Watching[]} watchings child compilers' watchers
23 * @param {MultiCompiler} compiler the compiler
24 */
25 constructor(watchings, compiler) {
26 this.watchings = watchings;
27 this.compiler = compiler;
28 }
29
30 invalidate(callback) {
31 if (callback) {
32 asyncLib.each(
33 this.watchings,
34 (watching, callback) => watching.invalidate(callback),
35 callback
36 );
37 } else {
38 for (const watching of this.watchings) {
39 watching.invalidate();
40 }
41 }
42 }
43
44 suspend() {
45 for (const watching of this.watchings) {
46 watching.suspend();
47 }
48 }
49
50 resume() {
51 for (const watching of this.watchings) {
52 watching.resume();
53 }
54 }
55
56 /**
57 * @param {Callback<void>} callback signals when the watcher is closed
58 * @returns {void}
59 */
60 close(callback) {
61 asyncLib.forEach(
62 this.watchings,
63 (watching, finishedCallback) => {
64 watching.close(finishedCallback);
65 },
66 err => {
67 this.compiler.hooks.watchClose.call();
68 if (typeof callback === "function") {
69 this.compiler.running = false;
70 callback(err);
71 }
72 }
73 );
74 }
75}
76
77module.exports = MultiWatching;
Note: See TracBrowser for help on using the repository browser.