0.4.0 • Published 8 years ago

cssplexity v0.4.0

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

CSSplexity

A small helper to calculcate the cyclomatic complexity of CSS selectors

Build Status Coverage Status Dependency Status Dependency Status

Installation

npm install cssplexity --save-dev

Examples

Calculcate selector complexity

var cssplexity = require('cssplexity');
var result = cssplexity.selector('.teaser .article-title .headline');
console.log('Complexity: ' + result);

Parse CSS file and calculcate selector complexities

var cssplexity = require('cssplexity');
var results = cssplexity.parse('.teaser .article-title .headline { color: red } body { background: red }');
console.log(JSON.stringify(results, null, 2));

API

cssplexity.selector(selector)

Accepts a CSS selector and returns its complexity.

In case no valid CSS selector is provided, false is returned.

cssplexity.parse(code)

Accepts CSS code and returns an object containing the complexity per selector, ordered decreasingly by complexity.

In case no valid CSS selector is found within the provided CSS code, false is returned.

Changelog

  • 0.4.0
    • Remove CSS selector tree methods in favor of its own npm module
    • Update outdated dependencies
  • 0.3.0
    • Fix parser for selector-less input (e.g. comments)
  • 0.2.0
    • Fix complexity calculation to include the subject as well
  • 0.1.0
    • Fix complexity calculation to include child selectors as well
  • 0.0.2
    • Update outdated dependencies
  • 0.0.1
    • Initial version

License

Copyright (c) 2016 Thomas Rasshofer
Licensed under the MIT license.

See LICENSE for more info.

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago