source: trip-planner-front/node_modules/@angular/compiler/esm2015/src/render3/util.js@ 1ad8e64

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

initial commit

  • Property mode set to 100644
File size: 9.1 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { escapeIdentifier } from '../output/abstract_emitter';
9import * as o from '../output/output_ast';
10export function typeWithParameters(type, numParams) {
11 if (numParams === 0) {
12 return o.expressionType(type);
13 }
14 const params = [];
15 for (let i = 0; i < numParams; i++) {
16 params.push(o.DYNAMIC_TYPE);
17 }
18 return o.expressionType(type, undefined, params);
19}
20const ANIMATE_SYMBOL_PREFIX = '@';
21export function prepareSyntheticPropertyName(name) {
22 return `${ANIMATE_SYMBOL_PREFIX}${name}`;
23}
24export function prepareSyntheticListenerName(name, phase) {
25 return `${ANIMATE_SYMBOL_PREFIX}${name}.${phase}`;
26}
27export function getSafePropertyAccessString(accessor, name) {
28 const escapedName = escapeIdentifier(name, false, false);
29 return escapedName !== name ? `${accessor}[${escapedName}]` : `${accessor}.${name}`;
30}
31export function prepareSyntheticListenerFunctionName(name, phase) {
32 return `animation_${name}_${phase}`;
33}
34export function jitOnlyGuardedExpression(expr) {
35 return guardedExpression('ngJitMode', expr);
36}
37export function devOnlyGuardedExpression(expr) {
38 return guardedExpression('ngDevMode', expr);
39}
40export function guardedExpression(guard, expr) {
41 const guardExpr = new o.ExternalExpr({ name: guard, moduleName: null });
42 const guardNotDefined = new o.BinaryOperatorExpr(o.BinaryOperator.Identical, new o.TypeofExpr(guardExpr), o.literal('undefined'));
43 const guardUndefinedOrTrue = new o.BinaryOperatorExpr(o.BinaryOperator.Or, guardNotDefined, guardExpr, /* type */ undefined,
44 /* sourceSpan */ undefined, true);
45 return new o.BinaryOperatorExpr(o.BinaryOperator.And, guardUndefinedOrTrue, expr);
46}
47export function wrapReference(value) {
48 const wrapped = new o.WrappedNodeExpr(value);
49 return { value: wrapped, type: wrapped };
50}
51export function refsToArray(refs, shouldForwardDeclare) {
52 const values = o.literalArr(refs.map(ref => ref.value));
53 return shouldForwardDeclare ? o.fn([], [new o.ReturnStatement(values)]) : values;
54}
55//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9yZW5kZXIzL3V0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLGdCQUFnQixFQUFDLE1BQU0sNEJBQTRCLENBQUM7QUFDNUQsT0FBTyxLQUFLLENBQUMsTUFBTSxzQkFBc0IsQ0FBQztBQUUxQyxNQUFNLFVBQVUsa0JBQWtCLENBQUMsSUFBa0IsRUFBRSxTQUFpQjtJQUN0RSxJQUFJLFNBQVMsS0FBSyxDQUFDLEVBQUU7UUFDbkIsT0FBTyxDQUFDLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQyxDQUFDO0tBQy9CO0lBQ0QsTUFBTSxNQUFNLEdBQWEsRUFBRSxDQUFDO0lBQzVCLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsR0FBRyxTQUFTLEVBQUUsQ0FBQyxFQUFFLEVBQUU7UUFDbEMsTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsWUFBWSxDQUFDLENBQUM7S0FDN0I7SUFDRCxPQUFPLENBQUMsQ0FBQyxjQUFjLENBQUMsSUFBSSxFQUFFLFNBQVMsRUFBRSxNQUFNLENBQUMsQ0FBQztBQUNuRCxDQUFDO0FBZ0JELE1BQU0scUJBQXFCLEdBQUcsR0FBRyxDQUFDO0FBQ2xDLE1BQU0sVUFBVSw0QkFBNEIs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