@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
24 lines • 694 B
JavaScript
;
"use client";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = debounce;
// https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/debounce.js
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