UNPKG

1.59 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.BuildGraph = void 0;
4const nodes_1 = require("../ng-package/nodes");
5/**
6 * A tree of source files. Eventually, it's a graph. Ideally, it's an acyclic directed graph.
7 * Technically, it's implemented as a map-like collection with references between map entries.
8 */
9class BuildGraph {
10 constructor() {
11 this.store = new Map();
12 }
13 put(value) {
14 if (value instanceof Array) {
15 value.forEach(node => this.insert(node));
16 }
17 else {
18 this.insert(value);
19 }
20 return this;
21 }
22 insert(node) {
23 if (this.store.has(node.url)) {
24 // Clean up dependee references
25 const oldNode = this.store.get(node.url);
26 oldNode['_dependees'].delete(oldNode);
27 }
28 if (this.watcher && node.url.startsWith(nodes_1.URL_PROTOCOL_FILE)) {
29 this.watcher.add(node.url.slice(nodes_1.URL_PROTOCOL_FILE.length));
30 }
31 this.store.set(node.url, node);
32 }
33 get(url) {
34 return this.store.get(url);
35 }
36 has(url) {
37 return this.store.has(url);
38 }
39 entries() {
40 const values = this.store.values();
41 return Array.from(values);
42 }
43 some(by) {
44 return this.entries().some(by);
45 }
46 filter(by) {
47 return this.entries().filter(by);
48 }
49 find(by) {
50 return this.entries().find(by);
51 }
52 get size() {
53 return this.store.size;
54 }
55}
56exports.BuildGraph = BuildGraph;
57//# sourceMappingURL=build-graph.js.map
\No newline at end of file