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

xpatch-rs-native

v0.4.2

Published

High-performance delta compression library with automatic algorithm selection

Readme

xpatch-rs-native

Native Node.js bindings for xpatch - maximum performance delta compression.

npm install xpatch-rs-native

Note: This package provides native bindings for maximum performance (~10-30% faster than WASM). For most use cases, consider xpatch-rs instead, which uses WASM and works in both browsers and Node.js with a smaller package size (~890KB vs ~2MB per platform).

| Package | Size | Platforms | Performance | |---------|------|-----------|-------------| | xpatch-rs | ~890KB | Browser + Node.js | Fast | | xpatch-rs-native | ~2MB/platform | Node.js only | Fastest |

Quick Start

const xpatch = require('xpatch-rs-native');

// Create a delta patch
const base = Buffer.from('Hello, World!');
const newData = Buffer.from('Hello, Node!');
const delta = xpatch.encode(0, base, newData);

console.log(`Delta size: ${delta.length} bytes`);

// Apply the patch
const reconstructed = xpatch.decode(base, delta);
console.log(reconstructed.equals(newData)); // true

// Extract metadata tag
const tag = xpatch.getTag(delta);
console.log(`Tag: ${tag}`);

TypeScript Support

TypeScript definitions are included:

import { encode, decode, getTag } from 'xpatch-rs-native';

const base = Buffer.from('Hello, World!');
const newData = Buffer.from('Hello, TypeScript!');

const delta: Buffer = encode(0, base, newData);
const reconstructed: Buffer = decode(base, delta);
const tag: number = getTag(delta);

API Reference

encode(tag, baseData, newData, enableZstd?) => Buffer

Creates a delta patch between baseData and newData.

Parameters:

  • tag (number): Metadata tag to embed (0-4294967295)
  • baseData (Buffer): Original data
  • newData (Buffer): New data
  • enableZstd (boolean, optional): Enable zstd compression (default: true)

Returns: Buffer - The encoded delta patch

decode(baseData, delta) => Buffer

Reconstructs newData from baseData and a delta patch.

Parameters:

  • baseData (Buffer): Original data
  • delta (Buffer): Delta patch created by encode()

Returns: Buffer - The reconstructed new data

Throws: Error if delta is invalid

getTag(delta) => number

Extracts the metadata tag from a delta patch without decoding.

Parameters:

  • delta (Buffer): Delta patch

Returns: number - The embedded tag

Throws: Error if delta is invalid

Performance

xpatch achieves exceptional compression ratios on real-world data:

  • 99.8% compression on typical code changes
  • 2 byte median delta for sequential edits
  • Instant decoding (<1µs for most patches)
  • 40-55 GB/s throughput for encoding

Use Cases

Perfect for:

  • Performance-critical Node.js server applications
  • High-throughput data processing pipelines
  • Real-time collaborative editing backends
  • Version control system backends

Building from Source

cd crates/xpatch-node-native
npm install
npm run build

For development builds:

npm run build:debug

Supported Platforms

Pre-built binaries are available for:

  • Linux (x64, ARM64, musl)
  • macOS (Intel, Apple Silicon)
  • Windows (x64, ARM64)

License

This project is dual-licensed:

See LICENSE-AGPL.txt and LICENSE-COMMERCIAL.txt for details.

Links