jszip
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
lie | 3.3.0 | 8.67 kB | MIT | prod | |
pako | 1.0.11 | 199.69 kB | (MIT AND Zlib) | prod | |
readable-stream | 2.3.8 | 25.14 kB | MIT | prod | |
setimmediate | 1.0.5 | 3.18 kB | MIT | prod |
JSZip is a powerful JavaScript library that provides features for creating, reading, and editing .zip files with a simple and delightful API. The tool is widely used in client-side and server-side JavaScript applications for managing .zip files. Further insights can be found on the project's GitHub page at git+https://github.com/Stuk/jszip.git.
Using JSZip is straightforward and requires just a few lines of code. To start, instantiate a new JSZip object. From there, you can create files and directories using the file
and folder
methods respectively. For instance, to create a 'Hello.txt' file containing 'Hello World', use zip.file("Hello.txt", "Hello World\n");
. You can add images or other files using similar methods. To generate the zip, use the generateAsync
method, as showcased in the example below.
const zip = new JSZip();
zip.file("Hello.txt", "Hello World\n");
const img = zip.folder("images");
img.file("smile.gif", imgData, {base64: true});
zip.generateAsync({type:"blob"}).then(function(content) {
// see FileSaver.js
saveAs(content, "example.zip");
});
The above script eventually results in a zip file containing 'Hello.txt' and 'images/smile.gif'.
The comprehensive documentation for JSZip is available at the official documentation page https://stuk.github.io/jszip. The documentation covers a broad range of topics including installation, API reference, and several usage examples. Users are encouraged to explore the documentation to gain a better understanding and fully leverage the potential of JSZip.