MCPcopy Create free account
hub / github.com/cujojs/poly / countdown

Function countdown

test/curl.js:205–213  ·  view source on GitHub ↗

* Returns a function that when executed, executes a lambda function, * but only executes it the number of times stated by howMany. * When done executing, it executes the completed function. Each callback * function receives the same parameters that are supplied to the * returned function eac

(howMany, lambda, completed)

Source from the content-addressed store, hash-verified

203 * @returns {Function}
204 */
205 function countdown (howMany, lambda, completed) {
206 var result;
207 return function () {
208 if (--howMany >= 0 && lambda) result = lambda.apply(undef, arguments);
209 // we want ==, not <=, since some callers expect call-once functionality
210 if (howMany == 0 && completed) completed(result);
211 return result;
212 }
213 }
214
215 core = {
216

Callers 2

curl.jsFile · 0.85
getDepFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected