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

bare-delta

v1.1.0

Published

Binary patch handling for Bare

Readme

bare-delta

Binary patch handling for Bare. Provides both asynchronous and synchronous APIs for creating and applying binary deltas using a modified version of Fossil SCM's delta algorithm.

Includes zstd support for working with compressed patches.

npm install bare-delta

Usage

const original = Buffer.from('Hello world!')
const modified = Buffer.from('Hello Bare world!')

// Async API
const patch = await create(original, modified)
const result = await apply(original, patch)

// Sync API  
const patch = createSync(original, modified)
const result = applySync(original, patch)

// Apply multiple patches
const patches = [patch1, patch2, patch3]
const finalResult = await applyBatch(original, patches)
const finalResultSync = applyBatchSync(original, patches)

API

create(original, modified[, options])

Creates a binary patch between two buffers.

  • original - Original data (Buffer or Uint8Array)
  • modified - Modified data (Buffer or Uint8Array)
  • options - Optional creation options
    • hashWindowSize - Hash window size (must be power of 2, default: 16)
    • searchDepth - Maximum search depth for matches (default: 250)
    • compressed - Whether to compress the patch (default: false)

Returns a Promise<Buffer> containing the patch.

apply(original, patch)

Applies a binary patch to reconstruct the modified data. Automatically detects if the patch is compressed.

  • original - Original data (Buffer or Uint8Array)
  • patch - Patch created by create() (Buffer or Uint8Array)

Returns a Promise<Buffer> containing the result.

applyBatch(original, patches)

Applies multiple binary patches sequentially to reconstruct the final result. Automatically detects if each patch is compressed.

  • original - Original data (Buffer or Uint8Array)
  • patches - Array of patches to apply in order (Array of Buffer or Uint8Array)

Returns a Promise<Buffer> containing the result.

createSync(original, modified[, options])

Synchronous version of create(). Returns a Buffer directly.

  • original - Original data (Buffer or Uint8Array)
  • modified - Modified data (Buffer or Uint8Array)
  • options - Optional creation options
    • hashWindowSize - Hash window size (must be power of 2, default: 16)
    • searchDepth - Maximum search depth for matches (default: 250)
    • compressed - Whether to compress the patch (default: false)

applySync(original, patch)

Synchronous version of apply(). Returns a Buffer directly. Automatically detects if the patch is compressed.

  • original - Original data (Buffer or Uint8Array)
  • patch - Patch created by create() (Buffer or Uint8Array)

applyBatchSync(original, patches)

Synchronous version of applyBatch(). Returns a Buffer directly. Automatically detects if each patch is compressed.

  • original - Original data (Buffer or Uint8Array)
  • patches - Array of patches to apply in order (Array of Buffer or Uint8Array)

Algorithm Enhancements

This library implements an enhanced version of Fossil SCM's delta compression algorithm with the following optimizations:

SIMD Acceleration

We've added SIMD (Single Instruction Multiple Data) optimizations to accelerate the core hash computation and chunk matching operations. Our SIMD implementation processes multiple data elements in parallel for these operations on modern processors.

Compact Encoding

The original Fossil delta format uses a custom base-64 encoding for integers (see putInt/getInt functions in the reference implementation). We've replaced this with compact-encoding for variable-length integer encoding.

Performance

Use the sync API for better performance on small to medium files. Use the async API for large files or when you need to avoid blocking the event loop.

License

Apache 2.0

This project incorporates code from Fossil SCM's delta compression algorithm, which is licensed under the BSD-2-Clause License. Copyright (c) 2006 D. Richard Hipp.