Skip to content
A small helper to calculcate the Halstead metrics of CSS selectors
JavaScript CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
.travis.yml
LICENSE
README.md
halcsstead.js
package.json

README.md

HalCSStead

A small helper to calculcate the Halstead metrics of CSS selectors

Build Status Coverage Status Dependency Status Dependency Status

Installation

npm install halcsstead --save-dev

Examples

Calculcate selector metrics

var halcsstead = require('halcsstead');
var metrics = halcsstead.selector('.teaser .article-title .headline');
console.log(JSON.stringify(metrics, null, 2));

Parse CSS file and calculcate selector metrics

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

API

halcsstead.selector(selector)

Accepts a CSS selector and returns its metrics.

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

halcsstead.parse(code)

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

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

Changelog

  • 0.0.2
    • Use custom calculation of Math.log2 to prevent issues with older Node.js versions
  • 0.0.1
    • Initial version

License

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

See LICENSE for more info.

You can’t perform that action at this time.