Skip to content

Commit

Permalink
v0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
101arrowz committed Jun 15, 2021
1 parent 688b524 commit b786929
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## 0.7.1
- Removed requirement for `setTimeout`
- Added support for unzip file filters (thanks to [@manucorporat](https://github.com/manucorporat): #67)
- Fixed streaming gunzip and unzlib bug causing corruption
## 0.7.0
- Improved errors
- Now errors are error objects instead of strings
Expand Down
18 changes: 13 additions & 5 deletions README.md
Expand Up @@ -249,7 +249,7 @@ const zipped = fflate.zipSync({
'other/tmp.txt': new Uint8Array([97, 98, 99, 100])
},
// You can also provide compression options
'myImageData.bmp': [aMassiveFile, {
'massiveImage.bmp': [aMassiveFile, {
level: 9,
mem: 12,
// ZIP-specific: mtime works here too, defaults to current time
Expand All @@ -274,13 +274,21 @@ const zipped = fflate.zipSync({
// | |-> 你好.txt
// |-> other
// | |-> tmp.txt
// myImageData.bmp
// massiveImage.bmp
// superTinyFile.png

// When decompressing, folders are not nested; all filepaths are fully
// written out in the keys. For example, the return value may be:
// { 'nested/directory/a2.txt': Uint8Array(2) [97, 97] })
const decompressed = fflate.unzipSync(zipped);
// { 'nested/directory/structure.txt': Uint8Array(2) [97, 97] }
const decompressed = fflate.unzipSync(zipped, {
// You may optionally supply a filter for files. By default, all files in a
// ZIP archive are extracted, but a filter can save resources by telling
// the library not to decompress certain files
filter(file) {
// Don't decompress the massive image or any files larger than 10 MiB
return file.name != 'massiveImage.bmp' && file.originalSize <= 10_000_000;
}
});
```

If you need extremely high performance or custom ZIP compression formats, you can use the highly-extensible ZIP streams. They take streams as both input and output. You can even use custom compression/decompression algorithms from other libraries, as long as they [are defined in the ZIP spec](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT) (see section 4.4.5). If you'd like more info on using custom compressors, [feel free to ask](https://github.com/101arrowz/fflate/discussions).
Expand Down Expand Up @@ -441,7 +449,7 @@ zip({ f1: aMassiveFile, 'f2.txt': anotherMassiveFile }, {
});

// unzip is the only async function without support for consume option
// Also parallelized, so unzip is also often much faster than unzipSync
// It is parallelized, so unzip is also often much faster than unzipSync
unzip(aMassiveZIPFile, (err, unzipped) => {
// If the archive has data.xml, log it here
console.log(unzipped['data.xml']);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "fflate",
"version": "0.7.0",
"version": "0.7.1",
"description": "High performance (de)compression in an 8kB package",
"main": "./lib/index.cjs",
"module": "./esm/browser.js",
Expand Down

0 comments on commit b786929

Please sign in to comment.