(condition, source)
| 21 | * @returns {string | Source} wrapped source |
| 22 | */ |
| 23 | const 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. |
no test coverage detected