( text: string, pattern: RegExp, placeholders: string[], render: (match: string, ...groups: string[]) => string, )
| 24 | } |
| 25 | |
| 26 | function protect( |
| 27 | text: string, |
| 28 | pattern: RegExp, |
| 29 | placeholders: string[], |
| 30 | render: (match: string, ...groups: string[]) => string, |
| 31 | ): string { |
| 32 | const nextText = text.replace(pattern, (...args) => { |
| 33 | const match = args[0] as string; |
| 34 | const groups = args.slice(1, -2) as string[]; |
| 35 | const token = `${PLACEHOLDER_START}${placeholders.length}${PLACEHOLDER_END}`; |
| 36 | placeholders.push(render(match, ...groups)); |
| 37 | return token; |
| 38 | }); |
| 39 | return nextText; |
| 40 | } |
| 41 | |
| 42 | function restore(text: string, placeholders: string[]): string { |
| 43 | return text.replace( |
no outgoing calls
no test coverage detected