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 🙏

© 2025 – Pkg Stats / Ryan Hefner

upload-calc

v1.0.3

Published

上传文件 图片 图片预览 多文件 文件夹等。接收多参数,多种计算回调,**不提供UI显示**,需要您根据回调自行发挥。

Downloads

11

Readme

upload-calc

上传单文件、多文件、文件夹(图片/图片预览),接收多参数,多种计算回调。

功能

- 拖拽上传
- 点击上传
- 自动上传
  - 上传拦截
- 文件个数
  * 单文件
  * 多文件
- 文件夹
- 过滤
  - 上传个数
  - size
  - 格式
  - 自定义过滤
- 额外参数
- 任务队列状态监听
- 上传进度监听
- 失败队列监听
- 图片预览

安装

npm i upload-calc

使用案例

import upload from 'upload-calc'

const upd = new upload('upd', 'http://xxx/api/file_upload/', {
  data: {
    task_number: 'task_1676530245'
  },
  dragAble: true,
  dragWrapperId: 'dg'
}, {
  failMessageList (list) {
    console.log(list)
  },
  onProgress (progress) {
    console.log(progress)
  },
  beforeDrag () {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve(0)
      }, 1000);
    })
  }
})
<div id="dg" style="width: 500px; height: 500px; background-color: #999;">
  <form>
    <input
      id="upd"
      hidden
      type="file"
      multiple
      @change="upd.change"
      />
    <el-button @click="upd.click()">选择文件</el-button>
    <el-button @click="upd.syncSubmit()">同步上传</el-button>
  </form>
</div>

**注意:**调用upd函数必须加(), 如上面upd.click() upd.syncSubmit()

使用说明

new upload(inputId, apiUrl, options{}, callback{})

options{}

参数|说明|类型|默认值|可选值 :---|:---|:---|:---|:--- data| 携带参数 | Object | {} | - limit| 限制个数 | Number | - | - size| 单文件限制大小 /byte | Number | - | - autoUpload| 是否自动上传 | Boolean | false | true dragAble| 拖拽上传 | Boolean | false | true dragWrapperId | 拽到的容器id | String | - | -

callback{}

参数|说明|类型|参数格式 :---|:---|:---|:--- filter| 自定义过滤函数 | Function(fileList, originFilterFailList) | - failMessageList|过滤不能通过的列表|function(failList)|[{file_name: '', message: ''}] onSwitch|上传队列任务的开始/结束|function(Boolean)| true:开始,false:结束 onTotal| 总量 | function(num) | - onImgPreview| 上传文件中有图片,则返回图片给预览 |function(img)|- onSuccess|单个文件上传结束|function(response, fileName)|(ajax_body, '文件名') onCount| 剩余总量 | function(num) | - onProgress|单个文件上传进度|function(progressNumber, fileName)|(0~100, '文件名') onAccessLimitNum|上传文件个数超过限制,并阻止上传|function(Boolean)| false beforeDrag| 拖拽上传前拦截 | Function(updCallback) | -

Events

事件名 | 说明 :---|:--- click|input点击事件 change|input文件变化事件 submit|异步提交文件 syncSubmit|同步提交文件