MCPcopy
hub / github.com/xpf0000/FlyEnv / _handle

Method _handle

src/shared/TaskQueue.ts:34–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32 }
33
34 private _handle() {
35 if (this.runQueue.length < this.runSize && this.queue.length > 0) {
36 const task = this.queue.shift()!
37 this.runQueue.push(task)
38 const next = () => {
39 this.progressFn?.(this._progress)
40 this.runQueue.splice(this.runQueue.indexOf(task), 1)
41 this._handle()
42 }
43 task
44 .run()
45 .then((res) => {
46 this._progress.finish += 1
47 if (res) {
48 this._progress.success += 1
49 this._progress.successTask.push(task)
50 }
51 next()
52 })
53 .catch((err) => {
54 console.log('task catch: ', err)
55 this._progress.finish += 1
56 this._progress.fail += 1
57 task.msg = err.toString()
58 this._progress.failTask.push(task)
59 next()
60 })
61 }
62 if (this.queue.length === 0 && this.runQueue.length === 0) {
63 this.endFn?.()
64 }
65 }
66
67 initQueue(queue: Array<TaskItem>) {
68 this.queue = queue

Callers 2

nextMethod · 0.95
runMethod · 0.95

Calls 7

nextFunction · 0.85
pushMethod · 0.80
catchMethod · 0.80
thenMethod · 0.45
runMethod · 0.45
logMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected