UNPKG

@kiwicom/smart-faq

Version:

33 lines (28 loc) 882 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.debounce = void 0; // @flow var debounce = function debounce(fn /*: any => any*/ ) { var timeout /*: number*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250; var interval /*:: ?: TimeoutID*/ = arguments.length > 2 ? arguments[2] : undefined; return function () { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } 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(function () { return fn.apply(void 0, args); }, timeout); }; }; exports.debounce = debounce;