15 lines
311 B
TypeScript
15 lines
311 B
TypeScript
|
"use strict";
|
||
|
|
||
|
export function shuffled(array: Array<any>): Array<any> {
|
||
|
array = array.slice();
|
||
|
|
||
|
for (let i = array.length - 1; i > 0; i--) {
|
||
|
let j = Math.floor(Math.random() * (i + 1));
|
||
|
let tmp = array[i];
|
||
|
array[i] = array[j];
|
||
|
array[j] = tmp;
|
||
|
}
|
||
|
|
||
|
return array;
|
||
|
}
|