Files
bun.sh/simple_unzip_test.js
Claude Bot 4bd9795638 Implement Bun.unzipSync API for ZIP file extraction
This adds a new `unzipSync` function to the Bun runtime that allows
synchronous extraction of ZIP files. The implementation:

- Uses Zig's std.zip library for robust ZIP parsing
- Returns the first file found as a Uint8Array (simplified for initial version)
- Includes security measures to prevent directory traversal attacks
- Handles deflate and store compression methods
- Provides comprehensive error handling for malformed ZIP files

API Usage:
```javascript
import { unzipSync } from "bun";
const data = unzipSync(zipBuffer);
```

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-22 22:49:04 +00:00

24 lines
621 B
JavaScript

// Simple test to verify Bun.unzipSync is available
try {
const { unzipSync } = require("bun");
console.log("unzipSync function:", typeof unzipSync);
// Test with invalid input to see if it throws the right error
try {
unzipSync("not a buffer");
} catch (err) {
console.log("Expected error:", err.message);
}
// Test with empty buffer
try {
unzipSync(new Uint8Array(0));
} catch (err) {
console.log("Expected empty buffer error:", err.message);
}
console.log("Basic API test passed!");
} catch (err) {
console.error("API not available:", err.message);
process.exit(1);
}