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

@thinkeloquent/git-file-id

v0.1.0

Published

Generate GitHub URLs from Git file paths with commit hash - WASM module

Readme

git-file-id

A Rust/WASM library to generate GitHub URLs from Git file paths with commit hashes, and access Git objects (blobs, trees, commits, tags).

Features

  • Generate GitHub URLs for files with specific commit hashes
  • Search upward for .git directory from any file path
  • Access Git objects: blobs, trees, commits, and tags
  • Support for both SSH and HTTPS GitHub remotes
  • Fast WASM implementation

Installation

npm install git-file-id

Usage

Basic Usage - Generate GitHub URL

const { GitFileId, generate_github_url_direct } = require('git-file-id');

// Quick one-liner
const url = await generate_github_url_direct('/path/to/your/file.js');
console.log(url);
// Output: https://github.com/owner/repo/blob/abc123.../path/to/file.js

// Using the class for multiple operations
const git = new GitFileId();
await git.find_repository('/path/to/your/file.js');

const url = await git.generate_github_url('/path/to/your/file.js');
console.log(url);

Access Git Objects

const git = new GitFileId();
await git.find_repository('/path/to/repo');

// Get commit information
const commit = await git.get_commit('abc123...');
console.log(commit.message);
console.log(commit.author_name);

// Get blob (file) information
const blob = await git.get_blob('def456...');
console.log(blob.size);
console.log(blob.is_binary);

// Get tree (directory) information
const tree = await git.get_tree('789abc...');
console.log(tree.len); // Number of entries

// Get tag information
const tag = await git.get_tag('tag123...');
console.log(tag.name);
console.log(tag.message);

Other Operations

const git = new GitFileId();
await git.find_repository('/path/to/repo');

// Get file hash for current branch
const hash = await git.get_file_hash('src/main.js');

// Get file status
const status = await git.get_file_status('src/main.js');
// Returns: 'clean', 'modified', 'untracked', etc.

// Get HEAD reference
const head = await git.get_head_ref();
// Returns: branch name or commit hash if detached

// List all references
const refs = await git.list_refs();
// Returns: array of reference names (branches, tags, etc.)

API Reference

GitFileId Class

Constructor

  • new GitFileId() - Create a new instance

Methods

  • find_repository(file_path: string) - Find the Git repository root
  • generate_github_url(file_path: string) - Generate GitHub URL for a file
  • get_file_hash(file_path: string) - Get the commit hash for a file
  • get_blob(hash: string) - Get blob object by hash
  • get_tree(hash: string) - Get tree object by hash
  • get_commit(hash: string) - Get commit object by hash
  • get_tag(hash: string) - Get tag object by hash
  • list_refs() - List all Git references
  • get_file_status(file_path: string) - Get file status
  • get_head_ref() - Get current HEAD reference

Standalone Functions

  • generate_github_url_direct(file_path: string) - Generate GitHub URL directly without creating an instance

Git Object Types

GitBlob

  • id: String - Object hash
  • size: Number - Blob size in bytes
  • is_binary: Boolean - Whether the blob is binary

GitTree

  • id: String - Object hash
  • len: Number - Number of entries in the tree

GitCommit

  • id: String - Commit hash
  • message: String - Commit message
  • author_name: String - Author name
  • author_email: String - Author email
  • time: Number - Commit timestamp (seconds since epoch)
  • tree_id: String - Tree object hash

GitTag

  • id: String - Tag hash
  • name: String - Tag name
  • message: String - Tag message
  • target_id: String - Target object hash

Building from Source

# Clone the repository
git clone https://github.com/yourusername/git-file-id.git
cd git-file-id

# Build WASM module
wasm-pack build --target nodejs

# Run tests
cargo test

License

MIT