js-asynctask
v0.1.1
Published
js async task library
Downloads
1
Readme
js-asynctask
js中 执行异步任务
安装
npm i js-asynctask --save
使用
const asyncTask = require('js-asynctask');
const middleWares = [];
middleWares.push(async function (context, next) {
console.log('task-1');
context.count++;
await next();
});
middleWares.push(async function (context, next) {
console.log('task-2');
context.count++;
await next();
});
middleWares.push(async function (context, next) {
console.log('task-3');
context.count++;
await next();
});
const context = {
count: 0,
};
asyncTask(middleWares, context).then(() => {
console.log('finished', context.count);
});