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 🙏

© 2024 – Pkg Stats / Ryan Hefner

easeupload

v1.0.22

Published

- 使用 npm 安装

Downloads

26

Readme

📄 easeupload

快速开始

1. 安装

  • 使用 npm 安装
npm install easeupload
  • 使用 yarn 安装
yarn add easeupload
  • 使用 pnpm 安装
pnpm add easeupload

2. 使用 easeupload 上传文件切片

import Upload from 'easeupload'
const { show, addListener, start } = Upload({
  fileType: ['.zip'], // 文件类型
  chunkSize: 3, // 分片的大小
  concurrent: 1 // 并发请求数
})

addListener('progress', num => {
  // TODO
})

addListener('changeFinish', ({ file, fileSize, resolve }) => {
  const controller = new AbortController()

  resolve<[]>(chunks =>
    chunks.map(
      chunk => () =>
        uploadSystemInfoApi(
          {
            file: new File([chunk.file], file.name),
            dzuuid: chunk.id,
            dzchunkindex: chunk.index,
            dztotalfilesize: chunk.allSize,
            dzchunksize: chunk.size,
            dztotalchunkcount: chunk.chunksNum,
            dzchunkbyteoffset: chunk.offset
          },
          controller.signal
        )
    )
  )
})

🔥🔥🔥 特点

  1. 简单
  2. 自由
  3. 轻量
  4. 类型提示良好

API文档

默认导出

upload函数,返回 show、 addListener、start 函数

  1. Upload 参数

| 参数名 | 类型 | 必传 | 说明 | | ------ | ------------------------------------------------------------ | ---- | --------------------------------------------------------------------------------------------- | | config | { fileType: string[]; chunkSize: number;concurrent: number;} | true | fileType: 可选择文件类型的数组chunkSize: 分片的大小(MB)concurrent:并发上传数 |

  1. 返回值

| 返回值 | 类型 | 说明 | | ----------- | --------------------------------------------------------------------- | ---------------------- | | show | () => void | 调用显示选择文件的弹窗 | | addListener | (eventName: 'progress' | 'change'| 'changeFinish',handleFn) | 增加监听 | | start | () => void | 开始上传 | | cancel | () => void | 取消上传 |

addListener

可监听事件

  1. progress

| 事件名 | 参数类型 | 说明 | | -------- | -------- | ------------------------------------------- | | progress | number | 上传的进度(已经上传完成的切片 / 总切片数) |

  1. change

| 事件名 | 参数 | 说明 | | ------ | --------- | -------------- | | change | undefined | 选择文件后触发 |

  1. changeFinish

| 事件名 | 参数 | 说明 | | ------------ | ---------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------- | | changeFinish | ({ file: File, fileSize: string, resolve: (createTaskList: (chunks: Chunk[]) => Task[]) => void }) | 在文件的hash值和切片的hash计算完毕后触发,必须增加此监听,调用resolve函数,自定义切片上传的请求字段名,使用封装axios,拦截器依旧生效 |