MCPcopy Create free account
hub / github.com/course-dasheng/fe-algorithm / start

Function start

interview/limit.js:55–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

53}
54
55async function start(){
56 let runner = limit(2) //并发量是3
57 let tasks = [
58 ()=> sleep(1,'吃饭'),
59 ()=> sleep(3,'睡觉'),
60 ()=> sleep(5,'打游戏'),
61 ()=> sleep(3.5,'学习算法'),
62 ()=> sleep(4,'学习Vue和React'),
63 ].map(runner)
64 let result = await Promise.all(tasks)
65 console.log(result,'end')
66}
67// @think 如果任务有优先级呢
68start()

Callers 1

limit.jsFile · 0.70

Calls 2

limitFunction · 0.85
sleepFunction · 0.70

Tested by

no test coverage detected