(strs: TemplateStringsArray, ...args: (CodeArg | string[])[])
| 86 | const plus = new _Code("+") |
| 87 | |
| 88 | export function str(strs: TemplateStringsArray, ...args: (CodeArg | string[])[]): _Code { |
| 89 | const expr: CodeItem[] = [safeStringify(strs[0])] |
| 90 | let i = 0 |
| 91 | while (i < args.length) { |
| 92 | expr.push(plus) |
| 93 | addCodeArg(expr, args[i]) |
| 94 | expr.push(plus, safeStringify(strs[++i])) |
| 95 | } |
| 96 | optimize(expr) |
| 97 | return new _Code(expr) |
| 98 | } |
| 99 | |
| 100 | export function addCodeArg(code: CodeItem[], arg: CodeArg | string[]): void { |
| 101 | if (arg instanceof _Code) code.push(...arg._items) |
no test coverage detected