All files debounce.js

71.42% Statements 10/14
33.33% Branches 2/6
75% Functions 3/4
81.81% Lines 9/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19    2x 1x 1x       1x 1x 1x 1x         1x 1x  
export function debounce(func, wait, immediate) {
    let timeout;
    return function () {
        const context = this, args = arguments;
        const later = function () {
            timeout = null;
            if (!immediate) func.apply(context, args);
        };
        const callNow = immediate && !timeout;
        clearTimeout(timeout);
        timeout = setTimeout(later, wait);
        Iif (callNow) func.apply(context, args);
    };
}
 
export function dispatchChange(element) {
    const changeEv = new Event("change", {"bubbles": false, "cancelable": true});
    element.dispatchEvent(changeEv);
}