Registry / testing / typhonjs-escomplex

typhonjs-escomplex

JSON →
library0.1.0jsnpmunverified

Next generation JavaScript and TypeScript complexity reporting module powered by the Babel parser. Version 0.1.0 is current, but this project appears to be in an early/alpha state with active development. It computes cyclomatic complexity, Halstead metrics, maintainability index, and dependency analysis. Unlike older complexity tools (e.g., escomplex), this uses the full Babel parser with all plugins enabled, supporting modern JS and TS syntax out of the box. The library is designed as a modular shim; separate sub-packages handle AST processing independently. Note that breaking report format changes occurred in 0.1.0.

npm install typhonjs-escomplex
INSTALL
IMPORT
SIG · TYPHONJS-ESCOMPLEX
T
typhonjs-escomplex
testingjavascriptv0.1.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

escomplex
✓ import escomplex from 'typhonjs-escomplex';
✗ import { escomplex } from 'typhonjs-escomplex';
Use default import for ESM. The module exports a single default object.
escomplex
✓ const escomplex = require('typhonjs-escomplex');
✗ const { escomplex } = require('typhonjs-escomplex');
CommonJS require returns the default export directly. Named destructuring is incorrect.
analyzeModule
✓ escomplex.analyzeModule(source);
✗ escomplex.analyzeModule('source');
Pass a string of source code, not a file path. For file analysis, read the file first.

Analyze a JavaScript file for complexity metrics including cyclomatic, Halstead, and maintainability index.

import escomplex from 'typhonjs-escomplex'; import { readFileSync } from 'fs'; const source = readFileSync('./example.js', 'utf8'); const report = escomplex.analyzeModule(source); console.log(JSON.stringify(report, null, 2));
Debug
Known issues
breakingReport format changed significantly in version 0.1.0.
fix
Review the 0.1.0 update guide at https://github.com/typhonjs-node-escomplex/typhonjs-escomplex/wiki/0.1.0-update-guide and adjust any consumers that parse the report structure.
affects: >=0.1.0
deprecatedThis package is a shim over @babel/parser. For direct AST processing, use the individual sub-packages in the typhonjs-node-escomplex organization.
fix
If you need fine-grained control, use @babel/parser + typhonjs-escomplex-* modules directly.
affects: *
gotchaThe analyzeModule function expects source code as a string, not a file path.
fix
Use fs.readFileSync to read the file content before passing it.
affects: *
gotchaOnly CommonJS and ES module inputs are supported; no UMD or browser build provided.
fix
Use a bundler like webpack or rollup if you need to run in the browser.
affects: *
Errors
Common errors & fixes
TypeError: escomplex.analyzeModule is not a function
Importing the module incorrectly (e.g., named import instead of default).
fix
Use `import escomplex from 'typhonjs-escomplex'` or `const escomplex = require('typhonjs-escomplex')`.
SyntaxError: Unexpected token (1:1) while parsing
Passing a file path string instead of source code content to analyzeModule.
fix
Read the file content first: `const source = fs.readFileSync(filePath, 'utf8');` then pass `source`.
Error: Could not find module: @babel/parser
Missing @babel/parser peer dependency.
fix
Run `npm install @babel/parser` (or yarn add) to install the peer dependency.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
@babel/parserrequiredAll-in-one Babel parser with all plugins enabled to produce the AST for complexity analysis.
Agent activity
16 hits · last 30 days
node
16
Resources
typhonjs-escomplex — npm install typhonjs-escomplex · libregistry