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

impeldown

v0.1.9

Published

前端 JavaScript 下载插件

Downloads

15

Readme

impeldown是什么?

一个浏览器端下载插件,可以监听下载进度,没有依赖任何第三方框架,压缩后大小仅4kb,小巧方便,使用灵活

演示地址

使用注意

  • 受到浏览器同源策略的限制,impeldown无法下载跨域资源,只能下载本域资源或者服务端开启CORS
  • 服务端返回的Response Headers必须包含Content-Length,否则无法监听到下载进度,但是可以正常下载

安装

npm 的方式
npm install impeldown --save
或
cnpm insatll impeldown --save

支持CDN引入
git地址:https://github.com/cttaohua/impeldown
引入dist文件夹下的impeldown.min.js
<script src="./dist/impeldown.js"></script>

使用

  • 在js中添加
import impeldown from 'impeldown'
  • 可以简单的传入一个链接
new impeldown('https://taohuayuanskill.com/uploadImg/cover/97526.png') // 示例下载url
  • 或者选择传入一个对象来监听下载进度
new impeldown({
  url: 'https://taohuayuanskill.com/uploadImg/cover/97526.png',  // 必填项
  name: '下载.png', // 非必填项
  onStart: function() {  // 开始下载
    console.log('开始下载啦')
  },
  onProgress: function(p) {  // 监听进度
    console.log('现在下载了'+p)
  },
  onAbort: function() {  // 被用户中止下载
    console.log('您取消了下载')
  },
  onError: function() {   // 传输中出现错误
    console.log('出错了')
  },
  onSuccess: function() {  // 下载成功
    console.log('下载成功')
  },
  onComplete: function() {  // 下载结束(成功失败都会调用)
    console.log('下载结束啦')
  }
})
  • 可以调用abort方法来中止下载
const download = new impeldown('https://taohuayuanskill.com/uploadImg/cover/97526.png')
setTimeout(() => {
  download.abort() // 2s之后中止下载
}, 1000)

注意事项

如果没有定义name的话,impeldown会自动默认下载的文件名为静态资源的文件名,但是如果下载路径不是静态资源,而是动态生成的文件的话,impeldown会设置文件名为8位的随机字符串加文件后缀名。