Fix dependabot issues
This commit is contained in:
parent
c89d9bd8b0
commit
531c6ba7c8
705 changed files with 53406 additions and 20466 deletions
39
node_modules/ava/lib/ipc-flow-control.js
generated
vendored
Normal file
39
node_modules/ava/lib/ipc-flow-control.js
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
function controlFlow(channel) {
|
||||
let errored = false;
|
||||
let deliverImmediately = true;
|
||||
|
||||
const backlog = [];
|
||||
const deliverNext = error => {
|
||||
if (error !== null) {
|
||||
errored = true;
|
||||
}
|
||||
|
||||
if (errored || !channel.connected) {
|
||||
backlog.length = 0; // Free memory.
|
||||
return; // We can't send.
|
||||
}
|
||||
|
||||
let ok = true;
|
||||
while (ok && backlog.length > 0) { // Stop sending after backpressure.
|
||||
ok = channel.send(backlog.shift(), deliverNext);
|
||||
}
|
||||
|
||||
// Re-enable immediate delivery if there is no backpressure and the backlog
|
||||
// has been cleared.
|
||||
deliverImmediately = ok && backlog.length === 0;
|
||||
};
|
||||
|
||||
return message => {
|
||||
if (errored || !channel.connected) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (deliverImmediately) {
|
||||
deliverImmediately = channel.send(message, deliverNext);
|
||||
} else {
|
||||
backlog.push(message);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.controlFlow = controlFlow;
|
||||
Loading…
Add table
Add a link
Reference in a new issue