-
Notifications
You must be signed in to change notification settings - Fork 511
Open
Labels
p1: minor bugbugs in minor functionsbugs in minor functions
Description
While I was sanity-checking the reproduction on this issue, I've found that there's a discrepancy between lodash and compat throttle:
import lodashThrottle from 'lodash-es/throttle';
import compatThrottle from 'es-toolkit/compat/throttle';
const WAIT = 100;
const OPTIONS = {leading: false, trailing: false};
const lodashThrottled = lodashThrottle(() => console.log('lodashThrottled'), WAIT, OPTIONS);
const compatThrottled = compatThrottle(() => console.log('compatThrottled'), WAIT, OPTIONS);
// These seem to be mostly consistent on my machine
setInterval(lodashThrottled, 1);
setInterval(compatThrottled, 1);
// Things start to get inconsistent
setInterval(lodashThrottled, 100);
setInterval(compatThrottled, 100);
// Lodash now executes far more rarely, while compat seems to execute according to delay
// The lodash timing appears to grow exponentially compared to compat
setInterval(lodashThrottled, 115);
setInterval(compatThrottled, 115);
// Note: system/browser workload seems to increase the timing inconsistencies as wellThis is a bit extreme edge case considering this seems to happen only with both trailing and leading edges disabled, but configuration like this is still implicitly allowed (even though the effects of doing so are not generally established), so I thought it deserved mention.
Metadata
Metadata
Assignees
Labels
p1: minor bugbugs in minor functionsbugs in minor functions