mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Fixes #465 -- throttled functions return their value when they actually run.
This commit is contained in:
@@ -117,12 +117,15 @@ $(document).ready(function() {
|
||||
_.delay(function(){ equal(value, 6, "updated to latest value"); start(); }, 400);
|
||||
});
|
||||
|
||||
asyncTest("functions: throttle once", 1, function() {
|
||||
asyncTest("functions: throttle once", 2, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var incr = function(){ return ++counter; };
|
||||
var throttledIncr = _.throttle(incr, 100);
|
||||
throttledIncr();
|
||||
_.delay(function(){ equal(counter, 1, "incr was called once"); start(); }, 220);
|
||||
var result = throttledIncr();
|
||||
_.delay(function(){
|
||||
equal(result, 1, "throttled functions return their value");
|
||||
equal(counter, 1, "incr was called once"); start();
|
||||
}, 220);
|
||||
});
|
||||
|
||||
asyncTest("functions: throttle twice", 1, function() {
|
||||
|
||||
Reference in New Issue
Block a user