Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@zip.js/zip.js
Advanced tools
@zip.js/zip.js is a JavaScript library that provides functionalities for creating, reading, and manipulating ZIP files directly in the browser or in Node.js environments. It supports various compression methods and allows for asynchronous operations, making it suitable for handling large files efficiently.
Creating ZIP Files
This feature allows you to create a ZIP file and add files to it. In this example, a text file named 'hello.txt' with the content 'Hello, World!' is added to the ZIP file.
const { ZipWriter } = require('@zip.js/zip.js');
const writer = new ZipWriter(new zip.BlobWriter('application/zip'));
await writer.add('hello.txt', new zip.TextReader('Hello, World!'));
const zipBlob = await writer.close();
console.log(zipBlob);
Reading ZIP Files
This feature allows you to read the contents of a ZIP file. In this example, the code reads the 'hello.txt' file from the ZIP and logs its content.
const { ZipReader } = require('@zip.js/zip.js');
const reader = new ZipReader(new zip.BlobReader(zipBlob));
const entries = await reader.getEntries();
for (const entry of entries) {
if (entry.filename === 'hello.txt') {
const text = await entry.getData(new zip.TextWriter());
console.log(text); // 'Hello, World!'
}
}
await reader.close();
Extracting ZIP Files
This feature allows you to extract files from a ZIP archive. The example demonstrates how to extract each file as a Blob object.
const { ZipReader } = require('@zip.js/zip.js');
const reader = new ZipReader(new zip.BlobReader(zipBlob));
const entries = await reader.getEntries();
for (const entry of entries) {
const blob = await entry.getData(new zip.BlobWriter());
console.log(blob); // Blob object for each file
}
await reader.close();
JSZip is a popular library for creating, reading, and editing .zip files with JavaScript. It is widely used and has a straightforward API. Compared to @zip.js/zip.js, JSZip is more mature and has a larger user base, but it may not support as many advanced features or compression methods.
ADM-ZIP is a pure JavaScript implementation for ZIP file handling in Node.js. It provides functionalities for reading and writing ZIP files, including support for password-protected archives. ADM-ZIP is more focused on Node.js environments, whereas @zip.js/zip.js can be used both in the browser and Node.js.
Yazl is a ZIP file creation library for Node.js. It is designed to be fast and efficient, with a focus on streaming data into ZIP files. Compared to @zip.js/zip.js, Yazl is more specialized for ZIP file creation and may not offer as many features for reading or manipulating existing ZIP files.
zip.js is an open-source library (BSD-3-Clause license) for zipping and unzipping files in the browser and Deno.
See here for more info: https://gildas-lormeau.github.io/zip.js/
FAQs
A JavaScript library to zip and unzip files in the browser, Deno and Node.js
We found that @zip.js/zip.js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.