MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / tick

Method tick

cli/src/utils/chat-scroll-accel.ts:120–137  ·  view source on GitHub ↗

Calculates the average number of scroll events

(now = Date.now())

Source from the content-addressed store, hash-verified

118
119 /** Calculates the average number of scroll events */
120 tick(now = Date.now()): number {
121 this.tickHistory.enqueue(now)
122
123 let oldestTick = this.tickHistory.peek() ?? now
124 while (oldestTick < now - this.rollingWindowMs) {
125 this.tickHistory.dequeue()
126 oldestTick = this.tickHistory.peek() ?? now
127 }
128
129 this.buffer += clamp(
130 this.tickHistory.length * this.multiplier,
131 -this.maxRows,
132 this.maxRows,
133 )
134 const rows = Math.floor(this.buffer)
135 this.buffer -= rows
136 return rows
137 }
138
139 reset(): void {
140 this.tickHistory.clear()

Callers

nothing calls this directly

Calls 4

clampFunction · 0.90
enqueueMethod · 0.80
peekMethod · 0.80
dequeueMethod · 0.80

Tested by

no test coverage detected