Debian Codegraph @

timers-ext/test/throttle.js

raw
1 "use strict";
2
3 module.exports = function (t, a, d) {
4 var called = 0;
5 var fn = t(function () { ++called; }, 200);
6
7 fn();
8 a(called, 1);
9 fn();
10 fn();
11 a(called, 1);
12 // Wait 120ms
13 setTimeout(function () {
14 a(called, 1);
15 fn();
16 // Wait 120ms
17 setTimeout(function () {
18 a(called, 2);
19 fn();
20 fn();
21
22 // Wait 80ms
23 setTimeout(function () {
24 a(called, 2);
25
26 // Wait 120ms
27 setTimeout(function () {
28 a(called, 3);
29
30 // Wait 400ms
31 setTimeout(function () {
32 a(called, 3);
33 d();
34 }, 400);
35 }, 120);
36 }, 80);
37 }, 120);
38 }, 120);
39 };