MCPcopy Index your code
hub / github.com/caolan/nodeunit / waitFor

Function waitFor

test/test-base.js:20–43  ·  view source on GitHub ↗
(fn, timeout, callback, start)

Source from the content-addressed store, hash-verified

18// retries the assertion until it passes or the timeout is reached,
19// at which point it throws the assertion error
20var waitFor = function (fn, timeout, callback, start) {
21 start = start || new Date().getTime();
22 callback = callback || function () {};
23 try {
24 fn();
25 callback();
26 }
27 catch (e) {
28 if (e instanceof assert.AssertionError) {
29 var now = new Date().getTime();
30 if (now - start >= timeout) {
31 throw e;
32 }
33 else {
34 async.nextTick(function () {
35 waitFor(fn, timeout, callback, start);
36 });
37 }
38 }
39 else {
40 throw e;
41 }
42 }
43};
44
45
46// TESTS:

Callers 2

makeTestFunction · 0.85
test-base.jsFile · 0.85

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…