Skip to content

Commit 1ee3355

Browse files
committed
Update Readme
1 parent d97243d commit 1ee3355

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,39 @@
1010
LiteJS Zip – [![Coverage][1]][2] [![Size][3]][4] [![Buy Me A Tea][5]][6]
1111
==========
1212

13-
Dependency-free JavaScript library for creating ZIP files (~1.2KB) in Browser or Server.
14-
Uses the CompressionStream API if available; otherwise will generate uncompressed ZIP.
13+
Lightweight (~1.2KB) ZIP file creator for Browser and Node.js. No dependencies.
14+
Uses the CompressionStream API when available; otherwise will generate uncompressed ZIP.
15+
16+
17+
createZip(files [, options] [, callback])
18+
19+
- files: Array of `{name, content[, time]}`
20+
- options: `{ deflate: deflateRawSync }` (optional custom deflater makes ZIP creation synchronous)
21+
- callback: Optional `(err, zip)` callback
22+
23+
Returns a `Promise<Uint8Array>`, or invokes provided `callback`, or the ZIP synchronously when using a custom deflater.
1524

1625

1726
Examples
1827
--------
1928

2029
```javascript
21-
const { createZip } = require("@litejs/zip");
22-
const fileAsUint8Array = await createZip([
30+
const { createZip } = require("@litejs/zip")
31+
32+
// Async usage
33+
const zipUint8Array = await createZip([
2334
{ name: "file-a.txt", content: "Some content" },
2435
{ name: "dir/file-b.txt", content: Uint8Array.from("012"), time: new Date(2020, 1, 21) },
2536
])
37+
38+
// Callback style
39+
createZip(files, (err, zipUint8Array) => {
40+
// Handle ZIP file content
41+
})
42+
43+
// With custom deflate runs synchronously
44+
const zlib = require("zlib")
45+
const zipInSync = createZip(files, { deflate: zlib.deflateRawSync })
2646
```
2747

2848
## Contributing

0 commit comments

Comments
 (0)