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

fs-fingerprint

v0.14.0

Published

Filesystem-based fingerprinting library for node

Readme

FS Fingerprint 🫆

Generate unique fingerprint hashes from filesystem state and other inputs: text, JSON, envs.

What is FS Fingerprint?

A fast Node.js library to generate unique fingerprints based on:

  • Files & directories in your project
  • Other inputs: text content, JSON data, environment variables

Perfect for building intelligent caching solutions that detect when source files have changed. ⚡

Features

  • Reliable and fast change detection (100% code coverage, benchmarked)
  • Highly customizable: files/ignores glob patterns, additional inputs, hashing algorithms, .gitignore support
  • Elegant and simple TypeScript API, both sync and async
  • Tiny size (~30 KB unpacked) with minimal dependencies (tinyglobby)

Quick Start

  1. Install:
    npm install fs-fingerprint
    (or yarn/pnpm/bun add fs-fingerprint)
  2. Usage:
import { calculateFingerprint } from "fs-fingerprint";

const { hash } = await calculateFingerprint("/project/path", {
  files: ["ios/", "package.json"],
  ignores: ["ios/build/"],
});

Core API

calculateFingerprint

async function calculateFingerprint(
  basePath: string, // Base path to resolve "files" and "ignores" patterns
  options?: {
    files?: string[]; // Glob patterns to include (default: all)
    ignores?: string[]; // Glob patterns to exclude (default: none)
    contentInputs?: ContentInput[]; // Additional inputs: text, JSON, envs, etc.
    hashAlgorithm?: string; // Hash algorithm (default: "sha1")
    gitIgnore?: boolean; // Exclude paths ignored by Git (default: false)
  },
): Promise<Fingerprint>;

Generates a fingerprint hash for the filesystem state.

Return Value

interface Fingerprint {
  hash: string; // Overall project fingerprint hash
  files: FileHash[]; // File hashes included in the fingerprint
  content: ContentHash[]; // Content hashes included in the fingerprint
}

Note: when using gitIgnore option, it silently ignores any git invocation errors (e.g. missing git binary, or not a git repository).

Browse the API Reference for other API.

Examples

Basic usage:

const { hash } = await calculateFingerprint("/project/path");
console.log(hash); // "abc123..."

Using include/exclude patterns:

const { hash } = await calculateFingerprint("/project/path", {
  files: ["src/", "package.json"],
  ignores: ["**/*.test.ts", "dist"],
});

Using content inputs:

const { hash } = await calculateFingerprint("/project/path", {
  contentInputs: [
    textContent("app-config", "debug=true"), // Text content
    jsonContent("app-metadata", { version: "1.0", env: "prod" }), // JSON data
    envContent("app-envs", ["BUILD_ENVIRONMENT", "FEATURE_FLAG"]), // Env variables
    envContent("signing-key", ["API_KEY"], { secret: true }), // Secret env input (value not included in details)
  ],
});

Using .gitignore file:

const { hash } = await calculateFingerprint("/project/path", {
  gitIgnore: true,
});

Custom hash algorithm:

const { hash } = await calculateFingerprint("/project/path", {
  hashAlgorithm: "sha512",
});

Synchronous call:

const { hash } = calculateFingerprintSync("/project/path", { ...options });

Design Considerations

  1. Flat manifest:
    The final hash is computed from a list of all files and their hashes, sorted by relative path. Renaming or moving a file changes the fingerprint, even if content is unchanged.

  2. File Hashing:
    Each file’s hash is based only on its content (not name or path). The final hash includes both file paths and their content hashes.

  3. Minimal Dependencies: Avoid adding 3rd party deps unless highly beneficial.

  4. Benchmark Everything: Do not make assumptions about what is fast and what is not, always benchmark any introduced code changes.

Contributing

PRs welcome! Keep it awesome.

License

MIT 💝


Made with 💻 and ☕️ by MDJ