Skip to content

Commit

Permalink
src/core/function: grab Date off win (#37225)
Browse files Browse the repository at this point in the history
  • Loading branch information
samouri committed Dec 15, 2021
1 parent 0201b68 commit fb596cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/core/types/function/date-global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export {};

declare global {
interface Window {
Date: typeof Date;
}
}
4 changes: 2 additions & 2 deletions src/core/types/function/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function debounce(win, callback, minInterval) {
*/
function waiter() {
locker = 0;
const remaining = minInterval - (Date.now() - timestamp);
const remaining = minInterval - (win.Date.now() - timestamp);
if (remaining > 0) {
locker = win.setTimeout(waiter, remaining);
} else {
Expand All @@ -118,7 +118,7 @@ export function debounce(win, callback, minInterval) {
}

return function (...args) {
timestamp = Date.now();
timestamp = win.Date.now();
nextCallArgs = args;
if (!locker) {
locker = win.setTimeout(waiter, minInterval);
Expand Down

0 comments on commit fb596cf

Please sign in to comment.