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 🙏

© 2026 – Pkg Stats / Ryan Hefner

task-queue-service

v0.0.1

Published

standalone service component Which executes a task with bundle requests from a queue,dynamically quicken the procedure by queue state(waiting time and amount) and history state,lower average request waiting time.

Downloads

3

Readme

#TASK-QUEUE-SERVICE

Standalone Service Component Which executes a task with bundle requests from a queue, Dynamically quicken the procedure by queue state(waiting time and amount) and history state, Lower average request waiting time.


#Usage

You can overwrite fucntion executeBatch or execute to write your own task handling code, The former provides a bunch of tasks while the latter providing a single one,however you must end each task with either a tqs.endTask or a tqs.interruptTask API.

##server

    var async = require('async');
    var server = require('task-queue-service').server;
    var tqs = new server.TaskQueueService();
    
    //the max amount of tasks execute at a time.
    tqs.setTaskPoolMax(5);
    //Wait before next handling process until pool is full or time is up.account in millisecond
    tqs.setWaitingTime(5000); 
    
    tqs.executeBatch = function(taskList){
        //Write your own flow control code like async,here simulates a random task by `setTimeout`
        async.forEachOf(taskList, function(task, i, callback){
            //模拟单个任务的耗时操作
            setTimeout(function(){
                //单个任务有一定几率出错
                //Simulate an error
                // if(Math.random()>0.7){
                //     tqs.interruptTask(task,'Single Task Error!');
                // }else{
                //     tqs.endTask(task,"success");
                // }
                tqs.endTask(task,"success");
                callback();
            },task['finishTime']);
            },function(err){}
        );
    };
    //works at port:3001
    tqs.run(3001);

##client

    var client = require('task-queue-service').client;
    var path = require('path');
    
    client
        .setListenPort(3001)
        //if set ServerPath it will try to launch a server set here and reconnect.
        .setServerPath(path.join(__dirname,"server/batch.js"));
    
    var taskId = 0;
    function test(done){
        setTimeout(function(){
            taskId++;
            //Any user defined object can be taken as a task
            var task = {
                name:"task"+taskId,
                finishTime:Math.floor(Math.random()*1000)
            };
            client.informNewTask(task,function(res){
                if("error" in res){
                    console.log(task.name,res['error']);
                }else{
                    console.log(task.name,"Done!");
                }
            });
            //测试10个项目
            if(taskId<=10){
               test(done);
            }else{
               done();
            }
        },1000);
    }
    
    test(function(){
        console.log("Ten tasks Done!");
    })