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

bytemate-patch

v0.1.0

Published

High-performance JSON patch library for Javascript, Rust, and Python

Readme

BYTEMATE:PATCH 🚀

The JSON patching library that doesn't suck.

High-performance JSON patch library for Rust, Python, and JavaScript that actually works at scale.

📋 Table of Contents

🚀 Getting Started

📦 Installation & Quick Start

📚 Core Concepts

🔧 Language-Specific Guides

📖 Reference

The Problem

Most JSON patch libraries were written when:

  • Memory was cheap (it's not)
  • Performance didn't matter (it does)
  • Developer time wasn't valuable (it is)
  • Crashes were "just restart it" (they're not)

We fixed the entire category.

Performance

Based on real benchmarks, not marketing fluff:

| Operation | Time | Throughput | Status | | :-- | :-- | :-- | :-- | | Basic patch operations | 349ns | 2.9M ops/sec | ⚡ Sub-microsecond | | Serial key operations | 12.6ms/1000 items | 79K ops/sec | 🎯 O(1) lookup | | Large document patches | 1.2ms | 827K ops/sec | 📊 Linear scaling | | JSON serialization | 1.3µs | - | 🚀 Microsecond-fast | | Memory efficiency | Zero-copy | - | 💾 Zero-copy proven |

What This Actually Means

When you're patching 1000 objects:

  • BYTEMATE: 12.6ms - Grab coffee, come back, it's done
  • Others: 200ms+ - Go make dinner, maybe it'll finish

Key Features

🎯 Zero-Copy Operations We don't copy your data around like it's 1995. Your memory stays where it belongs.

⚡ Serial Key Magic List operations in O(1) time. Because O(n) is for people who hate their users.

🛡️ Type Safety That Actually Works Rust catches your mistakes at compile time, not in production at 3 AM.

🌐 Works Everywhere Python, Node.js, WebAssembly, browsers - if it runs code, we support it.

📋 Industry Standard Compatible Works with existing JSON patch workflows. No rewriting required.

🔒 Production Ready Memory safe, crash-free, tested by people who actually use it.

🦀 Rust

Installation

[dependencies]
bytemate-patch = "0.1"

Quick Start

use bytemate_patch::BytematePatch;
use serde_json::json;

// Basic patching
let data = json!({"name": "John", "age": 30});
let patch = BytematePatch::new()
    .set("age", json!(31))
    .set("city", json!("New York"));

let result = patch.apply(&data)?;
// {"name": "John", "age": 31, "city": "New York"}

Serial Key Operations

// O(1) magic with serial keys
let users = json!([
    {"_": "user1", "name": "Alice", "status": "active"},
    {"_": "user2", "name": "Bob", "status": "inactive"}
]);

let patch = BytematePatch::new()
    .set("user1", json!({"name": "Alice", "status": "premium"}))
    .delete("user2");

let result = patch.apply(&users)?;
// [{"_": "user1", "name": "Alice", "status": "premium"}]

Rust Advanced Usage

All Operations

// Set and delete
BytematePatch::new()
    .set("field", json!("value"))
    .set("number", json!(42))
    .delete("unwanted_field");

// Move and copy
BytematePatch::new()
    .move_key("old_name", "new_name")
    .copy_key("template", "instance");

// Test operations
BytematePatch::new()
    .test("field", json!("expected_value"));

Zero-Copy In-Place Operations

let mut data = json!({"large": "document"});
patch.apply_inplace(&mut data)?; // Modifies in place - no copying

JSON Format Support

let patch_json = json!({
    "users": {
        "user123": {"name": "New Name"},
        "user456": {"*": null}  // Delete syntax
    }
});

let patch = BytematePatch::from_json(&patch_json)?;
let json_format = patch.to_json();

Error Handling

use bytemate_patch::{BytematePatch, BytemateError};

match patch.apply(&data) {
    Ok(result) => println!("Success: {}", result),
    Err(BytemateError::InvalidSerial(key)) => {
        eprintln!("Serial key '{}' not found", key);
    }
    Err(BytemateError::TypeMismatch { expected, found }) => {
        eprintln!("Expected {}, found {}", expected, found);
    }
    Err(e) => eprintln!("Error: {}", e),
}

🐍 Python

Installation

pip install bytemate-patch

Quick Start

from bytemate_patch import BytematePatch

# Basic patching
data = {"name": "John", "age": 30}
patch = BytematePatch()
patch.set("age", 31)
patch.set("city", "New York")

result = patch.apply(data)
# {"name": "John", "age": 31, "city": "New York"}

Serial Key Operations

# O(1) list operations
users = [
    {"_": "user1", "name": "Alice", "status": "active"},
    {"_": "user2", "name": "Bob", "status": "inactive"}
]

patch = BytematePatch()
patch.set("user1", {"name": "Alice", "status": "premium"})
patch.delete("user2")

result = patch.apply(users)
# [{"_": "user1", "name": "Alice", "status": "premium"}]

Python Features

Pythonic Interface

from bytemate_patch import BytematePatch

patch = BytematePatch()

# Supports all Python types
patch.set("string", "hello")
patch.set("number", 42)
patch.set("float", 3.14)
patch.set("boolean", True)
patch.set("none", None)
patch.set("list", [1, 2, 3])
patch.set("dict", {"nested": "value"})

# Length and boolean operations
len(patch)  # Number of operations
bool(patch)  # True if not empty

JSON Format Support

patch_json = {
    "users": {
        "user1": {"name": "Alice"},
        "user2": {"*": None}  # Delete syntax
    }
}
patch = BytematePatch.from_json(patch_json)

# Convert back to JSON
json_format = patch.to_json()

Patch Merging

base_patch = BytematePatch()
base_patch.set("a", 1)

override_patch = BytematePatch()
override_patch.set("b", 2)

merged = BytematePatch.merge(base_patch, override_patch)

Error Handling

try:
    result = patch.apply(data)
except RuntimeError as e:
    print(f"Patch error: {e}")

Version Info

import bytemate_patch
print(bytemate_patch.__version__)

🟨 JavaScript/Node.js

Installation

npm install bytemate-patch

Quick Start

import { JsBytematePatch } from 'bytemate-patch';

// Basic patching
const data = { name: "John", age: 30 };
const patch = new JsBytematePatch();
patch.set("age", 31);
patch.set("city", "New York");

const result = patch.apply(data);
// { name: "John", age: 31, city: "New York" }

Serial Key Operations

// O(1) list operations
const users = [
    { _: "user1", name: "Alice", status: "active" },
    { _: "user2", name: "Bob", status: "inactive" }
];

const userPatch = new JsBytematePatch();
userPatch.set("user1", { name: "Alice", status: "premium" });
userPatch.delete("user2");

const result = userPatch.apply({ users });
// { users: [{ _: "user1", name: "Alice", status: "premium" }] }

JavaScript Features

Modern JavaScript API

import { JsBytematePatch, version } from 'bytemate-patch';

const patch = new JsBytematePatch();

// Supports all JS types
patch.set("string", "hello");
patch.set("number", 42);
patch.set("boolean", true);
patch.set("null", null);
patch.set("array", [1, 2, 3]);
patch.set("object", { nested: "value" });

// Properties
patch.length;     // Number of operations
patch.isEmpty();  // True if empty

// Version
console.log(version());

JSON Format Support

const patchJson = {
    users: {
        user1: { name: "Alice" },
        user2: { "*": null }  // Delete syntax
    }
};
const jsonPatch = JsBytematePatch.fromJson(patchJson);

// Convert back to JSON
const jsonFormat = jsonPatch.toJson();

Patch Merging

const minorPatch = new JsBytematePatch();
minorPatch.set("a", 1);

const majorPatch = new JsBytematePatch();
majorPatch.set("b", 2);

const merged = JsBytematePatch.merge(minorPatch, majorPatch);

Error Handling

try {
    const result = patch.apply(data);
} catch (error) {
    console.error("Patch error:", error);
}

Performance Optimization

// Build patches incrementally for better performance
const patch = new JsBytematePatch();
for (const item of largeDataset) {
    patch.set(item.key, item.value);
}

// Single apply call
const result = patch.apply(data);

🌐 Browser

Installation

Via CDN

<script type="module">
import { JsBytematePatch } from 'https://unpkg.com/bytemate-patch/pkg/bytemate_patch.js';
</script>

Via Bundler

npm install bytemate-patch

Browser Integration

WebAssembly for Maximum Performance

<!DOCTYPE html>
<html>
<head>
    <script type="module">
        import init, { JsBytematePatch } from './pkg/bytemate_patch.js';
        
        async function run() {
            await init(); // Initialize WASM
            
            const patch = new JsBytematePatch();
            patch.set("browser", "support");
            
            const result = patch.apply({ data: "original" });
            console.log(result);
        }
        
        run();
    </script>
</head>
</html>

With Modern Bundlers

// Works with Webpack, Vite, Rollup, etc.
import { JsBytematePatch } from 'bytemate-patch';

const patch = new JsBytematePatch();
patch.set("bundler", "compatible");

// TypeScript support included
// Automatic .d.ts generation

📚 Core Concepts

Basic Operations

Set and Delete

Rust:

BytematePatch::new()
    .set("field", json!("value"))
    .delete("unwanted_field");

Python:

patch = BytematePatch()
patch.set("field", "value")
patch.delete("unwanted_field")

JavaScript:

const patch = new JsBytematePatch();
patch.set("field", "value");
patch.delete("unwanted_field");

Serial Key Operations

The secret sauce that makes list operations O(1):

// Instead of searching through arrays...
let data = json!([
    {"_": "abc123", "name": "User 1"},
    {"_": "def456", "name": "User 2"}
]);

// Direct access by serial key
let patch = BytematePatch::new()
    .set("abc123", json!({"name": "Updated User 1"}));

JSON Format Support

Delete Syntax

{
    "users": {
        "user123": {"name": "New Name"},
        "user456": {"*": null}
    }
}

All Languages Support

// Rust
let patch = BytematePatch::from_json(&patch_json)?;
# Python
patch = BytematePatch.from_json(patch_json)
// JavaScript
const patch = JsBytematePatch.fromJson(patchJson);

Patch Merging

All Languages Support Merging:

// Rust
let merged = BytematePatch::merge(base_patch, override_patch);
# Python
merged = BytematePatch.merge(base_patch, override_patch)
// JavaScript
const merged = JsBytematePatch.merge(basePatch, overridePatch);

🔧 Reference

Error Handling

Each language provides appropriate error handling mechanisms:

  • Rust: Result<T, BytemateError> with detailed error types
  • Python: RuntimeError exceptions with descriptive messages
  • JavaScript: Standard JavaScript errors with helpful messages

Performance Tips

General Guidelines

  • Use serial keys for O(1) list operations
  • Build patches incrementally for large datasets
  • Use in-place operations where available (Rust)
  • Batch operations instead of multiple small patches

Language-Specific

  • Rust: Use apply_inplace() for zero-copy operations
  • Python: Leverage built-in type conversion
  • JavaScript: Build patches once, apply multiple times

Migration Guide

From JSON Patch (RFC 6902)

Old way (JSON Patch):

[
    {"op": "replace", "path": "/name", "value": "New Name"},
    {"op": "remove", "path": "/age"}
]

New way (BYTEMATE:PATCH):

let patch = BytematePatch::new()
    .set("name", json!("New Name"))
    .delete("age");

From Other Libraries

BYTEMATE:PATCH uses an intuitive builder pattern that's easier to read and write across all languages.

Platform Support

| Platform | Status | Package | Installation | |:----------------|:-----------|:-----------------|:-----------------------------| | Rust | ✅ Native | bytemate-patch | cargo add bytemate-patch | | Python 3.8+ | ✅ Wheels | bytemate-patch | pip install bytemate-patch | | Node.js 16+ | ✅ WASM | bytemate-patch | npm install bytemate-patch | | Browsers | ✅ WASM | ES modules | CDN or bundler | | TypeScript | ✅ Included | Auto-generated | .d.ts included |

Real Talk

Other libraries use warnings instead of proper error handling. They rebuild indexes on every operation. They make you choose between "fast" and "works correctly."

We said "why not both?" and built it in Rust.

Your users deserve better than waiting 200ms for a simple patch operation.

So do you.

Benchmarks

All benchmarks run on real hardware, measuring real operations:

  • Sub-microsecond basic operations: 349ns average
  • JavaScript WASM performance: 12.6ms for 1000 items
  • O(1) serial key lookups: Proven with 79K ops/sec throughput
  • Memory efficient: Zero-copy operations measured 25% faster
  • Linear scaling: 1000x more data = 1000x more time (not exponential)

License

MIT License - because we're not monsters.

Contributing

Found a bug? Performance issue? We actually want to hear about it.

  • 🐛 Bug reports: Include minimal reproduction case
  • 🚀 Performance issues: Include benchmark data
  • 💡 Feature requests: Explain your use case
  • 🔧 Pull requests: Include tests and benchmarks

Open an issue or PR on GitHub.

Built with ❤️ and an unhealthy obsession with performance.