0.0.2 • Published 8 years ago

halcsstead v0.0.2

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

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.