# @tybys/downloader

> Tiny downloader in Node.js

Latest version **0.2.0** (published 2021-05-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tybys/downloader
pnpm add @tybys/downloader
yarn add @tybys/downloader
bun add @tybys/downloader
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2021-05-31 |
| First published | 2021-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 105.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | toyobayashi |
| Maintainers | toyobayashi |

## Links

- npm: https://www.npmjs.com/package/@tybys/downloader
- Repository: https://github.com/toyobayashi/downloader
- Homepage: https://github.com/toyobayashi/downloader#readme
- Issues: https://github.com/toyobayashi/downloader/issues
- npm.io page: https://npm.io/package/@tybys/downloader

## Dependencies (4)

- [got](https://npm.io/package/got.md) ^11.8.2
- [tslib](https://npm.io/package/tslib.md) 2.2.0
- [@tybys/oid](https://npm.io/package/@tybys/oid.md) ^3.0.0
- [proxy-agent](https://npm.io/package/proxy-agent.md) ^4.0.1

## Recent versions

- 0.2.0 (latest) — 2021-05-31
- 0.1.2 — 2021-04-23
- 0.1.1 — 2021-04-23
- 0.1.0 — 2021-04-23

## README

# downloader

Tiny downloader in Node.js

[API Documentation](https://github.com/toyobayashi/downloader/blob/main/docs/api/index.md)

## Usage

```bash
npm install @tybys/downloader
```

```js
const { Downloader, DownloadOverwrite } = require('@tybys/downloader')

const downloader = new Downloader()
downloader.settings.maxConcurrentDownloads = 1
downloader.settings.overwrite = DownloadOverwrite.RENAME

const electron1204 = downloader.add('https://npm.taobao.org/mirrors/electron/12.0.4/electron-v12.0.4-win32-x64.zip', {
  dir: __dirname,
  out: 'electron-v12.0.4-win32-x64.zip'
})
const electron1203 = downloader.add('https://npm.taobao.org/mirrors/electron/12.0.3/electron-v12.0.3-win32-x64.zip', {
  dir: __dirname,
  out: 'electron-v12.0.3-win32-x64.zip'
})

const onProgress = (downloadProgress) => {
  if (process.stdout.clearLine) {
    process.stdout.clearLine(0)
    process.stdout.cursorTo(0)
    process.stdout.write(`percent: ${downloadProgress.percent}, speed: ${downloadProgress.downloadSpeed / 1000} KB/s`)
  }
}

electron1204.on('progress', onProgress)
electron1203.on('progress', onProgress)

electron1204.on('fail', () => {
  console.log(electron1204.error)
})

electron1204.whenStopped().then(() => {
  console.log('whenStopped ' + electron1204.gid)
}).catch(err => {
  console.log(err.message)
})

electron1203.whenStopped().then(() => {
  console.log('whenStopped ' + electron1203.gid)
}).catch(err => {
  console.log(err.message)
})

setTimeout(() => {
  electron1204.abort()
}, 2000)
```

---
_Source: https://npm.io/package/@tybys/downloader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
