docs update

This commit is contained in:
Vitaly Puzrin 2014-03-12 05:01:30 +04:00
parent 9b4b6b9a30
commit dfe21c62da
2 changed files with 29 additions and 10 deletions

View file

@ -63,15 +63,32 @@ var input = new Uint8Array();
//... fill input data here
var output = pako.deflate(input);
// Inflate
// Inflate (simple wrapper can throw exception on broken stream)
//
var compressed = new Uint8Array();
//... fill data to uncompress here
var result = pako.inflate(compressed);
if (result.err) {
console.log(result.err, result.msg);
try {
var result = pako.inflate(compressed);
catch (err) {
console.log(err);
}
var uncompressed = result.data;
//
// Alternate interface for chunking & without exceptions
//
var inflator = new pako.Inflate();
inflator.push(chunk1, false);
inflator.push(chunk2, false);
...
inflator.push(chunkN, true); // true -> last
if (inflator.err) {
console.log(inflator.msg);
}
var output = inflator.result;
```

View file

@ -246,12 +246,14 @@ Inflate.prototype.onEnd = function(status) {
*
* ```javascript
* var pako = require('pako')
* , in = Uint8Array([1,2,3,4,5,6,7,8,9])
* , out;
* , input = pako.deflate([1,2,3,4,5,6,7,8,9])
* , output;
*
* out = pako.inflate(data);
* if (out.err) { throw new Error(out.err); }
* console.log(pako.inflate(out.result));
* try {
* output = pako.inflate(input);
* } catch (err)
* console.log(err);
* }
* ```
**/
function inflate(input, options) {