@luzhongk/node-get

1.1.9 • Public • Published

@luzhongk/node-get

nodejs 实现批量下载文件,支持并发下载/手动停止下载/返回 Promise

Usage

const download = require('@luzhongk/node-get')

const data = [
  {
    src: 'https://img1.halobear.com/pano/f79085cd610fc4ee1d8c8eee13d73b3b.zip',
    // dir: '',
    // dest: '',
  },
]

start()

async function start() {
  const options = {
    // 下载文件数组
    data,
    // 并发下载数量
    concurrentNum: 3,
    // 允许错误数量
    errorLimit: 1,
    // 下载进度
    onprogress(e, total) {
      console.log('剩余任务数量', total)
      e && console.log(e)
    },
  }

  await download(options)
  console.log('下载成功')
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.92latest

Version History

VersionDownloads (Last 7 Days)Published
1.1.92
1.1.80
1.1.70
1.1.60
1.1.50
1.1.40
1.1.30

Package Sidebar

Install

npm i @luzhongk/node-get

Weekly Downloads

0

Version

1.1.9

License

ISC

Unpacked Size

6.13 kB

Total Files

6

Last publish

Collaborators

  • luzhongk