An binary diff and patch library based on bsdiff algorithm for NodeJS (Windows, Mac, Linux).
npm install bsdiff-node
!NpmLicense
> 🟡 Project status: maintenance mode
- Project is no longer in active development
- Only bug-related issues are accepted
- Only bug-related pull requests are accepted
- New features are unlikely to be added
- Project status may eventually transition to "discontinued" or back to "active"
If you find this package useful, please don't forget to star ⭐️ the repo, as this will help to promote the project.
bash
npm i bsdiff-node
`
Usage
`javascript
const bsdiff = require('bsdiff-node');
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:
`javascript
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();
``