Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cssplexity

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cssplexity

A small helper to calculcate the cyclomatic complexity of CSS selectors

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 25 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc