(s: string)
| 138 | * Escape a string for use inside a double-quoted TypeScript string literal. |
| 139 | */ |
| 140 | export function escapeStringLiteral(s: string): string { |
| 141 | let out = ""; |
| 142 | for (const ch of s) { |
| 143 | if (ch === "\\") out += "\\\\"; |
| 144 | else if (ch === '"') out += '\\"'; |
| 145 | else if (ch === "\n") out += "\\n"; |
| 146 | else if (ch === "\r") out += "\\r"; |
| 147 | else if (ch === "\t") out += "\\t"; |
| 148 | else if (ch === "\u2028") out += "\\u2028"; |
| 149 | else if (ch === "\u2029") out += "\\u2029"; |
| 150 | else out += escapeControlChar(ch); |
| 151 | } |
| 152 | return out; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Escape a string for use inside a JSDoc comment. |
no test coverage detected