MCPcopy Create free account
hub / github.com/xerrors/Yuxi / getDynamicReserve

Function getDynamicReserve

web/src/composables/useStreamSmoother.js:176–192  ·  view source on GitHub ↗
(controller, options, now)

Source from the content-addressed store, hash-verified

174}
175
176const getDynamicReserve = (controller, options, now) => {
177 const reserveSize = getReserveSize(controller, options)
178 const elapsedSincePush = Math.max(0, now - controller.lastPushAt)
179 const releaseDelay = Math.max(0, options.reserveReleaseDelayMs)
180
181 if (elapsedSincePush <= releaseDelay) {
182 return reserveSize
183 }
184
185 const decayProgress = clamp(
186 (elapsedSincePush - releaseDelay) / Math.max(1, options.reserveDecayWindowMs),
187 0,
188 1
189 )
190
191 return Math.ceil(reserveSize * (1 - decayProgress))
192}
193
194const getChunkSize = (controller, pending, options) => {
195 const now = Date.now()

Callers 1

getChunkSizeFunction · 0.85

Calls 2

getReserveSizeFunction · 0.85
clampFunction · 0.85

Tested by

no test coverage detected