# 防抖

防抖函数,经典的用于搜索框实时搜索,提高性能。

使用
import { debounce } from 'util-snippets'

deepClone(fn(),time)
代码
const throttle = (fn, interval = 300) => {
  let canRun = true;
  return () => {
    if (!canRun) {
      return;
    }
    canRun = false;
    setTimeout(() => {
      fn.apply();
      canRun = true;
    }, interval);
  };
};