This port was derived from a number of sources including: the Python library bsdiff4 (https://github.com/ilanschnell/bsdiff4), which was itself derived from cx_bsdiff (http://cx-bsdiff.sf.net); the original BSD version BSDiff (http://www.daemonology.net/bsdiff); and the existing node.js port, node-bsdiff (https://github.com/mikepb/node-bsdiff).
This port implements the bsdiff and bspatch algorithms, but it does not parse or generate BSDIFF 4 patch files or provide compression. The functions exported operate on the raw control, diff and extra blocks. Operation is asynchronous.
var fs = require('fs');
var bsdiff4 = require('bsdiff4');
var origData = fs.readFileSync('oldfile');
var newData = fs.readFileSync('newfile');
bsdiff4.diff(origData, newData, function(err, control, diff, extra) {
bsdiff4.patch(origData, newData.length, control, diff, extra, function(err, out) {
...
});
});
-
bsdiff4.diff(origData, newData, callback)
- generate a BSDiff patchorigData
- aBuffer
containing the original (source) datanewData
- aBuffer
containing the new (target) datacallback
- a function to call once a patch has been generatederr
- null on success,an
Error` object on errorcontrol
- anArray
containing the control blockdiffBlock
- aBuffer
containing the diff blockextraBlock
- aBuffer
containing the extra block
-
bsdiff4.patch(origData, newDataLength, control, diffBlock, extraBlock, callback)
- apply a BSDiff patchorigData
- aBuffer
containing the original (source) datanewDataLength
- the size of the new (target) data in bytescontrol
- anArray
of integers representing the control blockdiffBlock
- aBuffer
containing the diff blockextraBlock
- aBuffer
containing the extra blockcallback
- a function to call once a patch has been appliederr
- null on success, anError
object on errorout
- aBuffer
containing the new (target) data