1
0
Fork 0
peertube/server/helpers/debounce.ts
Chocobozzz 0c9668f779 Implement remote runner jobs in server
Move ffmpeg functions to @shared
2023-05-09 08:57:34 +02:00

16 lines
396 B
TypeScript

export function Debounce (config: { timeoutMS: number }) {
let timeoutRef: NodeJS.Timeout
return function (_target, _key, descriptor: PropertyDescriptor) {
const original = descriptor.value
descriptor.value = function (...args: any[]) {
clearTimeout(timeoutRef)
timeoutRef = setTimeout(() => {
original.apply(this, args)
}, config.timeoutMS)
}
}
}