push
github
1738 of 1745 branches covered (99.6%)
2 of 2 new or added lines in 1 file covered. (100.0%)
2198 of 2198 relevant lines covered (100.0%)
275.79 hits per line
1 |
import { deferred } from "./utils.js"; |
|
2 |
|
|
3 |
const queue = new Set();
|
4✔ |
4 |
export function add(fn) { |
|
5 |
if (!queue.size) deferred.then(execute);
|
|
6 |
queue.add(fn); |
626✔ |
7 |
} |
|
8 |
|
|
9 |
export function clear(fn) { |
|
10 |
queue.delete(fn);
|
430✔ |
11 |
} |
|
12 |
|
|
13 |
function execute() { |
|
14 |
for (const fn of queue) {
|
316✔ |
15 |
try {
|
626✔ |
16 |
fn(); |
626✔ |
17 |
} catch (e) {
|
|
18 |
console.error(e); |
14✔ |
19 |
} |
|
20 |
} |
|
21 |
|
|
22 |
queue.clear(); |
316✔ |
23 |
} |