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

uncovered-highlight

v1.0.1

Published

A package and tool to display source code with uncovered parts highlighted

Downloads

54

Readme

uncovered-highlight

A package and tool to display source code with uncovered parts highlighted.

Installation

npm install uncovered-highlight

For global installation:

npm install -g uncovered-highlight

Usage

Generating Coverage Data

First, run your TypeScript or JavaScript programs with V8 coverage enabled:

NODE_V8_COVERAGE=coverage node your-program.js

This will create coverage data in the coverage directory.

Command Line Tool

Display source files with uncovered parts highlighted:

uncovered-highlight [options] <file...>

Options

  • -c, --coverage-dir <dir> - Coverage data directory (default: auto-detected from source file path, or coverage)
  • -o, --out-dir <dir> - TypeScript output directory (overrides tsconfig.json)
  • -n, --no-line-numbers - Hide line numbers (line numbers shown by default)
  • -x, --context <n> - Number of context lines around uncovered code (default: 2)
  • -s, --show-omitted - Show "..." for omitted lines
  • -m, --hide-omitted - Hide "..." for omitted lines (default)
  • -h, --highlight <color> - Highlight color: black, red, green, yellow, blue, magenta, cyan, white, bold, underline, reverse, or numeric ANSI code (default: red)
  • --help - Show help message

Examples

Display a TypeScript file with default settings (line numbers shown, red highlights):

uncovered-highlight src/file.ts

Hide line numbers and show omitted line indicators:

uncovered-highlight -n -s src/file.ts

Use bold highlighting with more context lines:

uncovered-highlight -h bold -x 3 src/file.ts

Process multiple files:

uncovered-highlight src/*.ts

Library API

You can also use the library programmatically:

import { 
  V8CoverageReader, 
  SourceMapProcessor, 
  HighlightProcessor 
} from 'uncovered-highlight';

// Read V8 coverage data
const reader = new V8CoverageReader('coverage');

// Get coverage ranges for a JavaScript file
const ranges = reader.getCoverageRanges('path/to/file.js');

// Process with source maps for TypeScript
const processor = new SourceMapProcessor();
const mappedRanges = await processor.mapJsRangesToSource(
  'path/to/file.js', 
  ranges
);

// Generate per-line highlights
const highlighter = new HighlightProcessor();
const lineHighlights = highlighter.processSourceWithCoverage(
  sourceCode, 
  mappedRanges
);

// Clean up
processor.destroy();

Features

  • V8 Coverage Integration: Reads native V8 coverage data generated by Node.js
  • Subdirectory Support: Automatically finds coverage files in subdirectories (e.g., coverage/tmp/)
  • Source Map Support: Maps JavaScript coverage back to TypeScript source files
  • Smart Path Resolution: Correctly handles rootDir and outDir configurations in tsconfig.json
  • Multi-byte Character Support: Correctly handles Unicode characters including emojis
  • Flexible Highlighting: Customizable highlight colors including named colors (red, green, blue, etc.), styles (bold, underline, reverse), or numeric ANSI codes
  • Context Control: Show only relevant lines with configurable context
  • Multiple Files: Process multiple source files in a single run

How It Works

  1. Coverage Collection: Node.js V8 engine records which parts of your JavaScript code were executed
  2. Coverage Reading: The tool reads the V8 coverage data from JSON files
  3. Source Mapping: For TypeScript files, coverage data is mapped back to the original source using source maps
  4. Highlight Generation: Uncovered code regions are identified and per-line highlight ranges are calculated
  5. Terminal Output: Source code is displayed with uncovered parts highlighted using ANSI escape codes with customizable colors and styles
  6. Auto-discovery: Automatically searches for coverage directories and tsconfig.json from the source file location
  7. Subdirectory Scanning: If coverage directory has no files directly, automatically scans subdirectories (supports c8 and similar tools)

Note from a Human

I realized I wanted something like this tool that displays the parts of the source code uncovered by tests. The output to terminal shows lines with surrounding lines for context. If a condition is tested, but following block never covered, I want to know that. Reducing granularity to line-level was not good.

I had no particular interest in making such a tool, and I may have missed one if there is something that does what I needed. Partially as a way to play around with generative AI code generation and agents, this package exists. As long as it works, I have no particular desire to touch the code, provided I can help myself. I wanted the tool, I prompted, I got what you see.

Since all code has been generated by AI, this is not copyrighted even though AI may have added notes about licenses somewhere. The CC0-1.0 license was the suggestion of a Search Assist, which I followed, gullibly or not.