MCPcopy
hub / github.com/TanStack/router / tick

Method tick

packages/start-plugin-core/src/queue.ts:33–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31 }
32
33 private tick() {
34 if (!this.running) {
35 return
36 }
37 while (
38 this.active.length < this.currentConcurrency &&
39 this.pending.length
40 ) {
41 const nextFn = this.pending.shift()
42 if (!nextFn) {
43 throw new Error('Found task that is not a function')
44 }
45 this.active.push(nextFn)
46 ;(async () => {
47 let success = false
48 let res!: T
49 let error: any
50 try {
51 res = await nextFn()
52 success = true
53 } catch (e) {
54 error = e
55 }
56 this.active = this.active.filter((d) => d !== nextFn)
57 if (success) {
58 this.onSuccesses.forEach((d) => d(res, nextFn))
59 } else {
60 this.onErrors.forEach((d) => d(error, nextFn))
61 }
62 this.onSettles.forEach((d) => d(res, error))
63 this.tick()
64 })()
65 }
66 }
67
68 add(fn: () => Promise<T> | T, { priority }: { priority?: boolean } = {}) {
69 return new Promise<any>((resolve, reject) => {

Callers 8

addMethod · 0.95
startMethod · 0.95
speed.flame.tsFile · 0.80
speed.bench.tsFile · 0.80
speed.flame.tsFile · 0.80
speed.bench.tsFile · 0.80
speed.flame.tsFile · 0.80
speed.bench.tsFile · 0.80

Calls 2

dFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected