代码拉取完成,页面将自动刷新
网址: https://gitee.com/linuxmail/node-async-funnel
npm i async-funnel
一个一个的执行: 支持Promise的函数
并行个数可配置
const funnel = require("async-funnel").asyncFunnel
let funnel = new asyncFunnel.asyncFunnel({ parallel: 2 })
let funnel = new asyncFunnel.asyncFunnel() // parallel == 1
await funnel.run(async () => {
await do_sth()
})
// const funnel = require("async-funnel").asyncFunnel
const asyncFunnel = require("../src/")
async function do_job(funnel, sn) {
console.log("函数开始执行: ", sn)
await funnel.run(async () => {
await asyncFunnel.sleep(1000)
console.log(sn, (new Date()))
})
}
function test(parallel) {
let funnel = new asyncFunnel.asyncFunnel({ parallel: parallel })
// if (parallel == 1) {
// let funnel = asyncFunnel()
// }
for (i = 0; i < 100; i++) {
do_job(funnel, i)
}
}
test(2)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。