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

@aardiolib/tasks

v1.0.1

Published

任务序列

Downloads

12

Readme

tasks

可中断和恢复的任务序列,任务序列应该为 promise 数组,依次顺序执行一系列任务,所有任务全部完成后可得到执行结果

安装

npm

下载扩展库

npm i @aardiolib/tasks

复制扩展库到用户库

robocopy .\node_modules\@aardiolib\ .\lib\ /E

示例

简单示例

import console;
import win.ui;
import promise;
import tasks;
/*DSG{{*/
var winform = win.form(text="tasks";right=300;bottom=124)
winform.add(
button={cls="button";text="开始";left=16;top=30;right=125;bottom=87;z=1};
button2={cls="button";text="暂停";left=167;top=30;right=276;bottom=87;z=2}
)
/*}}*/

var taskList = {};

for(i=1;5;1){
	table.push(taskList,function(){
		return ..promise(function(resolve,reject){
			..console.log(i,"执行中")
		    winform.setTimeout(function(){
		        ..console.log(i,"执行完成")
		    	resolve(i)
		    },2000)
		})
		
	})
}

var processor = tasks(taskList);

winform.button.oncommand = function(id,event){
	console.log("点击开始")
	winform.button.disabled = true;
	
	processor.start().then(function(results){
		console.log("执行结果:");
		console.dumpJson(results);
		winform.button.disabled = false;
	},function(err){
		console.log("执行被中断");
		console.log(err);
	})
}

winform.button2.oncommand = function(id,event){
	console.log("点击暂停")
	winform.button2.disabled = true;
	processor.pause().then(function(){
		console.log("已暂停")
		winform.button.disabled = false;
		winform.button2.disabled = false;
	});
}

winform.show();

win.loopMessage();