0.2.0 • Published 5 years ago

css-analysis-diffstat v0.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

NPM Version Weekly downloads Build Status Known Vulnerabilities Dependencies Status Dependencies Status XO code style Project: Wallace

Installation

npm install css-analysis-diffstat

Usage

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
}

Related projects