Skip to content

Commit

Permalink
refactor: ts debounce fn
Browse files Browse the repository at this point in the history
  • Loading branch information
renbaoshuo committed Mar 8, 2023
1 parent 9d8764c commit 188c5d6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/hexo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,12 @@ const createLoadThemeRoute = function(generatorResult, locals, ctx) {
};
};

function debounce(func, wait) {
let timeout;
function debounce(func: () => void, wait: number) {
let timeout: NodeJS.Timeout;
return function() {
const context = this;
const args = arguments;
clearTimeout(timeout);
timeout = setTimeout(() => {
func.apply(context, args);
func.apply(this);
}, wait);
};
}
Expand Down

0 comments on commit 188c5d6

Please sign in to comment.