Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Pizzip is a JavaScript library for creating, reading, and editing zip files in the browser or Node.js. It is particularly useful for handling Office Open XML files, such as .docx, .xlsx, and .pptx, which are essentially zip files containing XML documents.
Create a new zip file
This feature allows you to create a new zip file and add files to it. In this example, a new zip file is created, and a text file named 'hello.txt' with the content 'Hello, World!' is added to it.
const PizZip = require('pizzip');
const zip = new PizZip();
zip.file('hello.txt', 'Hello, World!');
const content = zip.generate({ type: 'nodebuffer' });
Read a zip file
This feature allows you to read an existing zip file. In this example, a zip file named 'example.zip' is read, and the content of the file 'hello.txt' within the zip is extracted as text.
const PizZip = require('pizzip');
const fs = require('fs');
const data = fs.readFileSync('example.zip');
const zip = new PizZip(data);
const fileContent = zip.file('hello.txt').asText();
Modify a file within a zip
This feature allows you to modify the content of a file within an existing zip file. In this example, the content of 'hello.txt' within 'example.zip' is changed to 'Modified content'.
const PizZip = require('pizzip');
const fs = require('fs');
const data = fs.readFileSync('example.zip');
const zip = new PizZip(data);
zip.file('hello.txt', 'Modified content');
const newContent = zip.generate({ type: 'nodebuffer' });
JSZip is a library for creating, reading, and editing zip files in JavaScript. It is similar to Pizzip in functionality, offering a wide range of features for handling zip files. JSZip is widely used and has a large community, making it a robust choice for zip file manipulation.
ADM-ZIP is a pure JavaScript implementation for zip file management with support for reading, creating, and updating zip files. It is similar to Pizzip but is often used in Node.js environments due to its synchronous API, which can be more straightforward for server-side applications.
PizZip is a fork of JSZip version 2.x, because we want a synchronous Zip library.
A library for creating, reading and editing .zip files with Javascript, with a lovely and simple API.
var zip = new PizZip();
zip.file("Hello.txt", "Hello World\n");
var img = zip.folder("images");
img.file("smile.gif", imgData, { base64: true });
var content = zip.generate({ type: "blob" });
// see FileSaver.js
saveAs(content, "example.zip");
/*
Results in a zip containing
Hello.txt
images/
smile.gif
*/
PizZip is dual-licensed. You may use it under the MIT license or the GPLv3 license. See LICENSE.markdown.
FAQs
Create, read and edit .zip files synchronously with Javascript
The npm package pizzip receives a total of 90,854 weekly downloads. As such, pizzip popularity was classified as popular.
We found that pizzip demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.