Merge pull request #366 from tillberg/master

This commit fixes #364
This commit is contained in:
Jeremy Ashkenas
2011-11-14 11:13:27 -08:00
2 changed files with 3 additions and 2 deletions

View File

@@ -188,6 +188,7 @@ $(document).ready(function() {
equals(testAfter(5, 5), 1, "after(N) should fire after being called N times"); equals(testAfter(5, 5), 1, "after(N) should fire after being called N times");
equals(testAfter(5, 4), 0, "after(N) should not fire unless called N times"); equals(testAfter(5, 4), 0, "after(N) should not fire unless called N times");
equals(testAfter(0, 0), 1, "after(0) should fire immediately");
}); });
}); });

View File

@@ -595,9 +595,9 @@
// Returns a function that will only be executed after being called N times. // Returns a function that will only be executed after being called N times.
_.after = function(times, func) { _.after = function(times, func) {
return function() { return times ? function() {
if (--times < 1) { return func.apply(this, arguments); } if (--times < 1) { return func.apply(this, arguments); }
}; } : func();
}; };
// Object Functions // Object Functions