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