ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

16 lines
395 B

  1. export function Debounce (config: { timeoutMS: number }) {
  2. let timeoutRef: NodeJS.Timeout
  3. return function (_target, _key, descriptor: PropertyDescriptor) {
  4. const original = descriptor.value
  5. descriptor.value = function (...args: any[]) {
  6. clearTimeout(timeoutRef)
  7. timeoutRef = setTimeout(() => {
  8. original.apply(this, args)
  9. }, config.timeoutMS)
  10. }
  11. }
  12. }