MCPcopy Index your code
hub / github.com/angular/angular / guardedExpression

Function guardedExpression

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

Source from the content-addressed store, hash-verified

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

Callers 2

jitOnlyGuardedExpressionFunction · 0.85
devOnlyGuardedExpressionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…