@geneui/components
Version:
The Gene UI components library designed for BI tools
18 lines (16 loc) • 448 B
JavaScript
function debounce(callback, wait, immediate) {
let timeout;
return function func() {
const context = this;
const args = arguments;
const later = function () {
timeout = null;
if (!immediate) callback.apply(context, args);
};
const callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) callback.apply(context, args);
};
}
export { debounce as d };