easydownload
easydownload is a library that helps us:
- Download multiple files
- Get the download's speed
- Parallel downloading
Usage
Single file
const Download = const download = 'some url' 'some local path'download downloadstart
Multiple file
const DownloadManager = const manager = // Putting the number of file to download simultaneouslymanagersimultaneousDownloads = 5 // DEFAULT: 1 managermanagermanager managermanager managerstart
API
DownloadManager
new DownloadManager()
Create the manager
DownloadManager#start()
Starts the download
DownloadManager#pause()
Pauses the download to get resumed
Download#resume()
Resumes the download
DownloadManager#addToQueue(url, localPath)
Add a download to the queue
DownloadManager#simultaneousDownloads
Number of file to download at once
Event: 'start'
Event: 'finish'
Event: 'download_start'
Download
- A Download instance
Event: 'download_finish'
Download
- A Download instance
Event: 'download_retry'
Download
- A Download instance
Event: 'download_file_check'
Download
- A Download instance
Event: 'download_error'
Error
- A Download instanceDownload
- A Download instance
Event: 'speed'
Number
- Speed at which streams in the group are being read.Number
- Average speed.
Download
new Download(url, localPath)
Represents a download
Download#start()
Starts the download
Download#pause()
Pauses the download to get resumed
Download#resume()
Resumes the download
Download#stop()
Stops the download, but keeps the file
Download#destroy()
Destroys the download, and removes the file
Event: 'start'
stream.Readable
- The received download stream
Event: 'data'
Buffer
- chunk
Event: 'state_change'
Download.STATES: Number
- The current state
Event: 'pause'
Event: 'resume'
Event: 'stop'
Event: 'destroy'
Event: 'retry'
Event: 'file_check'
Event: 'finish'
Event: 'error'
Error
- the error