wazip
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

wazip

build

wazip is a ZIP file manipulation library for JavaScript powered by WebAssembly and written in Rust.

Usage

import wazip_init, { ZipWriter } from "wazip";
import { saveAs } from "file-saver";

async function main() {
  // Init wazip by calling its init function (the default export)
  await wazip_init();

  // Create a new ZipWriter to create a new archive
  let writer = new ZipWriter();

  // You can optionally set the ZIP comment for the archive
  writer.set_comment("a nice message!");

  // Add a new file with `start_file`
  writer.start_file("foo.txt");

  // Write data to the current file (foo.txt)
  // ZipWriter.write() takes an array or typed-array. strings must be encoded
  writer.write(new TextEncoder().encode("hello world!"));

  // When you're done, call writer.finish() and you get a Uint8Array (the ZIP)
  let zip_data = writer.finish();

  // This example uses file-saver to download the generated ZIP file
  saveAs(new Blob([zip_data], { type = "application/zip" }), "bar.zip");
}

main();

Features

Feature Status
Create an archive from scratch Supported
Read an existing archive 🚧 Planned
Modify an archive 🚧 Planned

Currently only DEFLATE is supported, but support for uncompressed storage is planned. Other compression methods might be added if they can be ported to WASM.

License

wazip is licensed under the terms of both the MIT license and the Apache License (Version 2.0), at your choice.

See LICENSE-MIT and LICENSE-APACHE-2.0 files for the full texts.

Readme

Keywords

none

Package Sidebar

Install

npm i wazip

Weekly Downloads

1

Version

0.1.0

License

MIT OR Apache-2.0

Unpacked Size

127 kB

Total Files

8

Last publish

Collaborators

  • nasso