( first: FileStateCache, second: FileStateCache, )
| 127 | |
| 128 | // Merge two file state caches, with more recent entries (by timestamp) overriding older ones |
| 129 | export function mergeFileStateCaches( |
| 130 | first: FileStateCache, |
| 131 | second: FileStateCache, |
| 132 | ): FileStateCache { |
| 133 | const merged = cloneFileStateCache(first) |
| 134 | for (const [filePath, fileState] of second.entries()) { |
| 135 | const existing = merged.get(filePath) |
| 136 | // Only override if the new entry is more recent |
| 137 | if (!existing || fileState.timestamp > existing.timestamp) { |
| 138 | merged.set(filePath, fileState) |
| 139 | } |
| 140 | } |
| 141 | return merged |
| 142 | } |
| 143 |
no test coverage detected