Recently I am reading the source code of lodash debounce function. I can't figure out why timeSinceLastCall could be less than 0 in the shouldInvoke method. The comment says that the system time has gone backwards. What does it mean? The source code of lodash debounce is here: https://github.com/lodash/lodash/blob/4.8.0-npm/debounce.js
Asked
Active
Viewed 72 times
0
-
I means pretty much exactly what it says. It's a precaution for if the system time is changed to some time in the past. – 4castle Jan 05 '17 at 03:35
-
@4castle, do you mean it is a precaution for changing system time into the past when the timer is scheduled? – Samuel Gong Jan 05 '17 at 04:55
-
@4castle, and if I don't change system time any way then the **timeSinceLastCall** will never be less than 0, right? – Samuel Gong Jan 05 '17 at 05:19
-
Yes and yes, that is correct – 4castle Jan 05 '17 at 05:21
-
@4castle, thanks a lot for your help. – Samuel Gong Jan 05 '17 at 05:58