( first: FileStateCache, second: FileStateCache, )
| 138 | |
| 139 | // Merge two file state caches, with more recent entries (by timestamp) overriding older ones |
| 140 | export function mergeFileStateCaches( |
| 141 | first: FileStateCache, |
| 142 | second: FileStateCache, |
| 143 | ): FileStateCache { |
| 144 | const merged = cloneFileStateCache(first) |
| 145 | for (const [filePath, fileState] of second.entries()) { |
| 146 | const existing = merged.get(filePath) |
| 147 | // Only override if the new entry is more recent |
| 148 | if (!existing || fileState.timestamp > existing.timestamp) { |
| 149 | merged.set(filePath, fileState) |
| 150 | } |
| 151 | } |
| 152 | return merged |
| 153 | } |
no test coverage detected