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

file-chunk-worker

v1.1.6

Published

A lightweight file chunk processor with MD5 calculation using Web Workers

Readme

file-chunk-worker

🚀 高性能文件分片处理器,基于 Web Workers 实现多线程并发处理,支持进度反馈,适用于大文件上传、MD5 计算、分片校验等场景。

利用多线程并发处理文件块,大幅提升处理速度,告别主线程阻塞!

npm version License


✨ 特性

  • 多线程并发处理:使用 Web Workers,避免主线程阻塞
  • 自动分片:按指定大小切分文件
  • 进度反馈:实时返回处理进度(0 ~ 1)
  • 高性能:结合 spark-md5 快速计算哈希
  • 轻量无依赖(除 spark-md5):仅 5KB 左右(gzip)
  • 支持 ESM / UMD:现代与传统项目皆可用

📦 安装

npm install file-chunk-worker

JavaScript 使用

import FileProcessor from 'file-chunk-worker';

// 假设你有一个 File 对象(如 input[type=file] 选择的文件)
const file = document.querySelector('input[type=file]').files[0];

const processor = new FileProcessor(file, {
  chunkSize: 1024 * 1024,  // 每片 1MB(可选,默认 1MB)
  threadCount: 4           // 使用 4 个线程(可选,默认 4)
});

// 开始处理
const chunks = await processor.calculateMd5((progress) => {
  console.log(`处理进度: ${(progress * 100).toFixed(2)}%`);
});

console.log('所有分片:', chunks);
// 输出示例:
// [
//   { chunkIndex: 0, hash: 'a1b2c3d4...', size: 1048576, file: Blob },
//   { chunkIndex: 1, hash: 'e5f6g7h8...', size: 800000, file: Blob }
// ]

📚 API 参考

# new FaceGuard(options)

| 参数名 | 类型 | 默认值 | 描述 |
| --- | --- | --- | --- |
| file | File |  null | 要处理的文件对象 |
| options.chunkSize | number | 1M | 每个分片的大小(字节)|
| options.threadCount	 | number | 4 |使用的线程数 |

返回值

Promise<Chunk[]>:分片数组,每个分片包含:
| 属性名 | 类型 | 描述 |
| --- | --- | --- |
| chunkIndex | number | 分片索引 |
| start | number |  起始字节 |
| end | number | 结束字节 |
| hash | string | 分片的 MD5 哈希值 |
| size | number | 分片大小(字节) |
| file | Blob | 分片文件对象 |