mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-04 10:50:59 +01:00
docs update
This commit is contained in:
parent
9b4b6b9a30
commit
dfe21c62da
2 changed files with 29 additions and 10 deletions
27
README.md
27
README.md
|
@ -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;
|
||||
|
||||
```
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue