npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

xinzip

v1.0.0

Published

High-performance streaming parallel compression library for large files (16GB+) in browsers

Readme

Xinzip - 高性能流式并行压缩库

npm version License: MIT

专为大文件设计的浏览器端压缩库,支持16GB+文件的高效流式并行压缩。

✨ 特性

  • 🚀 极速压缩:流式并行处理,充分利用多核CPU
  • 💾 内存可控:始终控制在2GB内存以内
  • 📁 大文件支持:理论支持无限大小文件(已测试16GB+)
  • 🔧 自动优化:根据文件大小自动调整压缩策略
  • 📊 实时监控:详细的进度和性能统计
  • 🌐 纯浏览器:无需服务器,完全在浏览器端运行

📦 安装

npm install xinzip

🚀 快速开始

基础用法

import Xinzip from 'xinzip';

// 创建压缩器实例
const compressor = new Xinzip({
    compressionLevel: 6,        // 压缩级别 1-9
    maxWorkers: 4,              // 最大Worker数量
    onProgress: (progress, completed, total) => {
        console.log(`压缩进度: ${progress.toFixed(1)}% (${completed}/${total})`);
    }
});

// 压缩文件
async function compressFile(file) {
    try {
        // 初始化(只需要调用一次)
        await compressor.init();
        
        // 压缩
        const result = await compressor.compress(file);
        
        console.log('压缩完成:', result.stats);
        console.log('原始大小:', result.stats.originalSize);
        console.log('压缩后大小:', result.stats.compressedSize);
        console.log('压缩率:', result.stats.compressionRatio);
        console.log('压缩速度:', result.stats.speed);
        
        // result.data 是压缩后的 Uint8Array
        return result.data;
        
    } catch (error) {
        console.error('压缩失败:', error);
    }
}

// 使用示例
const fileInput = document.getElementById('fileInput');
fileInput.addEventListener('change', async (e) => {
    const file = e.target.files[0];
    if (file) {
        const compressedData = await compressFile(file);
        
        // 下载压缩后的文件
        const blob = new Blob([compressedData], { type: 'application/gzip' });
        const url = URL.createObjectURL(blob);
        const a = document.createElement('a');
        a.href = url;
        a.download = file.name + '.gz';
        a.click();
        URL.revokeObjectURL(url);
    }
});

高级配置

const compressor = new Xinzip({
    chunkSize: 32 * 1024 * 1024,     // 32MB 块大小
    compressionLevel: 9,              // 最高压缩级别
    maxWorkers: 8,                    // 8个Worker并行
    memoryLimit: 4 * 1024 * 1024 * 1024, // 4GB内存限制
    onProgress: (progress, completed, total) => {
        // 更新进度条
        updateProgressBar(progress);
    }
});

支持的输入类型

// 文件对象
await compressor.compress(file);

// Blob对象
await compressor.compress(blob);

// ArrayBuffer
await compressor.compress(arrayBuffer);

// Uint8Array
await compressor.compress(uint8Array);

📊 性能数据

| 文件大小 | 压缩速度 | 内存使用 | 压缩率 | |---------|----------|----------|--------| | 100MB | ~200MB/s | <500MB | ~70% | | 1GB | ~300MB/s | <1GB | ~75% | | 8GB | ~400MB/s | <2GB | ~80% | | 16GB | ~500MB/s | <2GB | ~85% |

测试环境:Chrome 120+, 8核CPU, 16GB内存

🔧 API 参考

Xinzip(options?)

创建压缩器实例。

选项

  • chunkSize?: number - 数据块大小,默认16MB
  • compressionLevel?: number - 压缩级别 1-9,默认6
  • maxWorkers?: number - 最大Worker数量,默认为CPU核心数(最多8个)
  • memoryLimit?: number - 内存限制,默认2GB
  • onProgress?: Function - 进度回调 (progress, completed, total) => void

方法

  • init(): Promise<void> - 初始化压缩器
  • compress(input, options?): Promise<CompressionResult> - 压缩数据
  • destroy(): void - 清理资源

🌐 浏览器兼容性

  • Chrome 57+
  • Firefox 52+
  • Safari 11+
  • Edge 16+

需要支持:

  • WebAssembly
  • Web Workers
  • ES6 Modules

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📄 许可证

MIT License

🔗 相关链接