<commit_before>function processQueue(router, routerQueue, routeQueue, to, from, resolve, reject) {
  const queue = [];

  if (Array.isArray(routeQueue)) {
    queue.push(...routeQueue);
  } else if (routeQueue && typeof routeQueue === 'function') {
    queue.push(routeQueue);
  }
  if (routerQueue) {
    if (Array.isArray(routerQueue)) {
      queue.push(...routerQueue);
    } else {
      queue.push(routerQueue);
    }
  }

  function next() {
    if (queue.length === 0) {
      resolve();
      return;
    }
    const queueItem = queue.shift();

    queueItem.call(
      router,
      to,
      from,
      () => {
        next();
      },
      () => {
        reject();
      }
    );
  }
  next();
}

export default function (to, from, resolve, reject) {
  const router = this;
  function enterNextRoute() {
    if (router.params.beforeEnter || to.route.beforeEnter) {
      router.allowPageChange = false;
      processQueue(
        router,
        router.params.beforeEnter,
        to.route.beforeEnter,
        to,
        from,
        () => {
          router.allowPageChange = true;
          resolve();
        },
        () => {
          reject();
        },
      );
    } else {
      resolve();
    }
  }
  function leaveCurrentRoute() {
    if (router.params.beforeLeave || from.route.beforeLeave) {
      router.allowPageChange = false;
      processQueue(
        router,
        router.params.beforeLeave,
        from.route.beforeLeave,
        to,
        from,
        () => {
          router.allowPageChange = true;
          enterNextRoute();
        },
        () => {
          reject();
        },
      );
    } else {
      enterNextRoute();
    }<commit_msg>Dobule check for beforeEnter/beforeLeave<commit_after>function processQueue(router, routerQueue, routeQueue, to, from, resolve, reject) {
  const queue = [];

  if (Array.isArray(routeQueue)) {
    queue.push(...routeQueue);
  } else if (routeQueue && typeof routeQueue === 'function') {
    queue.push(routeQueue);
  }
  if (routerQueue) {
    if (Array.isArray(routerQueue)) {
      queue.push(...routerQueue);
    } else {
      queue.push(routerQueue);
    }
  }

  function next() {
    if (queue.length === 0) {
      resolve();
      return;
    }
    const queueItem = queue.shift();

    queueItem.call(
      router,
      to,
      from,
      () => {
        next();
      },
      () => {
        reject();
      }
    );
  }
  next();
}

export default function (to, from, resolve, reject) {
  const router = this;
  function enterNextRoute() {
    if (to && to.route && (router.params.beforeEnter || to.route.beforeEnter)) {
      router.allowPageChange = false;
      processQueue(
        router,
        router.params.beforeEnter,
        to.route.beforeEnter,
        to,
        from,
        () => {
          router.allowPageChange = true;
          resolve();
        },
        () => {
          reject();
        },
      );
    } else {
      resolve();
    }
  }
  function leaveCurrentRoute() {
    if (from && from.route && (router.params.beforeLeave || from.route.beforeLeave)) {
      router.allowPageChange = false;
      processQueue(
        router,
        router.params.beforeLeave,
        from.route.beforeLeave,
        to,
        from,
        () => {
          router.allowPageChange = true;
          enterNextRoute();
        },
        () => {
          reject();
        },
      );
    } else {
      enterNextRoute();
    }
{'fraction_non_alphanumeric': 0.1431864016133679, 'fraction_numerical': 0.0005762028233938346, 'mean_word_length': 1.7577442414614775, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6193941', 'n_tokens_mistral': 1032, 'n_tokens_neox': 1026, 'n_words': 191}