Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Komorski authored and Marcin Komorski committed Sep 27, 2024
1 parent c4907b8 commit 6fe399d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ export const activeOriginsCalls = new Map();
export const queuedCalls = [];

// Function to safely increment number of active calls for a given origin
function addRequestForOrigin(key) {
function incrementRequestsForOrigin(key) {
const currentValue = activeOriginsCalls.get(key);
const newValue = (currentValue ?? 0) + 1;
activeOriginsCalls.set(key, newValue);
}

// Function to safely decrement number of active calls for a given origin
function removeRequestForOrigin(key) {
function decrementRequestsForOrigin(key) {
const currentValue = activeOriginsCalls.get(key);
const newValue = (currentValue ?? 0) - 1;
activeOriginsCalls.set(key, newValue);
Expand Down Expand Up @@ -112,13 +112,13 @@ export function fetcherFactory(timeout = 3000, {request, done} = {}) {

const invokeRequest = () => {
request && request(origin);
addRequestForOrigin(origin);
incrementRequestsForOrigin(origin);
dep.fetch(resource, options)
.then(pm.resolve)
.catch(pm.reject)
.finally(() => {
if (to?.done != null) to.done();
removeRequestForOrigin(origin);
decrementRequestsForOrigin(origin);
const index = queuedCalls.findIndex((entry) => origin === entry.origin);
if (index >= 0) {
const entry = queuedCalls[index];
Expand Down

0 comments on commit 6fe399d

Please sign in to comment.