mirror of
https://github.com/jlfwong/speedscope.git
synced 2024-11-23 06:22:41 +03:00
13 lines
319 B
TypeScript
13 lines
319 B
TypeScript
export function atMostOnceAFrame<F extends Function>(fn: F) {
|
|
let frameRequest: number | null = null
|
|
function ret(...args: any[]) {
|
|
if (frameRequest == null) {
|
|
frameRequest = requestAnimationFrame(function () {
|
|
fn(...args)
|
|
frameRequest = null
|
|
})
|
|
}
|
|
}
|
|
return ret as any as F
|
|
}
|