0.4.0 • Published 2 months ago

estree-halstead v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

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.

0.4.0

2 months ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago