adm-zip
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
ADM-ZIP is a comprehensive zip data compression library written in pure JavaScript for NodeJS. The library allows users to extract and create zip files directly to disk or in memory, making it a versatile tool for managing compressed files. With ADM-ZIP, you can effortlessly handle zip files in memory or write them on-the-go to your storage. It also provides a simple API for updating the contents of existing zip files.
Using ADM-ZIP in Node.js is incredibly straightforward. After installing it via npm, you can begin incorporating its functionality into your projects right away.
To add the package to your application, first install it via npm. You can do it using the following command:
npm install adm-zip
Then, you can import the module into your JavaScript file:
var AdmZip = require('adm-zip');
To read archive files, you can initialize a new AdmZip object with the path to your desired zip file. This provides you easy access to all entries within the zip:
var zip = new AdmZip("./path_to_your_file.zip");
var zipEntries = zip.getEntries();
You can then iterate through the zip entries using a forEach loop and process each entry according to your needs:
zipEntries.forEach(function(zipEntry) {
console.log(zipEntry.toString());
});
Creating archives is just as seamless. You can create a new archive, add files with custom content, and output the final zip file to disk:
// creating archives
var zip = new AdmZip();
// add file directly
var content = "inner content of the file";
zip.addFile("test.txt", Buffer.from(content, "utf8"), "entry comment goes here");
// write everything to disk
zip.writeZip("./path_to_your_zipfile.zip");
The robust ADM-ZIP documentation can be accessed on its GitHub page's wiki section. The documentation features details about the API, descriptions of available methods, use cases, and numerous code examples. Visit the wiki at: ADM-ZIP Wiki to access step-by-step guides and extensive code examples covering different aspects of the library's functionality.