css-analysis-diffstat

0.2.0 • Public • Published

css-analysis-diffstat

Get a git-like diffstat from a css-analyzer-diff and see how much your stats have changed.

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

Package Sidebar

Install

npm i css-analysis-diffstat

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

7.42 kB

Total Files

7

Last publish

Collaborators

  • bartveneman