JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr{ gilour

File "shuffle-array.ts"

Full Path: /home/markqprx/iniasli.pro/client/utils/array/shuffle-array.ts
File size: 504 bytes
MIME-type: text/plain
Charset: utf-8

export function shuffleArray(items: any[], keepFirst = false) {
  let first = keepFirst ? items.shift() : null;

  let currentIndex = items.length,
    temporaryValue,
    randomIndex;

  while (0 !== currentIndex) {
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;

    temporaryValue = items[currentIndex];
    items[currentIndex] = items[randomIndex];
    items[randomIndex] = temporaryValue;
  }

  if (first) {
    items.unshift(first);
  }

  return [...items];
}