* Merges the provided values into a single result. * @param {Snapshot} snapshot1 a snapshot * @param {Snapshot} snapshot2 a snapshot * @returns {Snapshot} merged snapshot
(snapshot1, snapshot2)
| 2972 | * @returns {Snapshot} merged snapshot |
| 2973 | */ |
| 2974 | mergeSnapshots(snapshot1, snapshot2) { |
| 2975 | const snapshot = new Snapshot(); |
| 2976 | if (snapshot1.hasStartTime() && snapshot2.hasStartTime()) { |
| 2977 | snapshot.setStartTime( |
| 2978 | Math.min( |
| 2979 | /** @type {NonNullable<Snapshot[class="st">"startTime"]>} */ |
| 2980 | (snapshot1.startTime), |
| 2981 | /** @type {NonNullable<Snapshot[class="st">"startTime"]>} */ |
| 2982 | (snapshot2.startTime) |
| 2983 | ) |
| 2984 | ); |
| 2985 | } else if (snapshot2.hasStartTime()) { |
| 2986 | snapshot.startTime = snapshot2.startTime; |
| 2987 | } else if (snapshot1.hasStartTime()) { |
| 2988 | snapshot.startTime = snapshot1.startTime; |
| 2989 | } |
| 2990 | if (snapshot1.hasFileTimestamps() || snapshot2.hasFileTimestamps()) { |
| 2991 | snapshot.setFileTimestamps( |
| 2992 | mergeMaps(snapshot1.fileTimestamps, snapshot2.fileTimestamps) |
| 2993 | ); |
| 2994 | } |
| 2995 | if (snapshot1.hasFileHashes() || snapshot2.hasFileHashes()) { |
| 2996 | snapshot.setFileHashes( |
| 2997 | mergeMaps(snapshot1.fileHashes, snapshot2.fileHashes) |
| 2998 | ); |
| 2999 | } |
| 3000 | if (snapshot1.hasFileTshs() || snapshot2.hasFileTshs()) { |
| 3001 | snapshot.setFileTshs(mergeMaps(snapshot1.fileTshs, snapshot2.fileTshs)); |
| 3002 | } |
| 3003 | if (snapshot1.hasContextTimestamps() || snapshot2.hasContextTimestamps()) { |
| 3004 | snapshot.setContextTimestamps( |
| 3005 | mergeMaps(snapshot1.contextTimestamps, snapshot2.contextTimestamps) |
| 3006 | ); |
| 3007 | } |
| 3008 | if (snapshot1.hasContextHashes() || snapshot2.hasContextHashes()) { |
| 3009 | snapshot.setContextHashes( |
| 3010 | mergeMaps(snapshot1.contextHashes, snapshot2.contextHashes) |
| 3011 | ); |
| 3012 | } |
| 3013 | if (snapshot1.hasContextTshs() || snapshot2.hasContextTshs()) { |
| 3014 | snapshot.setContextTshs( |
| 3015 | mergeMaps(snapshot1.contextTshs, snapshot2.contextTshs) |
| 3016 | ); |
| 3017 | } |
| 3018 | if (snapshot1.hasMissingExistence() || snapshot2.hasMissingExistence()) { |
| 3019 | snapshot.setMissingExistence( |
| 3020 | mergeMaps(snapshot1.missingExistence, snapshot2.missingExistence) |
| 3021 | ); |
| 3022 | } |
| 3023 | if (snapshot1.hasManagedItemInfo() || snapshot2.hasManagedItemInfo()) { |
| 3024 | snapshot.setManagedItemInfo( |
| 3025 | mergeMaps(snapshot1.managedItemInfo, snapshot2.managedItemInfo) |
| 3026 | ); |
| 3027 | } |
| 3028 | if (snapshot1.hasManagedFiles() || snapshot2.hasManagedFiles()) { |
| 3029 | snapshot.setManagedFiles( |
| 3030 | mergeSets(snapshot1.managedFiles, snapshot2.managedFiles) |
| 3031 | ); |
no test coverage detected