@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
21 lines • 604 B
JavaScript
"use client";
// https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/debounce.js
export default function debounce(func, wait = 166, leading = false) {
let timeout;
function debounced(...args) {
const later = () => {
timeout = undefined;
func.apply(this, args);
};
if (!timeout && leading) {
later();
}
clearTimeout(timeout);
timeout = setTimeout(later, wait);
}
debounced.clear = () => {
clearTimeout(timeout);
};
return debounced;
}
//# sourceMappingURL=debounce.js.map