MCPcopy Create free account
hub / github.com/angular/angular / guardedExpression

Function guardedExpression

packages/compiler/src/render3/util.ts:61–76  ·  view source on GitHub ↗
(guard: string, expr: o.Expression)

Source from the content-addressed store, hash-verified

59}
60
61function guardedExpression(guard: string, expr: o.Expression): o.Expression {
62 const guardExpr = new o.ExternalExpr({name: guard, moduleName: null});
63 const guardNotDefined = new o.BinaryOperatorExpr(
64 o.BinaryOperator.Identical,
65 new o.TypeofExpr(guardExpr),
66 o.literal('undefined'),
67 );
68 const guardUndefinedOrTrue = new o.BinaryOperatorExpr(
69 o.BinaryOperator.Or,
70 guardNotDefined,
71 guardExpr,
72 /* type */ undefined,
73 /* sourceSpan */ undefined,
74 );
75 return new o.BinaryOperatorExpr(o.BinaryOperator.And, guardUndefinedOrTrue, expr);
76}
77
78export function wrapReference(value: any): R3Reference {
79 const wrapped = new o.WrappedNodeExpr(value);

Callers 2

jitOnlyGuardedExpressionFunction · 0.85
devOnlyGuardedExpressionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected