MCPcopy
hub / github.com/webpack/webpack / wrapInCondition

Function wrapInCondition

lib/ConditionalInitFragment.js:23–37  ·  view source on GitHub ↗
(condition, source)

Source from the content-addressed store, hash-verified

21 * @returns {string | Source} wrapped source
22 */
23const wrapInCondition = (condition, source) => {
24 if (typeof source === "string") {
25 return Template.asString([
26 `if (${condition}) {`,
27 Template.indent(source),
28 "}",
29 ""
30 ]);
31 }
32 return new ConcatSource(
33 `if (${condition}) {\n`,
34 new PrefixSource("\t", source),
35 "}\n"
36 );
37};
38
39/**
40 * Represents ConditionalInitFragment.

Callers 2

getContentMethod · 0.85
getEndContentMethod · 0.85

Calls 2

indentMethod · 0.80
asStringMethod · 0.45

Tested by

no test coverage detected