source: trip-planner-front/node_modules/@angular-devkit/build-optimizer/src/helpers/ast-utils.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: 3.1 KB
RevLine 
[6a3a178]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 */
9var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10 if (k2 === undefined) k2 = k;
11 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12}) : (function(o, m, k, k2) {
13 if (k2 === undefined) k2 = k;
14 o[k2] = m[k];
15}));
16var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17 Object.defineProperty(o, "default", { enumerable: true, value: v });
18}) : function(o, v) {
19 o["default"] = v;
20});
21var __importStar = (this && this.__importStar) || function (mod) {
22 if (mod && mod.__esModule) return mod;
23 var result = {};
24 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25 __setModuleDefault(result, mod);
26 return result;
27};
28Object.defineProperty(exports, "__esModule", { value: true });
29exports.getCleanHelperName = exports.isHelperName = exports.hasPureComment = exports.addPureComment = exports.collectDeepNodes = void 0;
30const tslib = __importStar(require("tslib"));
31const ts = __importStar(require("typescript"));
32const pureFunctionComment = '@__PURE__';
33// We include only exports that start with '__' because tslib helpers
34// all start with a suffix of two underscores.
35const tslibHelpers = new Set(Object.keys(tslib).filter((h) => h.startsWith('__')));
36// Find all nodes from the AST in the subtree of node of SyntaxKind kind.
37function collectDeepNodes(node, kind) {
38 const nodes = [];
39 const helper = (child) => {
40 if (child.kind === kind) {
41 nodes.push(child);
42 }
43 ts.forEachChild(child, helper);
44 };
45 ts.forEachChild(node, helper);
46 return nodes;
47}
48exports.collectDeepNodes = collectDeepNodes;
49function addPureComment(node) {
50 return ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, pureFunctionComment, false);
51}
52exports.addPureComment = addPureComment;
53function hasPureComment(node) {
54 if (!node) {
55 return false;
56 }
57 const leadingComment = ts.getSyntheticLeadingComments(node);
58 return !!leadingComment && leadingComment.some((comment) => comment.text === pureFunctionComment);
59}
60exports.hasPureComment = hasPureComment;
61function isHelperName(name) {
62 return tslibHelpers.has(name);
63}
64exports.isHelperName = isHelperName;
65/**
66 * In FESM's when not using `importHelpers` there might be multiple in the same file.
67 @example
68 ```
69 var __decorate$1 = '';
70 var __decorate$2 = '';
71 ```
72 * @returns Helper name without the '$' and number suffix or `undefined` if it's not a helper.
73 */
74function getCleanHelperName(name) {
75 const parts = name.split('$');
76 const cleanName = parts[0];
77 if (parts.length > 2 || (parts.length === 2 && isNaN(+parts[1]))) {
78 return undefined;
79 }
80 return isHelperName(cleanName) ? cleanName : undefined;
81}
82exports.getCleanHelperName = getCleanHelperName;
Note: See TracBrowser for help on using the repository browser.