Vcdiff Decoder
A Vcdiff decoder written in pure JavaScript.
Supports the Vcdiff format, as specified in RFC 3284.
Tested and proven with Vcdiff patch/delta files generated from
Google's open-vcdiff
and Joshua MacDonald's xdelta.
Usage
const vcdiff = require('@ably/vcdiff-decoder');
let target = vcdiff.decodeSync(deltaBuffer, new Buffer('some dictionary string buffer'));
console.log(target.toString());
Exported Functions
decodeSync(delta, source)
Synchronous decode. Parameters:
delta
: Buffer
- the binary Vcdiff format encoding of the patch/diff information needed to transform source
to the returned targetsource
: Buffer
- the group of bytes to transform to the returned target using by applying delta
Returns a Buffer
, the 'target', being the result of applying delta
to source
.
decode(delta, source)
Asynchronous decode.
The input parameters for this function are the same as for the synchronous function decodeSync(delta, source)
.
The difference is that this function returns a Promise
that either resolves with the target Buffer
or rejects with an error.
Contributing
Requirements
The vcdiff
dev dependency of this project, used for testing, fails to build against Node.js 9 and newer.
For this reason, until #3 has been addressed, the tests must be run against an environment with Node.js 8 installed.
At the time of writing this means:
vcdiff-decoder % node --version
v8.17.0
vcdiff-decoder % npm --version
6.13.4
For those who use
ASDF
or compatible tooling to manage their Node.js runtime versions, we have included a
.tool-versions
file.
Testing
To run all tests use
npm test
Browser testing supported by
for which you will need to configure environment variables for BROWSERSTACK_USERNAME
and BROWSERSTACK_ACCESSKEY
.
Release checklist
- Run
npm run grunt -- release:patch
(or "major", "minor" or "prepatch" as appropriate - see grunt-bump Usage Examples) - Run
npm run grunt -- release:deploy
- Visit tags and draft new release for the newly created tag