(callback)
| 3 | counter = {scheduled: 0, aborted: 0}; |
| 4 | |
| 5 | function task(callback) { |
| 6 | var index = counter.scheduled++; |
| 7 | ++active; |
| 8 | var timeout = setTimeout(function() { |
| 9 | timeout = null; |
| 10 | try { |
| 11 | callback(null, {active: active, index: index}); |
| 12 | } finally { |
| 13 | --active; |
| 14 | } |
| 15 | }, delay); |
| 16 | return { |
| 17 | abort: function() { |
| 18 | if (timeout) { |
| 19 | timeout = clearTimeout(timeout); |
| 20 | ++counter.aborted; |
| 21 | } |
| 22 | } |
| 23 | }; |
| 24 | } |
| 25 | |
| 26 | task.aborted = function() { |
| 27 | return counter.aborted; |
nothing calls this directly
no test coverage detected
searching dependent graphs…