source: trip-planner-front/node_modules/@angular/compiler/src/render3/partial/util.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: 12.1 KB
Line 
1(function (factory) {
2 if (typeof module === "object" && typeof module.exports === "object") {
3 var v = factory(require, exports);
4 if (v !== undefined) module.exports = v;
5 }
6 else if (typeof define === "function" && define.amd) {
7 define("@angular/compiler/src/render3/partial/util", ["require", "exports", "@angular/compiler/src/output/output_ast", "@angular/compiler/src/render3/r3_identifiers", "@angular/compiler/src/render3/view/util"], factory);
8 }
9})(function (require, exports) {
10 "use strict";
11 Object.defineProperty(exports, "__esModule", { value: true });
12 exports.generateForwardRef = exports.compileDependency = exports.compileDependencies = exports.toOptionalLiteralMap = exports.toOptionalLiteralArray = void 0;
13 /**
14 * @license
15 * Copyright Google LLC All Rights Reserved.
16 *
17 * Use of this source code is governed by an MIT-style license that can be
18 * found in the LICENSE file at https://angular.io/license
19 */
20 var o = require("@angular/compiler/src/output/output_ast");
21 var r3_identifiers_1 = require("@angular/compiler/src/render3/r3_identifiers");
22 var util_1 = require("@angular/compiler/src/render3/view/util");
23 /**
24 * Creates an array literal expression from the given array, mapping all values to an expression
25 * using the provided mapping function. If the array is empty or null, then null is returned.
26 *
27 * @param values The array to transfer into literal array expression.
28 * @param mapper The logic to use for creating an expression for the array's values.
29 * @returns An array literal expression representing `values`, or null if `values` is empty or
30 * is itself null.
31 */
32 function toOptionalLiteralArray(values, mapper) {
33 if (values === null || values.length === 0) {
34 return null;
35 }
36 return o.literalArr(values.map(function (value) { return mapper(value); }));
37 }
38 exports.toOptionalLiteralArray = toOptionalLiteralArray;
39 /**
40 * Creates an object literal expression from the given object, mapping all values to an expression
41 * using the provided mapping function. If the object has no keys, then null is returned.
42 *
43 * @param object The object to transfer into an object literal expression.
44 * @param mapper The logic to use for creating an expression for the object's values.
45 * @returns An object literal expression representing `object`, or null if `object` does not have
46 * any keys.
47 */
48 function toOptionalLiteralMap(object, mapper) {
49 var entries = Object.keys(object).map(function (key) {
50 var value = object[key];
51 return { key: key, value: mapper(value), quoted: true };
52 });
53 if (entries.length > 0) {
54 return o.literalMap(entries);
55 }
56 else {
57 return null;
58 }
59 }
60 exports.toOptionalLiteralMap = toOptionalLiteralMap;
61 function compileDependencies(deps) {
62 if (deps === 'invalid') {
63 // The `deps` can be set to the string "invalid" by the `unwrapConstructorDependencies()`
64 // function, which tries to convert `ConstructorDeps` into `R3DependencyMetadata[]`.
65 return o.literal('invalid');
66 }
67 else if (deps === null) {
68 return o.literal(null);
69 }
70 else {
71 return o.literalArr(deps.map(compileDependency));
72 }
73 }
74 exports.compileDependencies = compileDependencies;
75 function compileDependency(dep) {
76 var depMeta = new util_1.DefinitionMap();
77 depMeta.set('token', dep.token);
78 if (dep.attributeNameType !== null) {
79 depMeta.set('attribute', o.literal(true));
80 }
81 if (dep.host) {
82 depMeta.set('host', o.literal(true));
83 }
84 if (dep.optional) {
85 depMeta.set('optional', o.literal(true));
86 }
87 if (dep.self) {
88 depMeta.set('self', o.literal(true));
89 }
90 if (dep.skipSelf) {
91 depMeta.set('skipSelf', o.literal(true));
92 }
93 return depMeta.toLiteralMap();
94 }
95 exports.compileDependency = compileDependency;
96 /**
97 * Generate an expression that has the given `expr` wrapped in the following form:
98 *
99 * ```
100 * forwardRef(() => expr)
101 * ```
102 */
103 function generateForwardRef(expr) {
104 return o.importExpr(r3_identifiers_1.Identifiers.forwardRef).callFn([o.fn([], [new o.ReturnStatement(expr)])]);
105 }
106 exports.generateForwardRef = generateForwardRef;
107});
108//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9yZW5kZXIzL3BhcnRpYWwvdXRpbC50cyJdLCJuYW1lcyI6W10sIm1h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