MCPcopy
hub / github.com/webpack/webpack / build

Function build

lib/dependencies/HarmonyImportGuard.js:75–94  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

73 * @returns {GuardFormula} formula node
74 */
75 const build = (node) => {
76 if (node.type === "UnaryExpression" && node.operator === "!") {
77 return ["!", build(/** @type {Expression} */ (node.argument))];
78 }
79 if (
80 node.type === "LogicalExpression" &&
81 (node.operator === "&&" ||
82 node.operator === "||" ||
83 node.operator === "??")
84 ) {
85 return [
86 node.operator,
87 build(/** @type {Expression} */ (node.left)),
88 build(/** @type {Expression} */ (node.right))
89 ];
90 }
91 const dep =
92 node.range && depByRangeStart.get(/** @type {number} */ (node.range[0]));
93 return dep ? ["v", dep] : ["?"];
94 };
95
96 const formula = build(test);
97 return hasAtom(formula) ? formula : null;

Callers 2

applyMethod · 0.85
buildGuardFormulaFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected