async function processRequest(
  request,
  payload,
) {
  const route = request.url.substring(request.url.indexOf("api/"));
  const parts = route.split("/");
  // REMOVE THE API
  parts.shift();
  // REMOVES THE VERSION NUMBER
  if (parts[0]?.startsWith("v")) parts.shift();
  // SET THE NEW REQUEST URL
  request.url = `${BASE_URL}/v${rest.apiVersion}/${parts.join("/")}`;
  // REMOVE THE MAJOR PARAM
  parts.shift();
  const [id] = parts;
  const queue = rest.pathQueues.get(id);
  // IF THE QUEUE EXISTS JUST ADD THIS TO THE QUEUE
  if (queue) {
    queue.push({
      request,
      payload,
    });
  } else {
    // CREATES A NEW QUEUE
    rest.pathQueues.set(id, [
      {
        request,
        payload,
      },
    ]);
    await rest.processQueue(id);
  }
}
/** Processes a request and assigns it to a queue or creates a queue if none exists for it. */
Processes a request and assigns it to a queue or creates a queue if none exists for it.
Processes a request and assigns it to a queue or creates a queue if none exists for it .
async function processRequest(
  request,
  payload,
) {
  const route = request.url.substring(request.url.indexOf("api/"));
  const parts = route.split("/");
  parts.shift();
  if (parts[0]?.startsWith("v")) parts.shift();
  request.url = `${BASE_URL}/v${rest.apiVersion}/${parts.join("/")}`;
  parts.shift();
  const [id] = parts;
  const queue = rest.pathQueues.get(id);
  if (queue) {
    queue.push({
      request,
      payload,
    });
  } else {
    rest.pathQueues.set(id, [
      {
        request,
        payload,
      },
    ]);
    await rest.processQueue(id);
  }
}
async function processRequest ( request , payload , ) { const route = request . url . substring ( request . url . indexOf ( "api/" ) ) ; const parts = route . split ( "/" ) ; parts . shift ( ) ; if ( parts [ 0 ] ?. startsWith ( "v" ) ) parts . shift ( ) ; request . url = ` ${ BASE_URL } ${ rest . apiVersion } ${ parts . join ( "/" ) } ` ; parts . shift ( ) ; const [ id ] = parts ; const queue = rest . pathQueues . get ( id ) ; if ( queue ) { queue . push ( { request , payload , } ) ; } else { rest . pathQueues . set ( id , [ { request , payload , } , ] ) ; await rest . processQueue ( id ) ; } }
Processes a request and assigns it to a queue or creates a queue if none exists for it.
Processes a request and assigns it to a queue or creates a queue if none exists for it .
// REMOVE THE API // REMOVES THE VERSION NUMBER // SET THE NEW REQUEST URL // REMOVE THE MAJOR PARAM // IF THE QUEUE EXISTS JUST ADD THIS TO THE QUEUE // CREATES A NEW QUEUE