npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nurv-llc/codometer

v0.1.0

Published

A TypeScript library for analyzing code repositories and providing detailed metrics

Readme

Codometer

npm version License: MIT

A TypeScript library for analyzing code repositories and providing detailed metrics about lines of code, documentation, and file counts with intelligent filtering capabilities.

Features

  • 📊 Accurate Line Counting - Separate code lines from documentation and comments
  • 🎯 Smart Language Detection - Automatic parser selection based on file type
  • 🚫 Intelligent Filtering - Respects .gitignore by default, with test exclusion support
  • 📝 Documentation Analysis - Tracks inline comments and markdown files separately
  • Performance - Efficiently handles large repositories
  • 🔧 Zero Dependencies - No runtime dependencies for maximum reliability

Supported Languages

  • JavaScript/TypeScript (including JSX/TSX)
  • Python (with docstring detection)
  • C# (with XML doc comments)
  • C/C++ (with header files)
  • Rust (with doc comments)
  • Markdown (pure documentation)

Installation

# Using npx (recommended)
npx @nurv-llc/codometer

# Global installation
npm install -g @nurv-llc/codometer

# Local installation
npm install @nurv-llc/codometer

Usage

Command Line

# Analyze current directory
codometer

# Analyze specific directory
codometer ./src

# Ignore .gitignore rules
codometer --ignore-gitignore

# Exclude test files
codometer --exclude-tests="*.spec.ts,**/__tests__/**"

# Verbose output with per-file details
codometer --verbose

# Show help
codometer --help

Programmatic API

import { Analyzer } from '@nurv-llc/codometer';

const analyzer = new Analyzer({
  rootPath: '/path/to/project',
  respectGitignore: true,
  excludeTests: '*.spec.ts,**/__tests__/**',
  followSymlinks: false,
  includeHidden: false,
  verbose: false,
  maxFileSize: 10 * 1024 * 1024, // 10MB
});

const result = await analyzer.analyze();

console.log(`Files: ${result.totalFiles}`);
console.log(`Lines of Code: ${result.linesOfCode}`);
console.log(`Lines of Documentation: ${result.linesOfDocumentation}`);

CLI Options

| Option | Description | |--------|-------------| | --ignore-gitignore | Ignore .gitignore rules and scan all files | | --exclude-tests=<glob> | Exclude test files matching glob patterns | | --follow-symlinks | Follow symbolic links during scan | | --include-hidden | Include hidden files and directories | | --verbose | Show detailed per-file metrics | | -h, --help | Show help message | | -v, --version | Show version number |

Output Format

==================================================
Code Metrics Summary
==================================================

Files: 42
Lines of Code: 3521
Lines of Documentation: 892
  - Comments: 654
  - Markdown Files: 238

--------------------------------------------------
Language Breakdown
--------------------------------------------------

JavaScript/TypeScript:
  Files: 35
  Lines of Code: 2890
  Comment Lines: 543

Python:
  Files: 5
  Lines of Code: 631
  Comment Lines: 111

Markdown:
  Files: 2
  Lines of Code: 0
  Comment Lines: 238

How It Works

  1. File Discovery - Recursively scans directories, respecting filters
  2. Binary Detection - Automatically skips binary files
  3. Parser Selection - Chooses appropriate parser based on file extension
  4. Line Analysis - Accurately counts code vs documentation lines
  5. Aggregation - Combines results into comprehensive metrics

Development

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Lint
npm run lint

# Format
npm run format

License

MIT © Nurv LLC

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Repository

https://github.com/cyb3rsyph0n/codometer