in src/SimpleWebRequest.ts [618:649]
protected _enqueue(): void {
// It's possible for a request to be canceled before it's queued since onCancel fires synchronously and we set up the listener
// before queueing for execution
// An aborted request should never be queued for execution
if (this._aborted) {
return;
}
// Check if the current queues, if the request is already in there, nothing to enqueue
if (executingList.indexOf(this) >= 0 || blockedList.indexOf(this) >= 0 || requestQueue.indexOf(this) >= 0) {
return;
}
// Throw it on the queue
const index = requestQueue.findIndex(request =>
// find a request with the same priority, but newer
(request.getPriority() === this.getPriority() && request._created > this._created) ||
// or a request with lower priority
(request.getPriority() < this.getPriority()),
);
if (index > -1) {
// add me before the found request
requestQueue.splice(index, 0, this);
} else {
// add me at the end
requestQueue.push(this);
}
// See if it's time to execute it
SimpleWebRequestBase.checkQueueProcessing();
}