Replace setImmediate
with queueMicrotask
.
This commit is contained in:
parent
4d2b327da7
commit
9b58b10421
3 changed files with 4 additions and 13 deletions
|
@ -1,7 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
require(`setimmediate`);
|
||||
|
||||
// An order represents a pending push or shift.
|
||||
const Order = (channel) => {
|
||||
let order;
|
||||
|
@ -249,7 +247,7 @@ const Channel = function(length = 0) {
|
|||
shift: function() {
|
||||
const { order, promise } = Order(this);
|
||||
shifts.push(order);
|
||||
setImmediate(processOrders);
|
||||
queueMicrotask(processOrders);
|
||||
|
||||
// Don't freeze promise because Bluebird expects it to be mutable.
|
||||
return promise;
|
||||
|
@ -321,7 +319,7 @@ const Channel = function(length = 0) {
|
|||
processOrders();
|
||||
|
||||
// Give remaining orders in flight time to resolve before returning.
|
||||
setImmediate(resolve);
|
||||
queueMicrotask(resolve);
|
||||
}
|
||||
}),
|
||||
|
||||
|
@ -348,7 +346,7 @@ const Channel = function(length = 0) {
|
|||
order.reject(new Error(`Can't push more than one value at a time.`));
|
||||
} else {
|
||||
pushes.push(order);
|
||||
setImmediate(processOrders);
|
||||
queueMicrotask(processOrders);
|
||||
}
|
||||
|
||||
// Don't freeze promise because Bluebird expects it to be mutable.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue