travis-ci
3103 of 3170 relevant lines covered (97.89%)
9477.27 hits per line
1 |
var Promise = require('unexpected-bluebird'); |
60✔ |
2 |
|
|
3 |
var workQueue = {
|
60✔ |
4 |
queue: [],
|
|
5 |
drain: function () { |
|
6 |
this.queue.forEach(function (fn) { |
45,828✔ |
7 |
fn(); |
21,004✔ |
8 |
}); |
|
9 |
this.queue = [];
|
45,828✔ |
10 |
} |
|
11 |
}; |
|
12 |
|
|
13 |
var scheduler = Promise.setScheduler(function (fn) { |
60✔ |
14 |
workQueue.queue.push(fn); |
20,568✔ |
15 |
scheduler(function () {
|
20,568✔ |
16 |
workQueue.drain(); |
20,564✔ |
17 |
}); |
|
18 |
}); |
|
19 |
|
|
20 |
|
|
21 |
Promise.prototype._notifyUnhandledRejection = function () { |
60✔ |
22 |
var that = this; |
5,736✔ |
23 |
scheduler(function () {
|
5,736✔ |
24 |
if (that._isRejectionUnhandled()) {
|
5,724✔ |
25 |
if (workQueue.onUnhandledRejection) { // for testing |
4✔ |
26 |
workQueue.onUnhandledRejection(that.reason()); |
4✔ |
27 |
} else {
|
|
28 |
throw that.reason();
|
× |
29 |
} |
|
30 |
} |
|
31 |
}); |
|
32 |
}; |
|
33 |
|
|
34 |
module.exports = workQueue; |
60✔ |