(value: unknown, nameMap: Map<string, string>)
| 283 | } |
| 284 | |
| 285 | function updateValueReferences(value: unknown, nameMap: Map<string, string>): unknown { |
| 286 | if (typeof value === 'string') { |
| 287 | let updatedValue = value |
| 288 | nameMap.forEach((newName, oldName) => { |
| 289 | const regex = new RegExp(`<${oldName}\\.`, 'g') |
| 290 | updatedValue = updatedValue.replace(regex, `<${newName}.`) |
| 291 | }) |
| 292 | return updatedValue |
| 293 | } |
| 294 | if (Array.isArray(value)) { |
| 295 | return value.map((item) => updateValueReferences(item, nameMap)) |
| 296 | } |
| 297 | if (value && typeof value === 'object') { |
| 298 | const result: Record<string, unknown> = {} |
| 299 | for (const [key, val] of Object.entries(value)) { |
| 300 | result[key] = updateValueReferences(val, nameMap) |
| 301 | } |
| 302 | return result |
| 303 | } |
| 304 | return value |
| 305 | } |
| 306 | |
| 307 | function updateBlockReferences( |
| 308 | blocks: Record<string, BlockState>, |
no test coverage detected