debounce
function Debounce(wait: number, immediate: boolean = false) { return function (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) { let timeout: any; const originalMethod = descriptor.value; descriptor.value = function (...args: any[]) { let context = this; let later = function () { timeout = null; if (!immediate) { originalMethod.apply(context, args) } } let callNow = immediate && !timeout; clearTimeout(timeout) timeout = setTimeout(later, wait); if (callNow) { originalMethod.apply(context, args) } } return descriptor; } } class MouseObj { @Debounce(1000) public print() { console.log(1) } } (window as any)["MouseObj"] = MouseObj