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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@bsdiff-rust/node

v0.0.4

Published

A high-performance Rust implementation of bsdiff and bspatch algorithms with Node.js bindings

Readme

🚀 bsdiff-rust

A high-performance binary differential patching library based on Rust and NAPI-RS, providing an optimized bsdiff/bspatch algorithm implementation for Node.js. Built on qbsdiff library with standard BSDIFF40 format support, featuring suffix array algorithms and parallel processing.

npm version License: MIT

Chinese README

✨ Core Features

  • Standard Compatible: Generates standard BSDIFF40 format, fully compatible with bsdiff-node
  • Memory Safe: Rust guarantees memory safety and thread safety, high-performance Node.js bindings via napi-rs
  • Optimized Compression: Uses bzip2 compression with memory pre-allocation optimizations
  • Cross-platform: Supports Windows, macOS, Linux

🚀 Quick Start

Installation

pnpm install @bsdiff-rust/node

Basic Usage

const bsdiff = require('@bsdiff-rust/node')

// Synchronous API
bsdiff.diffSync('old-file.zip', 'new-file.zip', 'patch.bin')
bsdiff.patchSync('old-file.zip', 'generated-file.zip', 'patch.bin')

// Asynchronous API
await bsdiff.diff('old-file.zip', 'new-file.zip', 'patch.bin')
await bsdiff.patch('old-file.zip', 'generated-file.zip', 'patch.bin')

TypeScript Support

import { diff, diffSync, patch, patchSync } from '@bsdiff-rust/node'

// Generate and apply patches
await diff('old-file.zip', 'new-file.zip', 'patch.bin')
await patch('old-file.zip', 'generated-file.zip', 'patch.bin')

Need performance monitoring or custom configuration? See Complete API Documentation

📖 API Documentation

Core API

// Synchronous methods
diffSync(oldFile: string, newFile: string, patchFile: string): void
patchSync(oldFile: string, newFile: string, patchFile: string): void

// Asynchronous methods
diff(oldFile: string, newFile: string, patchFile: string): Promise<void>
patch(oldFile: string, newFile: string, patchFile: string): Promise<void>

Need advanced features? See the Complete Guide for performance stats, configuration options, testing, and benchmarks.

🧪 Testing

# Run functional tests
pnpm test

# Run performance benchmarks
pnpm run bench

🔧 Development Guide

Environment Requirements

  • Node.js: >= 16 (Latest LTS recommended)
  • Rust: >= 1.70
  • Package Manager: npm or pnpm

Building the Project

# Install dependencies
pnpm install

# Build release version
pnpm build

# Build debug version
pnpm build:debug

# Build for specific platform
pnpm build:arm64

Development Workflow

# Code formatting
pnpm format

# Code linting
pnpm lint

# Run tests
pnpm test

# Performance testing
pnpm bench

Project Structure

bsdiff-rust/
├── src/
│   ├── lib.rs              # NAPI binding entry
│   ├── bsdiff_rust.rs      # Core Rust implementation
├── benchmark/
│   └── benchmark.ts        # TypeScript benchmarks
├── test/
│   ├── index.ts            # Functional tests
│   └── resources/          # Test resource files
├── index.js                # Node.js entry point
├── index.d.ts              # TypeScript type definitions
├── Cargo.toml              # Rust project configuration
└── package.json            # Node.js project configuration

🌍 Cross-platform Support

Supported Platforms

  • macOS: ARM64 (Apple Silicon) and x64 (Intel)
  • Linux: ARM64 and x64 (GNU and musl)
  • Windows: ARM64 and x64 (MSVC)

Platform Package Strategy

This project uses napi-rs's multi-package strategy, automatically downloading precompiled binaries for the corresponding platform during installation:

npm/
├── @bsdiff-rust/darwin-arm64/     # macOS ARM64
├── @bsdiff-rust/darwin-x64/       # macOS x64
├── @bsdiff-rust/linux-arm64-gnu/  # Linux ARM64 glibc
├── @bsdiff-rust/linux-x64-gnu/    # Linux x64 glibc
├── @bsdiff-rust/linux-arm64-musl/ # Linux ARM64 musl
├── @bsdiff-rust/linux-x64-musl/   # Linux x64 musl
└── ...

Advantages:

  • 🚀 Fast Installation: No compilation needed, direct download of precompiled binaries
  • 📦 On-demand Download: Only downloads files needed for the current platform
  • 🛡️ Stable and Reliable: Avoids installation failures due to compilation environment issues

🤝 Contributing

Development Process

  1. Fork the project
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Create a Pull Request

Code Standards

  • Rust Code: Use cargo fmt for formatting
  • JavaScript/TypeScript: Use Prettier for formatting
  • Commit Messages: Use clear English descriptions

📚 References


⭐ If this project helps you, please give it a star!

🐛 Found an issue? Feel free to submit an Issue

💡 Have suggestions for improvement? Welcome to submit a Pull Request