Closed marthaberner closed 9 years ago
Nope, in both cases it swallows up the first execution of the function and only runs the second after the required time passes
Actually it appears that you are correct. It seems I mixed up throttle and denounce. I'll fix that when I get a chance
If this throttle-function is supposed to behave like the Underscore one it seems as if it should actually be called twice:
By default, throttle will execute the function as soon as you call it for the first time, and, if you call it again any number of times during the wait period, as soon as that period is over.
Not the clearest sentence, but if I understand it correctly this would mean that it's actually the Readme and the first tests that should be changed?
This doesn't look fixed. The first test case for throttle
expects 3 calls in a row to result in a single execution, but _.throttle
would call it twice - once on the leading edge, once on the trailing edge. It may be that you intended it to mimic _.throttle
with either the leading: false
or trailing: false
options set, in which case the README should be updated as such.
I renamed it to debounce, I'll add a throttle exercise later
The throttle test suite has the following tests:
In both cases, it appears that the test suite is expecting the
throttled
function to execute twice within the wait period. Is this test suite correct?Shouldn't that last test's assertion be
assert.deepEqual(args, [11, 22, 33]);
?