MCPcopy Index your code
hub / github.com/nodejs/node / f

Function f

test/parallel/test-timers-ordering.js:35–51  ·  view source on GitHub ↗
(i)

Source from the content-addressed store, hash-verified

33let last_ts = 0;
34
35function f(i) {
36 if (i <= N) {
37 // check order
38 assert.strictEqual(i, last_i + 1, `order is broken: ${i} != ${last_i} + 1`);
39 last_i = i;
40
41 // Check that this iteration is fired at least 1ms later than the previous
42 // We need to use the binding as the receiver for fast API calls.
43 const now = binding.getLibuvNow();
44 assert(now >= last_ts + 1,
45 `current ts ${now} < prev ts ${last_ts} + 1`);
46 last_ts = now;
47
48 // Schedule next iteration
49 setTimeout(f, 1, i + 1);
50 }
51}
52setTimeout(f, 1, 1);

Callers

nothing calls this directly

Calls 3

getLibuvNowMethod · 0.80
assertFunction · 0.50
setTimeoutFunction · 0.50

Tested by

no test coverage detected