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

Function guardedExpression

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

Source from the content-addressed store, hash-verified

146}
147
148function guardedExpression(guard: string, expr: o.Expression): o.Expression {
149 const guardExpr = new o.ExternalExpr({name: guard, moduleName: null});
150 const guardNotDefined = new o.BinaryOperatorExpr(
151 o.BinaryOperator.Identical,
152 new o.TypeofExpr(guardExpr),
153 o.literal('undefined'),
154 );
155 const guardUndefinedOrTrue = new o.BinaryOperatorExpr(
156 o.BinaryOperator.Or,
157 guardNotDefined,
158 guardExpr,
159 /* type */ undefined,
160 /* sourceSpan */ undefined,
161 );
162 return new o.BinaryOperatorExpr(o.BinaryOperator.And, guardUndefinedOrTrue, expr);
163}
164
165export function wrapReference(value: any): R3Reference {
166 const wrapped = new o.WrappedNodeExpr(value);

Callers 2

jitOnlyGuardedExpressionFunction · 0.85
devOnlyGuardedExpressionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected