Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@zip.js/zip.js

Package Overview
Dependencies
Maintainers
2
Versions
276
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zip.js/zip.js

A JavaScript library to zip and unzip files in the browser, Deno and Node.js

  • 2.7.54
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
990K
increased by3.13%
Maintainers
2
Weekly downloads
 
Created

What is @zip.js/zip.js?

@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.

What are @zip.js/zip.js's main functionalities?

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();

Other packages similar to @zip.js/zip.js

Keywords

FAQs

Package last updated on 05 Dec 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc