MCPcopy
hub / github.com/webpack/webpack / handleConstOperation

Method handleConstOperation

lib/javascript/JavascriptParser.js:991–1007  ·  view source on GitHub ↗
(operandHandler)

Source from the content-addressed store, hash-verified

989 * @returns {BasicEvaluatedExpression | undefined} the evaluated expression
990 */
991 const handleConstOperation = (operandHandler) => {
992 const left = this.evaluateExpression(expr.left);
993 if (!left.isCompileTimeValue()) return;
994
995 const right = this.evaluateExpression(expr.right);
996 if (!right.isCompileTimeValue()) return;
997
998 const result = operandHandler(
999 /** @type {T} */ (left.asCompileTimeValue()),
1000 /** @type {T} */ (right.asCompileTimeValue())
1001 );
1002 return valueAsExpression(
1003 result,
1004 expr,
1005 left.couldHaveSideEffects() || right.couldHaveSideEffects()
1006 );
1007 };
1008
1009 /**
1010 * Helper function to determine if two booleans are always different. This is used in `handleStrictEqualityComparison`

Callers

nothing calls this directly

Calls 4

evaluateExpressionMethod · 0.95
isCompileTimeValueMethod · 0.80
asCompileTimeValueMethod · 0.80
couldHaveSideEffectsMethod · 0.80

Tested by

no test coverage detected