export function debounce(func: Function, delay: number): Function {
  let timer: any;
  return function () {
    if (timer) {
      clearTimeout(timer);
    }
    timer = setTimeout(()=> {
      func();
    }, delay);
  };
}


export function throttle(func: Function, delay: number): Function {
  let lastTime = 0;
  return () => {
    const currentTime = new Date().getTime();
    if (currentTime - lastTime > delay) {
      lastTime = currentTime;
      func();
    }
  };
}