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

@ivorisnoob/linecount

v1.1.0

Published

A fast, smart line counter that automatically ignores common build artifacts and dependencies

Readme

linecount

A fast, intelligent line counter that automatically ignores common build artifacts, dependencies, and version control files. Built as a modern alternative to CLOC with sensible defaults for contemporary development workflows.

Features

  • Fast recursive directory scanning with async I/O
  • Smart defaults that automatically ignore build artifacts and dependencies
  • Comment detection for 30+ programming languages
  • Clean, colorized table output
  • Works as both a CLI tool and importable library
  • Configurable ignore patterns and directories
  • Zero runtime dependencies

Installation

Install globally to use as a command-line tool:

npm install -g linecount

Or install locally in your project:

npm install linecount

Usage

Command Line

Count lines in the current directory:

linecount

Count lines in a specific directory:

linecount ./src
linecount /path/to/project

Exclude specific directories:

linecount --exclude-dir tests docs
linecount --exclude-dir build temp

Exclude specific file extensions:

linecount --exclude-ext .md .txt
linecount --exclude-ext .test.js .spec.ts

Combine multiple options:

linecount ./src --exclude-dir __tests__ --exclude-ext .md .json

Show help information:

linecount --help

As a Library

import { LineCounter } from 'linecount';

const counter = new LineCounter();
const result = await counter.count('./my-project');

console.log(`Total files: ${result.totalFiles}`);
console.log(`Total lines: ${result.totalLines}`);
console.log(`Code lines: ${result.totalCode}`);
console.log(`Comment lines: ${result.totalComments}`);
console.log(`Blank lines: ${result.totalBlank}`);

// Access per-extension statistics
for (const [ext, stats] of result.byExtension) {
  console.log(`${ext}: ${stats.code} lines of code`);
}

Custom Configuration

import { LineCounter } from 'linecount';

const counter = new LineCounter({
  ignoreDirs: new Set(['node_modules', 'custom-dir']),
  ignorePatterns: [/\.test\.js$/, /\.spec\.ts$/],
});

const result = await counter.count('./src');

What Gets Ignored by Default

Directories

Package managers and dependencies:

  • node_modules, bower_components, vendor, Pods, Carthage
  • .pub-cache, site-packages, pypackages

Version control:

  • .git, .svn, .hg

IDE and editor folders:

  • .idea, .vscode, .vs, .cursor, .windsurf

Build outputs:

  • dist, build, out, target, bin, obj, Debug, Release
  • DerivedData, .build, cmake-build-debug, cmake-build-release

Test coverage:

  • coverage, .nyc_output, TestResults

Cache directories:

  • .cache, .parcel-cache, .next, .nuxt, .turbo
  • pycache, .pytest_cache, .mypy_cache, .ruff_cache
  • .gradle, .m2, .dart_tool

Framework-specific:

  • .terraform, .vagrant, .stack-work, .elixir_ls

Files

Lock files:

  • package-lock.json, yarn.lock, pnpm-lock.yaml
  • Gemfile.lock, Cargo.lock, Podfile.lock, composer.lock, poetry.lock

Minified and bundled files:

  • *.min.js, *.bundle.js, *.map

Generated files:

  • *.generated.swift, *.g.dart, *.pb.go, *_pb2.py
  • *.designer.cs, AssemblyInfo.cs

Config and ignore files:

  • .gitignore, .gitattributes, .npmignore, .dockerignore
  • .cursorignore, .cursorrules, .editorconfig

Binary and media files:

  • Images: jpg, png, gif, svg, ico, webp
  • Videos: mp4, avi, mov, wmv
  • Archives: zip, tar, gz, rar, 7z
  • Documents: pdf, doc, docx, xls, xlsx
  • Executables: exe, dll, so, dylib, apk, ipa

Supported Languages for Comment Detection

The tool accurately detects and counts comments in:

C-style comments (// and / /): JavaScript, TypeScript, Java, C, C++, C#, Go, Rust, Swift, Kotlin, PHP

Hash comments (#): Python, Ruby, Shell scripts (bash, zsh), YAML, TOML, Perl, Elixir, R

SQL comments (-- and / /): SQL, Lua

Other languages: HTML/XML, CSS/SCSS/LESS, Haskell, OCaml, Lisp, Clojure, Erlang, Vim script, MATLAB

Output Format

The tool displays results in a clean table format:

Language         Files      Lines      Blank    Comment       Code
.ts                  6        450         50         80        320
.js                  3        200         25         30        145
.json                2         80          5          0         75
Total               11        730         80        110        540

Why linecount?

Unlike traditional line counters, linecount is built for modern development:

  • Automatically ignores everything you don't want to count
  • No configuration needed for most projects
  • Understands modern frameworks and tooling (Next.js, Flutter, Rust, etc.)
  • Fast async I/O for large codebases
  • Clean, readable output with color coding
  • Can be used programmatically in Node.js applications

Requirements

Node.js 18.0.0 or higher

License

MIT