mirror of
https://github.com/codedread/bitjs
synced 2025-10-03 17:49:16 +02:00
Update readme for streaming and add a TODO for Issue #11
This commit is contained in:
parent
a6f9026ab1
commit
042b318cfa
2 changed files with 38 additions and 8 deletions
43
README.md
43
README.md
|
@ -18,16 +18,45 @@ var flagbits = bstream.peekBits(6); // look ahead at next 6 bits, but do not adv
|
||||||
|
|
||||||
### bitjs.archive
|
### bitjs.archive
|
||||||
|
|
||||||
This namespace includes objects for unarchiving binary data in popular archive formats (zip, rar, tar) providing unzip, unrar and untar capabilities via JavaScript in the browser. The unarchive code depends on browser support of Web Workers. See the design doc.
|
This namespace includes objects for unarchiving binary data in popular archive formats (zip, rar, tar) providing unzip, unrar and untar capabilities via JavaScript in the browser. The unarchiving actually happens inside a Web Worker.
|
||||||
|
|
||||||
```
|
```
|
||||||
function updateProgressBar(e) { ... update UI element ... }
|
|
||||||
function displayZipContents(e) { ... display contents of the extracted zip file ... }
|
|
||||||
|
|
||||||
var unzipper = new bitjs.archive.Unzipper(zipFileArrayBuffer);
|
var unzipper = new bitjs.archive.Unzipper(zipFileArrayBuffer);
|
||||||
unzipper.addEventListener("progress", updateProgressBar);
|
unzipper.addEventListener('progress', updateProgress);
|
||||||
unzipper.addEventListener("finish", displayZipContents);
|
unzipper.addEventListener('extract', receiveOneFile);
|
||||||
|
unzipper.addEventListener('finish', displayZipContents);
|
||||||
unzipper.start();
|
unzipper.start();
|
||||||
|
|
||||||
|
function updateProgress(e) {
|
||||||
|
// e.totalCompressedBytesRead has how many bytes have been unzipped so far
|
||||||
|
}
|
||||||
|
|
||||||
|
function receiveOneFile(e) {
|
||||||
|
// e.unarchivedFile.filename: string
|
||||||
|
// e.unarchivedFile.fileData: Uint8Array
|
||||||
|
}
|
||||||
|
|
||||||
|
function displayZipContents() {
|
||||||
|
// Now sort your received files and show them or whatever...
|
||||||
|
}
|
||||||
|
|
||||||
|
function
|
||||||
|
```
|
||||||
|
|
||||||
|
The unarchivers also support streaming, if you are receiving the zipped file from a slow place (a Cloud API, for instance). For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
var unzipper = new bitjs.archive.Unzipper(anArrayBufferWithStartingBytes);
|
||||||
|
unzipper.addEventListener('progress', updateProgress);
|
||||||
|
unzipper.addEventListener('extract', receiveOneFile);
|
||||||
|
unzipper.addEventListener('finish', displayZipContents);
|
||||||
|
unzipper.start();
|
||||||
|
...
|
||||||
|
// after some time
|
||||||
|
unzipper.update(anArrayBufferWithMoreBytes);
|
||||||
|
...
|
||||||
|
// after some more time
|
||||||
|
unzipper.update(anArrayBufferWithYetMoreBytes);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
@ -37,7 +66,7 @@ unzipper.start();
|
||||||
|
|
||||||
## Reference
|
## Reference
|
||||||
|
|
||||||
* [UnRar](http://codedread.github.io/bitjs/docs/unrar.html): An work-in-progress description of the RAR file format.
|
* [UnRar](http://codedread.github.io/bitjs/docs/unrar.html): A work-in-progress description of the RAR file format.
|
||||||
|
|
||||||
## History
|
## History
|
||||||
|
|
||||||
|
|
|
@ -354,6 +354,7 @@ function RarReadTables(bstream) {
|
||||||
bstream.readBits( (8 - bstream.bitPtr) & 0x7 );
|
bstream.readBits( (8 - bstream.bitPtr) & 0x7 );
|
||||||
|
|
||||||
if (bstream.readBits(1)) {
|
if (bstream.readBits(1)) {
|
||||||
|
// TODO: Implement PPM. 07535.
|
||||||
info("Error! PPM not implemented yet");
|
info("Error! PPM not implemented yet");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue