( variables: Record<string, string>, input: string )
| 1 | export const replaceVariables = ( |
| 2 | variables: Record<string, string>, |
| 3 | input: string |
| 4 | ): string => { |
| 5 | const findVarRegex = /\$[A-Za-z0-9_]+/gm |
| 6 | return input.replaceAll(findVarRegex, match => { |
| 7 | if (!(match in variables)) { |
| 8 | throw new Error(`No such variable ${match}`) |
| 9 | } |
| 10 | return variables[match] |
| 11 | }) |
| 12 | } |
| 13 | |
| 14 | export const isSurrogate = (str: string, pos: number): boolean => { |
| 15 | return ( |