| 146 | } |
| 147 | |
| 148 | export function ToRStringLiteral(s: string, quote: string): string { |
| 149 | if (s === undefined) { |
| 150 | return 'NULL'; |
| 151 | } |
| 152 | |
| 153 | return (quote + |
| 154 | s.replace(/\\/g, '\\\\') |
| 155 | .replace(/"""/g, `\\${quote}`) |
| 156 | .replace(/\\n/g, '\\n') |
| 157 | .replace(/\\r/g, '\\r') |
| 158 | .replace(/\\t/g, '\\t') |
| 159 | .replace(/\\b/g, '\\b') |
| 160 | .replace(/\\a/g, '\\a') |
| 161 | .replace(/\\f/g, '\\f') |
| 162 | .replace(/\\v/g, '\\v') + |
| 163 | quote); |
| 164 | } |
| 165 | |
| 166 | export async function delay(ms: number): Promise<unknown> { |
| 167 | return new Promise((resolve) => setTimeout(resolve, ms)); |