push
github
1754 of 1760 branches covered (99.66%)
2 of 2 new or added lines in 1 file covered. (100.0%)
1 existing line in 1 file now uncovered.2223 of 2224 relevant lines covered (99.96%)
143.67 hits per line
1 |
import { deferred } from "./utils.js"; |
|
2 |
|
|
3 |
const queue = new Set();
|
2✔ |
4 |
export function add(fn) { |
|
5 |
if (!queue.size) deferred.then(execute);
|
|
6 |
queue.add(fn); |
334✔ |
7 |
} |
|
8 |
|
|
9 |
export function clear(fn) { |
|
10 |
queue.delete(fn);
|
224✔ |
11 |
} |
|
12 |
|
|
13 |
function execute() { |
|
14 |
for (const fn of queue) {
|
168✔ |
15 |
try {
|
330✔ |
16 |
fn(); |
330✔ |
17 |
} catch (e) {
|
|
18 |
console.error(e); |
5✔ |
19 |
} |
|
20 |
} |
|
21 |
|
|
22 |
queue.clear(); |
168✔ |
23 |
} |