UNPKG

@dfinity/gix-components

Version:
14 lines (13 loc) 454 B
// TODO: copied from NNS-dapp and needs to be moved to utils /* eslint-disable-next-line @typescript-eslint/ban-types */ import { nonNullish } from "@dfinity/utils"; export const debounce = (func, timeout) => { let timer; return (...args) => { const next = () => func(...args); if (timer) { clearTimeout(timer); } timer = setTimeout(next, nonNullish(timeout) && timeout > 0 ? timeout : 300); }; };