JavaScript library to zip and unzip files supporting multi-core compression, compression streams, zip64, split files and encryption.
Attributes
Popular
Repository
Current version released
2 years ago
Versions
- v2.7.53Latest
- v2.7.52
- v2.7.51
- v2.7.50
- v2.7.49
- v2.7.48
- v2.7.47
- v2.7.46
- v2.7.45
- v2.7.44
- v2.7.43
- v2.7.42
- v2.7.41
- v2.7.40
- v2.7.39
- v2.7.38
- v2.7.37
- v2.7.36
- v2.7.35
- v2.7.34
- v2.7.33
- v2.7.32
- v2.7.31
- v2.7.30
- v2.7.29
- v2.7.28
- v2.7.27
- v2.7.26
- v2.7.25
- v2.7.24
- v2.7.23
- v2.7.22
- v2.7.21
- v2.7.20
- v2.7.19
- v2.7.18
- v2.7.17
- v2.7.16
- v2.7.15
- v2.7.14
- v2.7.13
- v2.7.12
- v2.7.11
- v2.7.10
- v2.7.9
- v2.7.8
- v2.7.7
- v2.7.6
- v2.7.5
- v2.7.4
- v2.7.3
- v2.7.2
- v2.7.0
- v2.6.84
- v2.6.83
- v2.6.82
- 2.6.81
- 2.6.80
- v2.6.79
- v2.6.78
- v2.6.77
- v2.6.75
- v2.6.74
- v2.6.73
- v2.6.72
- v2.6.70
- v2.6.69
- v2.6.68
- v2.6.67
- v2.6.66
- v2.6.65
- v2.6.63
- v2.6.62
- v2.6.61
- v2.6.60
- v.2.6.59
- v2.6.58
- v2.6.57
- v2.6.56
- v2.6.55
- test
- v2.6.54
- v2.6.52
- v2.6.51
- v2.6.50
- v2.6.48
- v2.6.47
- v2.6.46
- v2.6.45
- v2.6.44
- v2.6.43
- v2.6.42
- v2.6.41
- v2.6.40
- v2.6.39
- v2.6.37
- v2.6.36
- v2.6.35
- v2.6.34
- v2.6.33
- v2.6.32
- v2.6.31
- v2.6.30
- v2.6.29
- v2.6.28
- v2.6.27
- v2.6.26
- v2.6.25
- v2.6.24
- v2.6.23
- v2.6.21
- v2.6.20
- v2.6.19
- v2.6.18
- v2.6.17
- v2.6.16
- v2.6.15
- v2.6.14
- v2.6.13
- v2.6.12
- v2.6.11
- v2.6.10
- v2.6.9
- v2.6.8
- v2.6.7
- v2.6.6
- v2.6.5
- v2.6.4
- v2.6.3
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.26
- v2.5.25
- v2.5.24
- v2.5.23
- v2.5.22
- v2.5.21
- v2.5.20
- v2.5.19
- v2.5.18
- v2.5.17
- v2.5.16
- v2.5.15
- v2.5.14
- v2.5.13
- v2.5.12
- v2.5.11
- v2.5.10
- v2.5.9
- v2.5.7
- v2.5.6
- v2.5.5
- V2.5.4
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.26
- v2.4.25
- v2.4.24
- v2.4.23
- v2.4.22
- v2.4.21
- v2.4.20
- v2.4.19
- v2.4.18
- v2.4.17
- v2.4.16
- v2.4.15
- v2.4.14
- v2.4.13
- v2.4.12
- v2.4.11
- v2.4.10
- v2.4.9
- v2.4.8
- v2.4.7
- v2.4.6
- v2.4.5
- v2.4.4
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.24
- v2.3.23
- v2.3.22
- v2.3.21
- v2.3.20
- v2.3.19
- v2.3.18
- v2.3.17
- v2.3.16.1
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/
// Hello world with zip.js (and Streams)
import { ZipWriter, ZipReader, BlobReader } from "https://deno.land/x/zipjs/index.js";
// ----
// Write the zip file
// ----
// Creates a TransformStream object where the zip content will be written.
const zipStream = new TransformStream();
// Creates a Promise object resolved to the zip content returned as a Blob object.
const zipBlobPromise = new Response(zipStream.readable).blob();
// Creates a ReadableStream object containing the text of the entry to add in the zip.
const helloWorldReadable = new Blob(["Hello world!"], { type: "text/plain" }).stream();
// Creates a ZipWriter object writing data via zipStream, adds the file "hello.txt" containing
// the text "Hello world!" via helloWorldReadable in the zip, and closes the writer.
const zipWriter = new ZipWriter(zipStream);
await zipWriter.add("hello.txt", { readable: helloWorldReadable });
await zipWriter.close();
// Retrieves the Blob object containing the zip content.
const zipBlob = await zipBlobPromise;
// Uncomment the following code to download the zip file (in a browser)
//
// const anchorElement = document.createElement("a");
// anchorElement.href = URL.createObjectURL(zipBlob);
// anchorElement.download = "hello.zip";
// anchorElement.click();
//
// ----
// Read the zip file
// ----
// Creates a TransformStream object where the content of the first entry in the zip will be written.
const contentStream = new TransformStream();
// Creates a Promise object resolved to the first entry content returned as text.
const contentTextPromise = new Response(contentStream.readable).text();
// Reads zipBlob via a BlobReader object, retrieves metadata (name, dates, etc.) of the first entry,
// retrieves its content via contentStream, and closes the reader.
const zipReader = new ZipReader(new BlobReader(zipBlob));
const firstEntry = (await zipReader.getEntries()).shift();
await firstEntry.getData(contentStream);
await zipReader.close();
// Displays "Hello world!".
const contentText = await contentTextPromise;
console.log(contentText);
See here for more examples: https://github.com/gildas-lormeau/zip.js/tree/master/tests/all