source: trip-planner-front/node_modules/@angular-devkit/schematics/src/tree/recorder.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: 2.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.UpdateRecorderBom = exports.UpdateRecorderBase = void 0;
11const exception_1 = require("../exception/exception");
12const update_buffer_1 = require("../utility/update-buffer");
13class UpdateRecorderBase {
14 constructor(entry) {
15 this._original = Buffer.from(entry.content);
16 this._content = new update_buffer_1.UpdateBuffer(entry.content);
17 this._path = entry.path;
18 }
19 static createFromFileEntry(entry) {
20 const c0 = entry.content.byteLength > 0 && entry.content.readUInt8(0);
21 const c1 = entry.content.byteLength > 1 && entry.content.readUInt8(1);
22 const c2 = entry.content.byteLength > 2 && entry.content.readUInt8(2);
23 // Check if we're BOM.
24 if (c0 == 0xef && c1 == 0xbb && c2 == 0xbf) {
25 return new UpdateRecorderBom(entry);
26 }
27 else if (c0 === 0xff && c1 == 0xfe) {
28 return new UpdateRecorderBom(entry);
29 }
30 else if (c0 === 0xfe && c1 == 0xff) {
31 return new UpdateRecorderBom(entry);
32 }
33 return new UpdateRecorderBase(entry);
34 }
35 get path() {
36 return this._path;
37 }
38 // These just record changes.
39 insertLeft(index, content) {
40 this._content.insertLeft(index, typeof content == 'string' ? Buffer.from(content) : content);
41 return this;
42 }
43 insertRight(index, content) {
44 this._content.insertRight(index, typeof content == 'string' ? Buffer.from(content) : content);
45 return this;
46 }
47 remove(index, length) {
48 this._content.remove(index, length);
49 return this;
50 }
51 apply(content) {
52 if (!content.equals(this._content.original)) {
53 throw new exception_1.ContentHasMutatedException(this.path);
54 }
55 return this._content.generate();
56 }
57}
58exports.UpdateRecorderBase = UpdateRecorderBase;
59class UpdateRecorderBom extends UpdateRecorderBase {
60 constructor(entry, _delta = 1) {
61 super(entry);
62 this._delta = _delta;
63 }
64 insertLeft(index, content) {
65 return super.insertLeft(index + this._delta, content);
66 }
67 insertRight(index, content) {
68 return super.insertRight(index + this._delta, content);
69 }
70 remove(index, length) {
71 return super.remove(index + this._delta, length);
72 }
73}
74exports.UpdateRecorderBom = UpdateRecorderBom;
Note: See TracBrowser for help on using the repository browser.