Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qquanwei/js-downloader
Javascript downloader
https://github.com/qquanwei/js-downloader
Last synced: 14 days ago
JSON representation
Javascript downloader
- Host: GitHub
- URL: https://github.com/qquanwei/js-downloader
- Owner: Qquanwei
- Created: 2016-08-26T08:30:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-09T02:35:54.000Z (about 8 years ago)
- Last Synced: 2024-12-09T07:55:36.340Z (18 days ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#JS-DOWNLOADER
Features:
* download
* pause
* resume
* progress## Install
* npm install js-downloader --save
## Usage
```
"use strict"
let fs = require('fs');
let download = require('js-downloader');/*
* defaultoption ={
* resume: true, // resume switch
* output:{
* path: '/tmp',
* filename: $urlfilename,
* },
* headers:{}
* }
* */download('http://localhost:8000/setup.exe',{}).then(function(req){
/*
* req = {
* request,
* stream, //download fullpath,will be write'
* }
* */let stream = req.stream;
req.request
.on('end',()=>console.log('done'))
.on('error',console.log)
.on('progress',console.log)
.on('abort',()=>console.log('abort'))
.pipe(stream);setTimeout(function(){
req.request.abort(); // will be abort
},10000);}).catch(function(e){
if(e.message === 'file is done'){
//ignore , local file is already download
}else
console.log(e);
});
```