@kiwicom/smart-faq
Version:
14 lines (12 loc) • 399 B
JavaScript
// @flow
export const debounce = (
fn: any => any,
timeout: number = 250,
interval?: TimeoutID,
) => (...args: any) => {
clearTimeout(interval);
// FIXME: unfortunately it looks like this cannot be easily replaced
// one possible solution might be replacing it with an external lib
// eslint-disable-next-line no-param-reassign
interval = setTimeout(() => fn(...args), timeout);
};