(
contentOrChanges: MergeableChanges | MergeableContent,
isContent: 0 | 1 = 0,
)
| 182 | }; |
| 183 | |
| 184 | const mergeContentOrChanges = ( |
| 185 | contentOrChanges: MergeableChanges | MergeableContent, |
| 186 | isContent: 0 | 1 = 0, |
| 187 | ): Changes => { |
| 188 | const tablesChanges = {}; |
| 189 | const valuesChanges = {}; |
| 190 | const [ |
| 191 | [tablesObj, incomingTablesHlc = EMPTY_STRING, incomingTablesHash = 0], |
| 192 | values, |
| 193 | ] = contentOrChanges as typeof isContent extends 1 |
| 194 | ? MergeableContent |
| 195 | : MergeableChanges; |
| 196 | const [tablesStampMap, valuesStampMap] = contentStampMap; |
| 197 | const [tableStampMaps, oldTablesHlc, oldTablesHash] = tablesStampMap; |
| 198 | |
| 199 | let tablesHash = isContent ? incomingTablesHash : oldTablesHash; |
| 200 | let tablesHlc = incomingTablesHlc; |
| 201 | objForEach( |
| 202 | tablesObj, |
| 203 | ( |
| 204 | [rowsObj, incomingTableHlc = EMPTY_STRING, incomingTableHash = 0], |
| 205 | tableId, |
| 206 | ) => { |
| 207 | const tableStampMap = mapEnsure<Id, TableStampMap>( |
| 208 | tableStampMaps, |
| 209 | tableId, |
| 210 | stampNewMap, |
| 211 | ); |
| 212 | const [rowStampMaps, oldTableHlc, oldTableHash] = tableStampMap; |
| 213 | let tableHash = isContent ? incomingTableHash : oldTableHash; |
| 214 | let tableHlc = incomingTableHlc; |
| 215 | objForEach(rowsObj, (row, rowId) => { |
| 216 | const [rowHlc, oldRowHash, rowHash] = mergeCellsOrValues( |
| 217 | row, |
| 218 | mapEnsure<Id, RowStampMap>(rowStampMaps, rowId, stampNewMap), |
| 219 | objEnsure<IdObj<CellOrUndefined>>( |
| 220 | objEnsure<IdObj<IdObj<CellOrUndefined>>>( |
| 221 | tablesChanges, |
| 222 | tableId, |
| 223 | objNew, |
| 224 | ), |
| 225 | rowId, |
| 226 | objNew, |
| 227 | ), |
| 228 | isContent, |
| 229 | ); |
| 230 | |
| 231 | tableHash ^= isContent |
| 232 | ? 0 |
| 233 | : addOrRemoveHash( |
| 234 | oldRowHash ? getValueInValuesHash(rowId, oldRowHash) : 0, |
| 235 | getValueInValuesHash(rowId, rowHash), |
| 236 | ); |
| 237 | tableHlc = getLatestHlc(tableHlc, rowHlc); |
| 238 | }); |
| 239 | |
| 240 | tableHash ^= isContent |
| 241 | ? 0 |
no test coverage detected
searching dependent graphs…