Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
/**
* Fisher-Yates shuffle ES6 non-mutating implementation.
* @param {Array} array the array to shuffle
* @return {Array} shuffled array without mutating the initial array.
*/
export const shuffle = (array: any[]): any[] => {
// perform deep clone on array to mutate
let cloned = array.slice(0);
// array to return
let randomizedArray = [];
// perform shuffle
while (cloned.length !== 0) {
let rIndex = Math.floor(cloned.length * Math.random());
randomizedArray.push(cloned[rIndex]);
cloned.splice(rIndex, 1);
}
return randomizedArray;
};