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

@hardlydifficult/repo-processor

v1.0.150

Published

Opinionated GitHub repo processing with git-backed YAML results.

Readme

@hardlydifficult/repo-processor

Opinionated GitHub repo processing with git-backed YAML results.

The package is built around one happy path:

  1. Open a processor for one source repo.
  2. Describe how to turn files and directories into results.
  3. Run it or attach a watcher.

Installation

npm install @hardlydifficult/repo-processor

Quick Start

import { RepoProcessor } from "@hardlydifficult/repo-processor";

const processor = await RepoProcessor.open({
  repo: "hardlydifficult/typescript",
  ref: "main",
  results: {
    repo: "hardlydifficult/repo-data",
    directory: "./repo-data",
  },
  include(file) {
    return file.path.endsWith(".ts");
  },
  async processFile(file) {
    return {
      path: file.path,
      sha: file.sha,
      length: file.content.length,
    };
  },
  async processDirectory(directory) {
    return {
      path: directory.path,
      fileCount: directory.files.length,
    };
  },
});

const result = await processor.run({
  onProgress(progress) {
    console.log(progress.phase, progress.message);
  },
});

console.log(result);
// {
//   repo: "hardlydifficult/typescript",
//   sourceSha: "...",
//   processedFiles: 12,
//   removedFiles: 0,
//   processedDirectories: 5
// }

Why This API

  • RepoProcessor.open() binds the source repo once.
  • run() does not ask for owner and repo again.
  • GitHub auth and git-backed YAML persistence are built in.
  • The default results layout is repos/<owner>/<repo>.

API

await RepoProcessor.open(options)

interface RepoProcessorOptions<TFileResult, TDirResult = never> {
  repo: string;
  githubToken?: string;
  ref?: string;
  concurrency?: number;
  results: {
    repo: string;
    directory: string;
    root?: string;
    branch?: string;
    gitUser?: { name: string; email: string };
  };
  include?: (file: {
    path: string;
    sha: string;
    size?: number;
  }) => boolean;
  processFile(file: {
    repo: string;
    path: string;
    sha: string;
    content: string;
  }): Promise<TFileResult>;
  processDirectory?: (directory: {
    repo: string;
    path: string;
    sha: string;
    files: readonly string[];
    children: readonly {
      name: string;
      path: string;
      type: "file" | "directory";
    }[];
  }) => Promise<TDirResult>;
}

Notes:

  • repo and results.repo accept either owner/repo or a GitHub URL.
  • githubToken defaults to GH_PAT, then GITHUB_TOKEN.
  • results.root defaults to "repos".
  • results.branch defaults to the checked-out branch in the results clone.
  • results.gitUser defaults to local git config (user.name and user.email).

await processor.run({ onProgress? })

type RepoProcessorRunResult = {
  repo: string;
  sourceSha: string;
  processedFiles: number;
  removedFiles: number;
  processedDirectories: number;
};
type RepoProcessorProgress = {
  phase: "loading" | "files" | "directories" | "committing";
  message: string;
  files: { total: number; completed: number };
  directories: { total: number; completed: number };
};

If processDirectory is omitted, directory diffing and directory result writes are skipped.

Reading Stored Results

const fileResult = await processor.readFileResult(
  "src/index.ts",
  schema
);

const directoryResult = await processor.readDirectoryResult(
  "src",
  schema
);

Watching A Repo

const watcher = await processor.watch({
  stateDirectory: "./state",
  maxAttempts: 3,
  onComplete(result, sha) {
    console.log("processed", sha, result.processedFiles);
  },
});

watcher.handlePush("abc123");
await watcher.runNow();

Watcher methods:

  • handlePush(sha)
  • runNow()
  • isRunning()
  • getLastSha()
  • setLastSha(sha)