_.barrier + tests

This commit is contained in:
Sam Gentle
2011-04-14 07:19:05 +10:00
parent 1fc7d4b049
commit 217a6a6a63
5 changed files with 95 additions and 64 deletions

View File

@@ -510,6 +510,14 @@
};
};
// Returns a function that will only be executed after being called N times.
_.barrier = function(func, times) {
return function() {
if (--times === 0) { return func.apply(this, arguments); }
};
};
// Object Functions
// ----------------