Skip to content
/ zip Public

Lightweight (~1.3KB) ZIP file creator for Browser and Node.js. No dependencies.

Notifications You must be signed in to change notification settings

litejs/zip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LiteJS Zip – Coverage Size Buy Me A Tea

Lightweight (~1.3KB) ZIP file creator for Browser and Node.js. No dependencies.
Uses the CompressionStream API if available; otherwise uses provided deflater or creates an uncompressed ZIP.

createZip(files [, options] [, callback])

  • files: Array of {name, content[, time]}
  • options: { deflate: deflateRawSync, comment: 'Comment for a file' } (optional custom deflater makes ZIP creation synchronous)
  • callback: Optional (err, zip) callback

Returns a Promise<Uint8Array>, or invokes provided callback, or the ZIP synchronously when using a custom deflater.

Examples

const { createZip } = require("@litejs/zip")

// Async usage
const zipUint8Array = await createZip([
    { name: "file-a.txt", content: "Some content" },
    { name: "dir/file-b.txt", content: Uint8Array.from("012"), time: new Date(2020, 1, 21) },
])

// Callback style
createZip(files, { comment: "Some comment for a zip file" }, (err, zipUint8Array) => {
    // Handle ZIP file content
})

// With custom deflate runs synchronously
const zlib = require("zlib")
const zipInSync = createZip(files, { deflate: zlib.deflateRawSync })

Contributing

Follow Coding Style Guide, run tests npm install; npm test.

Copyright (c) 2023-2025 Lauri Rooden <lauri@rooden.ee>
MIT License | GitHub repo | npm package | Buy Me A Tea

About

Lightweight (~1.3KB) ZIP file creator for Browser and Node.js. No dependencies.

Topics

Resources

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project