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

@admni/file-uploader

v1.0.1

Published

Browser file uploader SDK with queue, chunk upload, instant upload and pause/resume support.

Readme

@admni/file-uploader

浏览器端文件上传 SDK(TypeScript),按 v1.0.md 设计基线实现,支持:

  • 上传队列与并发调度(UploadQueue
  • 单文件完整生命周期(FileUploader
  • 直传 / 分片上传(滑动窗口并发)
  • 暂停 / 继续 / 取消(含网络自动暂停恢复)
  • 秒传(identical_storage)与同 hash 去重
  • 业务 code 拦截(onConfigResponse)与 bizCode 透传
  • Worker hash 并行计算(hashConcurrency

内部维护文档见 INTERNAL.md;完整规范源见 ../file-upload/v1.0.md

安装

npm i @admni/file-uploader

快速开始

import { UploadQueue, UploadBizError } from "@admni/file-uploader"

const queue = new UploadQueue({
  concurrency: 3,
  hashConcurrency: 2,
  onTaskChange(task) {
    console.log(task.taskId, task.fileName, task.state, task.progress)
  },
  // 可选:统一处理服务端 code
  onConfigResponse: async (response, retry, ctx) => {
    if (response.code === 0 && response.data) return response.data
    if (response.code === 1012) return retry() // 例如 token 刷新后重试
    throw new UploadBizError(
      "CONFIG_FAILED",
      response.message || `config failed: ${response.code}`,
      response.code,
      { ctx, response },
    )
  },
})

const taskId = queue.add(file, {
  async getUploadConfig({ fileHash, fileName, fileSize, fileType }) {
    const res = await fetch("/api/upload/config", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ fileHash, fileName, fileSize, fileType }),
    })
    return await res.json()
  },
  async notifyComplete(params) {
    await fetch("/api/upload/complete", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(params),
    })
  },
})

// 控制任务
queue.pause(taskId)
queue.resume(taskId)
queue.cancel(taskId)

核心能力

  • 状态机:pending -> hashing -> configuring -> uploading -> (merging) -> notifying -> success
  • 秒传:identical_storage=true 时跳过 uploading/merging
  • 可插拔策略:onConfigResponse 可处理业务码、重试、终止
  • 存储适配:内置 OBS / S3 / Custom(fetch PUT)
  • 可观测性:插件钩子(step start/end/error, network change)

API 速览

  • new UploadQueue(options)
  • queue.add(file, options)
  • queue.pause(taskId) / queue.resume(taskId) / queue.cancel(taskId)
  • queue.pauseAll() / queue.resumeAll() / queue.getTasks() / queue.destroy()

发布到 npm(维护者)

npm login
npm run typecheck
npm run build
npm run pack:check
npm publish --access public