export function throttle(f, wait = 200, options = {}) {
    const opts = Object.assign({ ensureLast: false }, options);
    let throttled = false;
    let context = null;
    let args = [];
    return function () {
        context = this;
        args = arguments;
        if (throttled)
            return;
        f.apply(context, args);
        throttled = true;
        setTimeout(() => {
            throttled = false;
            if (opts.ensureLast)
                f.apply(context, args);
        }, wait);
    };
}
