JSFiddle - React, Tailwind, and code Playground

by Antério Vieira

Babel + JSX

var debounce = (func, wait, options) => {

    var timeout;

    return () => {
        var args = arguments;

        var delayed = () => {
            // 
            if (!options.leadingEdge) func.apply(func, args);

            timeout = null;
        }

        if (timeout) {
            clearTimeout(timeout);
        } else if (options.leadingEge) {
            func.apply(func, args);
        }

        timeout = setTimeout(delayed, wait);
    }

}

document.onmousemove = debounce((e) => console.log(e))

/*

document.onmousemove(event, target, element)

-> return of debounce is a function 
document.onmousemove = (event) => {}


























*/