(input: Record<string, any>, key: string)
| 184 | } |
| 185 | |
| 186 | export function findOutputKeys(input: Record<string, any>, key: string): string[] { |
| 187 | const regex = new RegExp(`{{\\s*${key}\\.(\\w+)\\s*}}`, 'g') |
| 188 | const matches: string[] = [] |
| 189 | |
| 190 | for (const inputKey in input) { |
| 191 | if (typeof input[inputKey] === 'object' && input[inputKey] !== null) { |
| 192 | const keys = findOutputKeys(input[inputKey], key) |
| 193 | for (const key of keys) { |
| 194 | matches.push(key) |
| 195 | } |
| 196 | } else if (typeof input[inputKey] === 'string') { |
| 197 | let match |
| 198 | while ((match = regex.exec(input[inputKey])) !== null) { |
| 199 | matches.push(match[1]) |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | return matches |
| 205 | } |
| 206 | |
| 207 | export function strToInterpolationKey(str: string): string { |
| 208 | return str.replace(/[^a-zA-Z0-9]/g, '_') |
no outgoing calls
no test coverage detected