@clayui/shared
Version:
ClayShared component
23 lines (21 loc) • 464 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.throttle = throttle;
/**
* SPDX-FileCopyrightText: © 2023 Liferay, Inc. <https://liferay.com>
* SPDX-License-Identifier: BSD-3-Clause
*/
function throttle(callback, limit) {
var waiting = false;
return function () {
if (!waiting) {
callback(...arguments);
waiting = true;
setTimeout(() => {
waiting = false;
}, limit);
}
};
}