Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
Something went wrong. Try again.
TypeScript
12345678910111213141516171819202122const RealDate = Date
function random(seed: number) { const x = Math.sin(seed++) * 10000 return x - Math.floor(x)}
export function shuffle<T>(array: T[], seed: number = RealDate.now()): T[] { let length = array.length
while (length) { const index = Math.floor(random(seed) * length--)
const previous = array[length] array[length] = array[index] array[index] = previous ++seed }
return array}