export const debounce = (fn, wait = 88) => {
    let callback = fn;
    let timerId = null;

    function debounced() {
        // 保存作用域
        // @ts-ignore
        let context = this;
        // 保存参数，例如 event 对象
        let args = arguments;

        // @ts-ignore
        clearTimeout(timerId);
        // @ts-ignore
        timerId = setTimeout(function () {
            callback.apply(context, args);
        }, wait);
    }

    // 返回一个闭包
    return debounced;
}