push
github
1857 of 1960 branches covered (94.74%)
3319 of 3404 relevant lines covered (97.5%)
2012.29 hits per line
1 |
const Promise = require('unexpected-bluebird');
|
16✔ |
2 |
|
|
3 |
const workQueue = { |
16✔ |
4 |
queue: [],
|
|
5 |
drain() { |
|
6 |
this.queue.forEach((fn) => {
|
10,179✔ |
7 |
fn(); |
4,673✔ |
8 |
}); |
|
9 |
this.queue = [];
|
10,179✔ |
10 |
}, |
|
11 |
}; |
|
12 |
|
|
13 |
const scheduler = Promise.setScheduler((fn) => { |
16✔ |
14 |
workQueue.queue.push(fn); |
4,653✔ |
15 |
scheduler(() => { |
4,653✔ |
16 |
workQueue.drain(); |
4,653✔ |
17 |
}); |
|
18 |
}); |
|
19 |
|
|
20 |
Promise.prototype._notifyUnhandledRejection = function () { |
16✔ |
21 |
const that = this;
|
1,340✔ |
22 |
scheduler(() => { |
1,340✔ |
23 |
if (that._isRejectionUnhandled()) {
|
|
24 |
if (workQueue.onUnhandledRejection) {
|
|
25 |
// for testing
|
|
26 |
workQueue.onUnhandledRejection(that.reason()); |
× |
27 |
} else {
|
|
28 |
throw that.reason();
|
× |
29 |
} |
|
30 |
} |
|
31 |
}); |
|
32 |
}; |
|
33 |
|
|
34 |
module.exports = workQueue; |
16✔ |