Skip to content

An binary diff and patch library based on bsdiff algorithm for NodeJS (Windows, Mac, Linux). Allow larger than 2GB files to be read.

License

Notifications You must be signed in to change notification settings

porsager/bsdiff-nodejs

 
 

Repository files navigation

NpmLicense Build Status Build status

bsdiff-nodejs

An binary diff and patch library based on bsdiff algorithm for NodeJS (Windows, Mac, Linux)



If you find this package useful, please don't forget to star ⭐️ the repo, as this will help to promote the project.


Installation

Install as a dependency for your project (need python 2.x):

npm install --save bsdiff-nodejs

Usage

const bsdiff = require('bsdiff-nodejs');
bsdiff.diff(oldFile, newFile, patchFile, function(result, err) {}); // Async
bsdiff.patch(oldfile, newfile, patchfile, function(result, err) {}); // Async

bsdiff.diffSync(oldFile, newFile, patchFile); // Sync
bsdiff.patchSync(oldfile, newfile, patchfile); // Sync

For example:

const fs = require('fs');
const path = require('path');

const oldFile = path.join(__dirname, 'resources/react-0.3-stable.zip');
const newFile = path.join(__dirname, 'resources/react-0.4-stable.zip');
const patchFile = path.join(__dirname, 'resources/react.patch');
const generatedFile = path.join(__dirname, 'resources/react-generated.zip');

async function asyncCall() {
    await bsdiff.diff(oldFile, newFile, patchFile, function (result) {
        console.log('diff:' + String(result).padStart(4) + '%');
    });

    await bsdiff.patch(oldFile, generatedFile, patchFile, function (result) {
        console.log('patch:' + String(result).padStart(4) + '%');
    });
}
  
asyncCall();

License

The original algorithm and implementation was developed by Colin Percival. The algorithm is detailed in his paper, Naïve Differences of Executable Code. For more information, visit his website at http://www.daemonology.net/bsdiff/.

Copyright 2003-2005 Colin Percival
MIT © Exoway

About

An binary diff and patch library based on bsdiff algorithm for NodeJS (Windows, Mac, Linux). Allow larger than 2GB files to be read.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 93.8%
  • C++ 5.3%
  • Other 0.9%