source: trip-planner-front/node_modules/@angular-devkit/core/src/workspace/json/metadata.js@ 6a80231

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

initial commit

  • Property mode set to 100644
File size: 1.6 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 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.JsonWorkspaceMetadata = exports.JsonWorkspaceSymbol = void 0;
11exports.JsonWorkspaceSymbol = Symbol.for('@angular/core:workspace-json');
12class JsonWorkspaceMetadata {
13 constructor(filePath, ast, raw) {
14 this.filePath = filePath;
15 this.ast = ast;
16 this.raw = raw;
17 this.changes = [];
18 }
19 get hasChanges() {
20 return this.changes.length > 0;
21 }
22 get changeCount() {
23 return this.changes.length;
24 }
25 findChangesForPath(path) {
26 return this.changes.filter((c) => c.path === path);
27 }
28 addChange(op, path, node, value, type) {
29 // Remove redundant operations
30 if (op === 'remove' || op === 'replace') {
31 for (let i = this.changes.length - 1; i >= 0; --i) {
32 const currentPath = this.changes[i].path;
33 if (currentPath === path || currentPath.startsWith(path + '/')) {
34 if (op === 'replace' && currentPath === path && this.changes[i].op === 'add') {
35 op = 'add';
36 }
37 this.changes.splice(i, 1);
38 }
39 }
40 }
41 this.changes.push({ op, path, node, value, type: op === 'remove' || !type ? 'json' : type });
42 }
43 reset() {
44 this.changes.length = 0;
45 }
46}
47exports.JsonWorkspaceMetadata = JsonWorkspaceMetadata;
Note: See TracBrowser for help on using the repository browser.