mirror of
https://github.com/tenrok/vue-json-viewer.git
synced 2026-05-15 11:59:40 +03:00
14 lines
297 B
JavaScript
14 lines
297 B
JavaScript
export const debounce = function(func, wait) {
|
|
let startTime = Date.now();
|
|
let timer;
|
|
|
|
return (...args) => {
|
|
if (Date.now() - startTime < wait && timer) {
|
|
clearTimeout(timer);
|
|
}
|
|
timer = setTimeout(() => {
|
|
func(...args);
|
|
}, wait);
|
|
startTime = Date.now();
|
|
}
|
|
} |