1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

shuffle copied array (#9847)

This commit is contained in:
✨ Audrey ✨
2024-06-26 15:41:02 -04:00
committed by GitHub
parent 89a34a396c
commit a3514001c0
2 changed files with 4 additions and 4 deletions

View File

@@ -31,9 +31,9 @@ export class CryptoServiceRandomizer implements Randomizer {
async shuffle<T>(items: Array<T>, options?: { copy?: boolean }) {
const shuffled = options?.copy ?? true ? [...items] : items;
for (let i = items.length - 1; i > 0; i--) {
for (let i = shuffled.length - 1; i > 0; i--) {
const j = await this.uniform(0, i);
[items[i], items[j]] = [items[j], items[i]];
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
}
return shuffled;