A small helper to calculcate the Halstead metrics of CSS selectors
npm install halcsstead --save-devvar halcsstead = require('halcsstead');
var metrics = halcsstead.selector('.teaser .article-title .headline');
console.log(JSON.stringify(metrics, null, 2));var halcsstead = require('halcsstead');
var results = halcsstead.parse('.teaser .article-title .headline { color: red } body { background: red }');
console.log(JSON.stringify(results, null, 2));Accepts a CSS selector and returns its metrics.
In case no valid CSS selector is provided, false is returned.
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.
- 0.0.2
- Use custom calculation of Math.log2 to prevent issues with older Node.js versions
- 0.0.1
- Initial version
Copyright (c) 2016 Thomas Rasshofer
Licensed under the MIT license.
See LICENSE for more info.