@ably/vcdiff-decoder
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "@ably/vcdiff-decoder", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Pure JavaScript vcdiff decoder that works with binary deltas from Google's open-vcdiff", | ||
"main": "lib/vcdiff_decoder.js", | ||
"scripts": { | ||
"test": "mocha" | ||
"grunt": "./node_modules/grunt-cli/bin/grunt", | ||
"test": "./node_modules/grunt-cli/bin/grunt test:all" | ||
}, | ||
@@ -32,9 +33,26 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/core": "^7.9.0", | ||
"@babel/preset-env": "^7.9.5", | ||
"babel-loader": "^8.1.0", | ||
"chai": "^3.5.0", | ||
"grunt": "^1.0.4", | ||
"core-js": "^3.6.5", | ||
"grunt": "^1.1.0", | ||
"grunt-cli": "^1.3.2", | ||
"grunt-bump": "^0.8.0", | ||
"grunt-karma": "^3.0.2", | ||
"grunt-mocha-test": "^0.13.3", | ||
"grunt-webpack": "^3.1.3", | ||
"karma": "^4.4.1", | ||
"karma-browserstack-launcher": "^1.5.1", | ||
"karma-firefox-launcher": "^1.3.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-sourcemap-loader": "^0.3.7", | ||
"karma-webpack": "^4.0.2", | ||
"mocha": "^3.0.2", | ||
"vcdiff": "baranov1ch/node-vcdiff" | ||
"vcdiff": "baranov1ch/node-vcdiff", | ||
"webpack": "^4.42.1", | ||
"webpack-cli": "^3.3.11" | ||
}, | ||
"homepage": "https://github.com/ably-forks/vcdiff-decoder" | ||
} |
@@ -1,10 +0,17 @@ | ||
# vcdiff-decoder | ||
# Vcdiff Decoder | ||
[![Build Status](https://travis-ci.org/ably-forks/vcdiff-decoder.svg?branch=master)](https://travis-ci.org/ably-forks/vcdiff-decoder) | ||
[![npm version](https://badge.fury.io/js/%40ably%2Fvcdiff-decoder.svg)](https://badge.fury.io/js/%40ably%2Fvcdiff-decoder) | ||
Pure JavaScript vcdiff decoder. Tested and proven working with vcdiff patch/delta files generated from Google's [open-vcdiff](https://github.com/google/open-vcdiff) and [xdelta](https://github.com/jmacd/xdelta) | ||
A Vcdiff decoder written in pure JavaScript. | ||
Supports the Vcdiff format, as specified in [RFC 3284](https://tools.ietf.org/html/rfc3284). | ||
Tested and proven with Vcdiff patch/delta files generated from | ||
[Google](https://github.com/google)'s [open-vcdiff](https://github.com/google/open-vcdiff) | ||
and [Joshua MacDonald](https://github.com/jmacd)'s [xdelta](https://github.com/jmacd/xdelta). | ||
## Usage | ||
```javascript | ||
const vcdiff = require('vcdiff-decoder'); | ||
const vcdiff = require('@ably/vcdiff-decoder'); | ||
@@ -15,21 +22,56 @@ let target = vcdiff.decodeSync(deltaBuffer, new Buffer('some dictionary string buffer')); | ||
## API | ||
### vcdiff.decodeSync(delta, source) | ||
* `delta` Buffer | ||
* `source` Buffer | ||
## Exported Functions | ||
Returns a `Buffer` object of the target. | ||
### `decodeSync(delta, source)` | ||
`delta` is the binary encoding of the information needed to transform the source to the target. It is encoded as vcdiff, as specified in [RFC 3284](https://tools.ietf.org/html/rfc3284) | ||
Synchronous decode. Parameters: | ||
`source` is the group of bytes to transform into the target. In delta encoding, this probably an old, cached version. | ||
* `delta`: [`Buffer`](https://nodejs.org/api/buffer.html) - the binary Vcdiff format encoding of the patch/diff information needed to transform `source` to the returned target | ||
* `source`: [`Buffer`](https://nodejs.org/api/buffer.html) - the group of bytes to transform to the returned target using by applying `delta` | ||
### vcdiff.decode(delta, source) | ||
Returns a `Buffer`, the 'target', being the result of applying `delta` to `source`. | ||
Same as above except returns a `Promise` that either resolves with the target `Buffer` or rejects with an error. | ||
### `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`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that either resolves with the target [`Buffer`](https://nodejs.org/api/buffer.html) or rejects with an error. | ||
## Contributing | ||
### Requirements | ||
The `vcdiff` dev dependency of this project, used for testing, fails to build against [Node.js 9](https://nodejs.org/download/release/latest-v9.x/) and newer. | ||
For this reason, until [#3](https://github.com/ably-forks/vcdiff-decoder/issues/3) has been addressed, the tests must be run against an environment with [Node.js 8](https://nodejs.org/download/release/latest-v8.x/) 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](https://github.com/asdf-vm/asdf) | ||
or compatible tooling to manage their Node.js runtime versions, we have included a | ||
[`.tool-versions`](.tool-versions) | ||
file. | ||
### Testing | ||
To run all tests use | ||
npm test | ||
Browser testing supported by | ||
[<img src="./resources/Browserstack-logo@2x.png" width="200px"></img>](https://www.browserstack.com/) | ||
for which you will need to configure environment variables for `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESSKEY`. | ||
## Release checklist | ||
1. Run `grunt release:<type>` (where `type` is "major", "minor", "patch", "prepatch") | ||
2. Run `grunt release:deploy` | ||
3. Visit [https://github.com/ably-forks/vcdiff-decoder/tags](https://github.com/ably-forks/vcdiff-decoder/tags) and draft new release for the newly created tag | ||
1. Run `npm run grunt -- release:patch` (or "major", "minor" or "prepatch" as appropriate - see [grunt-bump Usage Examples](https://github.com/vojtajina/grunt-bump#usage-examples)) | ||
2. Run `npm run grunt -- release:deploy` | ||
3. Visit [tags](https://github.com/ably-forks/vcdiff-decoder/tags) and draft new release for the newly created tag |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
26215
77
22
1