/**
 * 防抖
 * @param wait 等待时间 单位秒
 */
export default function Debounce(wait: number) {
	return function (target: any, keyname: string, descriptor: PropertyDescriptor) {
		const method: Function = descriptor.value;
		let timer: number = null;
		descriptor.value = function (...args: any[]) {
			if (timer) {
				clearInterval(timer);
				timer = null;
			}
			timer = setTimeout(() => {
				clearInterval(timer);
				timer = null;
				method.apply(this, args);
			}, wait * 1000);
		};
	};
}
