(leftValue, rightValue, formatter = (value) => String(value))
| 1084 | } |
| 1085 | |
| 1086 | function buildCompareTone(leftValue, rightValue, formatter = (value) => String(value)) { |
| 1087 | const changed = valuesDiffer(leftValue, rightValue, formatter); |
| 1088 | let deltaClass = "delta-pill delta-pill-neutral"; |
| 1089 | |
| 1090 | if (changed) { |
| 1091 | if (!hasValue(leftValue) && hasValue(rightValue)) { |
| 1092 | deltaClass = "delta-pill delta-pill-added"; |
| 1093 | } else if (hasValue(leftValue) && !hasValue(rightValue)) { |
| 1094 | deltaClass = "delta-pill delta-pill-removed"; |
| 1095 | } else if (Number.isFinite(leftValue) && Number.isFinite(rightValue)) { |
| 1096 | deltaClass = rightValue >= leftValue ? "delta-pill delta-pill-added" : "delta-pill delta-pill-removed"; |
| 1097 | } else { |
| 1098 | deltaClass = "delta-pill delta-pill-changed"; |
| 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | return { |
| 1103 | changed, |
| 1104 | leftClass: changed && hasValue(leftValue) ? "diff-removed" : "", |
| 1105 | rightClass: changed && hasValue(rightValue) ? "diff-added" : "", |
| 1106 | deltaClass, |
| 1107 | }; |
| 1108 | } |
| 1109 | |
| 1110 | function mergeByLabel(leftItems, rightItems, getLabel) { |
| 1111 | const map = new Map(); |
no test coverage detected