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

repeat-down

v1.0.1

Published

downloading files and try again some times in a bad network environment.

Downloads

7

Readme

repeat-down

multi-tasking download files and support continue transferring from breakpoint repeattly.

npm install repeat-down

##example

    var path = require('path');
    var RepeatDown = require('repeat-down');
    
    //{maxRun} max tasks in running, {repeatNum} the auto repeat times internally  if a task failed .
    //{timeout} the connection timeout.
    var downloader = new RepeatDown({maxRun: 6, timeout: 5000, repeatNum: 4});
    
    downloader.get({
        url:'http://download.sublimetext.com/Sublime%20Text%20Build%203103%20x64%20Setup.exe',
        dest:path.join(__dirname, 'temp', 'test.zip')
    }).get({
        url:'http://download.sublimetext.com/Sublime%20Text%20Build%203103%20x64%20Setup.exe',
        dest:path.join(__dirname, 'temp', 'test2.zip')
    }).run(function(percent,task){//percent callback {percent: 0-100}
    
        console.log('file:'+task.dest+' : '+percent);
        
    },function(err,task){//single task callback ,maybe completed or have a error.
    
        if(err){
            console.log('download err :'+task.url);
        }else{
            console.log('download complete :'+task.url);
        }
        
    },function(errtasks){//all tasks callback,errtasks are array of err task,
    
        if(errtasks.length > 1){
            console.log('failed tasks :'+errtasks.length);

            //you can call this to continue run the errtasks.
            //downloader.restartErrTasks(errtasks);
        }else{
            console.log('all complete.');
        }
        
    });

#methods

###RepeatDown(option)

    var RepeatDown = require('repeat-down');
    var downloader = new RepeatDown({maxRun: 6, timeout: 5000, repeatNum: 4});

create a downloader. option a obj with some propertys.

timeout [number] the connection timeout ,default 5000(milliscond). maxRun [number] the max running tasks ,default 5. repeatNum [number] max auto repeat times if a task failed ,default 10. delayTime [number] a increasing time for every repeat ,default 500(milliscond).

###.get(option)

downloader.get({
        url:'http://download.sublimetext.com/Sublime%20Text%20Build%203103%20x64%20Setup.exe',
        dest:path.join(__dirname, 'temp', 'test.zip')
    })

add tasks. option is a obj|array. propertys below.

url [string] the quest url of a file. dest [string] the filepath.

###.run(processCallback,doneCallback,doneAllCallback)

    downloader.run(processCallback(percent, task),doneCallback(err, task),doneAllCallback(errtasks));

run the tasks.

processCallback the process callback. percent a percent for every task in range 0 - 100. task is a obj. doneCallback the callback for every task when complete or failed. doneAllCallback the global callback. errtasks is a array of failed tasks. optionly you cal call downloader.restartErrTasks(errtasks) to continue the failed tasks.

###.restartErrTasks(errtasks)

restart the failed tasks. if need you can call many times until all tasks complete.

###Task

task has some propertys below:

start [number] the start point(byte) in download stream for breakpoint resume. timeout [number] connection timeout. url [string] quest url. dest [string]filepath. curChunk [obj] a chunk obj. _isBreak [boolean] whether if surpport breakpoint resume for the task. process [number]a percent of the process. reclen [number] current received length. start+reclen is the total received length. totalLen [number] the total lenght of the file will be received.