jashkenas/underscore — pull request #1629 by dontfidget (2014-05-07 05:39:03+00:00)
Title: fix throttle and debounce to be re-entrant

It looks like debounce and throttle are not re-entrant because they clear the function context and args after executing the underlying function, even if the underlying function may call the original function itself. I assume this is done to allow garbage collection. I noticed this because I was triggering a debounced function in an ember application whenever I observed a change in a property that the function might itself change. Turns out ember has it's own throttle and debounce functions but I thought I'd offer up this patch anyway. I believe the fix is to only clear the context and args if a new timer has not been set up.

Andrew