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

task-list-runner

v1.2.1

Published

駐列任務處理器

Downloads

4

Readme

task-list-runner

駐列任務處理器

install

npm install task-list-runner

使用說明

var TaskListRunner = require('task-list-runner');
var tasklist = new TaskListRunner();

//定義完成一個task的callback,並回傳這個task的data
tasklist.endAnTask = function(data) {
    console.log('完成一個task!!', data);
}

//定義完成所有task的callback
tasklist.endCall = function() {
    console.log('駐列所有工作完成!!');
}

//任務1
var task1 = {
    data: { //要傳入的參數可以放這裡
        name: 'task1'
    },
    task: function() {
        var that = this;
        console.log('start run ' + that.data.name);
        setTimeout(function() {
            console.log('start end ' + that.data.name);
            that.tasker.endAndNext(); //事件完成後請呼叫 this.tasker.endAndNext();
        }, 500);
    }
}

//任務2
var task2 = {
    data: {
        name: 'task2'
    },
    task: function() {
        var that = this;
        console.log('start run ' + that.data.name);
        setTimeout(function() {
            console.log('start end ' + that.data.name);
            that.tasker.endAndNext();
        }, 500);
    }
}

//任務1放入駐列
tasklist.push(task1);

// 200毫秒後,任務2放入駐列
setTimeout(function() {
    tasklist.push(task2);
}, 200);

以上例子,tasklist物件會幫你依序執行task1與task2中的task方法

宣告任務處理器

var tasklist = require('task-list-runner');

你必須覆寫定義完成一個task的callback,並回傳這個他會傳回這個task中的data物件

tasklist.endAnTask

你必須覆寫定義完成所有任務時呼叫的callback

tasklist.endCall

task版型

var task1 = {
    data: { //要傳入的參數可以放這裡
        name: 'task1'
    },
    task: function() {
        var that = this;
        console.log('start run ' + that.data.name);
        setTimeout(function() {
            console.log('start end ' + that.data.name);
            that.tasker.endAndNext(); //事件完成後請呼叫             this.tasker.endAndNext();
        }, 500);
    }
}

task1.data 需要利用的數據可以放這裡 task1.task 這是一個函示,會依照駐列任務執行 task1.tasker.endAndNext 任務完成後不管成功或失敗,你利用這個方法告訴任務處理器,task1.tasker 即為任務處理器本身,task1.tasker.endAndNext()同等於 tasklist.endAndNext()

你可以利用下面方法來清空你的駐列,執行後駐列將不會繼續下一個任務

tasklist.stop()