UNPKG

wix-style-react

Version:
21 lines (20 loc) 700 B
"use strict"; exports.__esModule = true; exports.debounce = void 0; /** Lodash debounce doesn't play nicely with jest fake timers, * so we provide a simplified debouncing function for unit test. */ var debounce = exports.debounce = function debounce(callback) { var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250; var timeoutId; return function () { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } clearTimeout(timeoutId); timeoutId = setTimeout(() => { timeoutId = null; callback(...args); }, delay); }; }; //# sourceMappingURL=debounce.js.map