Skip to content

A small helper to calculcate the Halstead metrics of CSS selectors

License

Notifications You must be signed in to change notification settings

rasshofer/halcsstead

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A small helper to calculcate the Halstead metrics of CSS selectors

Resources

License

Stars

Watchers

Forks

Packages

No packages published