Files
SnowLuma/.pnpm-store/v11/files/be/18d0e483332126041f87ba5037a5a5833af64c932c98ad2d25dfe41409f4d3b72a2849948a562508f4bce2d3555c57f4e3b565fcbc203cc5bd32a1e3f5f2b8
TanTan 2a69b23b47
Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

35 lines
1.0 KiB
Plaintext

'use strict';
/**
* @link https://davidwalsh.name/javascript-debounce-function
* @param func needs to implement a function which is debounced
* @param wait how long do you want to wait till the previous declared function is executed
* @param isImmediate defines if you want to execute the function on the first execution or the last execution inside the time window. `true` for first and `false` for last.
*/
var debounce = (func, wait, isImmediate) => {
let timeout;
return function debounce(...args) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const context = this;
const later = () => {
timeout = undefined;
if (!isImmediate) {
func.apply(context, args);
}
};
const shouldCallNow = isImmediate && !timeout;
if (timeout !== undefined) {
clearTimeout(timeout);
}
timeout = setTimeout(later, wait);
if (shouldCallNow) {
func.apply(context, args);
return;
}
return undefined;
};
};
module.exports = debounce;
//# sourceMappingURL=debounce.cjs.map