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 🙏

© 2026 – Pkg Stats / Ryan Hefner

codeinf

v1.1.3

Published

A CLI tool to analyze code statistics like lines of code, file counts, and more with filtering capabilities

Downloads

43

Readme

codeinf

A CLI tool and library to analyze code statistics like lines of code, file counts, and more with filtering capabilities. Features a real-time progress bar during scanning.

Installation

Global Installation (CLI usage)

npm install -g codeinf

Local Installation (Programmatic usage)

npm install codeinf

CLI Usage

Basic Usage

# Analyze current directory (shows progress bar)
codeinf

# Analyze specific directory
codeinf ./src

# Analyze with specific file extensions
codeinf -e js,ts,jsx,tsx
codeinf --extensions .js,.ts

# Output as JSON (no progress bar)
codeinf --json
codeinf -f json

# Ignore specific directories
codeinf -i "test,docs,build"

# Show top 20 largest files
codeinf -t 20

CLI Options

| Option | Description | |--------|-------------| | -h, --help | Show help message | | -v, --version | Show version | | -e, --ext, --extensions | Filter by file extensions (comma-separated) | | -i, --ignore | Additional ignore patterns (comma-separated) | | -f, --format | Output format: table or json | | --json | Shortcut for JSON output (disables progress bar) | | -t, --top | Number of largest files to show (default: 10) | | --no-color | Disable colored output (also disables progress bar) |

Progress Bar

When analyzing directories, codeinf displays a real-time progress bar:

  1. Discovery Phase - Shows a spinning animation while finding files:

    ⠋ Scanning: Found 4,117 files package.json
  2. Analysis Phase - Shows a progress bar while analyzing files:

    Analyzing: [████████░░░░░░░░░░░░░░░░░░░░] 25% 1/4 .npmignore

The progress bar is automatically disabled when:

  • Using --json or -f json output format
  • Using --no-color flag
  • Analyzing a single file

Programmatic API

Basic Usage

const { analyze, formatBytes } = require('codeinf');

// Analyze current directory
const stats = analyze('.');
console.log(stats);

// Analyze with options
const stats = analyze('./src', {
  extensions: ['.js', '.ts'],
  ignore: ['test', 'dist'],
  recursive: true
});

console.log(`Total files: ${stats.summary.files}`);
console.log(`Total lines: ${stats.summary.totalLines}`);
console.log(`Code lines: ${stats.summary.codeLines}`);

API Reference

analyze(targetPath, options)

Analyzes code statistics for a given path.

Parameters:

  • targetPath (string): Path to analyze (default: '.')
  • options (Object):
    • extensions (string[]): Filter by file extensions (e.g., ['.js', '.ts'])
    • ignore (string[]): Additional patterns to ignore
    • recursive (boolean): Scan recursively (default: true)

Returns:

{
  path: '/absolute/path',
  summary: {
    files: 42,
    totalLines: 5000,
    nonEmptyLines: 4500,
    codeLines: 3800,
    size: 1024000
  },
  byExtension: {
    '.js': { files: 20, lines: 3000, size: 500000 },
    '.ts': { files: 22, lines: 2000, size: 524000 }
  },
  largestFiles: [
    { path: '...', totalLines: 500, nonEmptyLines: 450, codeLines: 400, size: 10000, extension: '.js' }
  ],
  allFiles: [...]
}

scanDirectory(dir, options)

Scans a directory and returns file statistics.

const { scanDirectory } = require('codeinf');

const files = scanDirectory('./src', {
  extensions: ['.js'],
  ignore: ['node_modules'],
  recursive: true
});

files.forEach(file => {
  console.log(`${file.path}: ${file.totalLines} lines`);
});

getFileStats(filePath)

Gets statistics for a single file.

const { getFileStats } = require('codeinf');

const stats = getFileStats('./src/index.js');
console.log(stats);
// { path, size, totalLines, nonEmptyLines, codeLines, extension }

formatBytes(bytes)

Formats bytes to human-readable string.

const { formatBytes } = require('codeinf');

console.log(formatBytes(1024));      // "1 KB"
console.log(formatBytes(1048576));   // "1 MB"

Default Ignore Patterns

The following directories are automatically ignored:

  • node_modules
  • .git, .svn, .hg
  • .DS_Store
  • dist, build
  • coverage
  • .next, .nuxt
  • .cache
  • vendor, bin, obj

License

MIT