Get a git-like diffstat from a css-analyzer-diff and see how much your stats have changed.
npm install css-analysis-diffstat
const cssAnalysisDiffStat = require('css-analysis-diffstat')
// Diff calculated by https://github.com/bartveneman/css-analyzer-diff
const cssAnalyzerDiff = {
'colors.total': {
oldValue: 2,
newValue: 4,
changed: true,
diff: {absolute: 2, relative: 1}
},
'rules.total': {
oldValue: 4,
newValue: 2,
changed: true,
diff: {absolute: -2, relative: -0.5}
},
'declarations.importants.total': {
oldValue: 1,
newValue: 0,
changed: true,
diff: {absolute: -1, relative: -1}
},
'selectors.identifiers.max.value': {
oldValue: 'oldValue',
newValue: 'newValue',
changed: true
},
'colors.unique': [
{
value: 'red',
added: true,
changed: true,
removed: false
},
{
value: 'blue',
added: false,
changed: false,
removed: false
}
]
}
const diffStat = cssAnalysisDiffStat(cssAnalyzerDiff)
// =>
{
changes: 5,
additions: 4,
deletions: 4,
changeRatio: 0.8,
additionRatio: 0.5,
deletionRatio: 0.5
}
- CSS Analyzer Analytics for CSS
- css-analyzer-diff Calculate the difference between two sets of CSS stats