estree-halstead
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

estree-halstead

Halstead complexity measures for ESTree.

Calculate complexity using Halstead complexity measures from an ESTree-compliant AST.

NPM license NPM version NPM downloads NPM downloads NPM downloads NPM downloads NPM downloads Build Status

💿 Installation

npm install estree-halstead

📖 Usage

import { analyze } from 'estree-halstead'
import acorn from 'acorn'

const ast = acorn.parse(sourceCode, options); // https://github.com/acornjs/acorn
const result /* : Result */ = analyze(ast)
console.log(result)

// declare type Result = {
//     vocabulary: number;
//     length: number;
//     volume: number;
//     difficulty: number;
//     effort: number;
//     time: number;
//     deliveredBugs: number;
// };

Note:
The calculation uses the AST, so tokens not included in the AST, such as semicolons and unwanted parenthesis tokens, are ignored. This means that the calculation result is format independent.

Readme

Keywords

Package Sidebar

Install

npm i estree-halstead

Weekly Downloads

4

Version

0.4.0

License

MIT

Unpacked Size

67.7 kB

Total Files

7

Last publish

Collaborators

  • ota-meshi