Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
8 | */
|
---|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
10 | exports.WatcherNotifier = void 0;
|
---|
11 | class WatcherDescriptor {
|
---|
12 | constructor(files, directories, callback) {
|
---|
13 | this.files = files;
|
---|
14 | this.directories = directories;
|
---|
15 | this.callback = callback;
|
---|
16 | }
|
---|
17 | shouldNotify(path) {
|
---|
18 | return true;
|
---|
19 | }
|
---|
20 | }
|
---|
21 | class WatcherNotifier {
|
---|
22 | constructor() {
|
---|
23 | this.descriptors = new Set();
|
---|
24 | }
|
---|
25 | notify(events) {
|
---|
26 | for (const descriptor of this.descriptors) {
|
---|
27 | for (const { path } of events) {
|
---|
28 | if (descriptor.shouldNotify(path)) {
|
---|
29 | descriptor.callback([...events]);
|
---|
30 | break;
|
---|
31 | }
|
---|
32 | }
|
---|
33 | }
|
---|
34 | }
|
---|
35 | watch(files, directories, callback) {
|
---|
36 | const descriptor = new WatcherDescriptor(new Set(files), new Set(directories), callback);
|
---|
37 | this.descriptors.add(descriptor);
|
---|
38 | return { close: () => this.descriptors.delete(descriptor) };
|
---|
39 | }
|
---|
40 | }
|
---|
41 | exports.WatcherNotifier = WatcherNotifier;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.