diff --git a/libs/common/src/tools/generator/random.ts b/libs/common/src/tools/generator/random.ts index 6b72e3cd91..1400ed1175 100644 --- a/libs/common/src/tools/generator/random.ts +++ b/libs/common/src/tools/generator/random.ts @@ -31,9 +31,9 @@ export class CryptoServiceRandomizer implements Randomizer { async shuffle(items: Array, 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; diff --git a/libs/tools/generator/core/src/engine/crypto-service-randomizer.ts b/libs/tools/generator/core/src/engine/crypto-service-randomizer.ts index a15440836d..5320fad681 100644 --- a/libs/tools/generator/core/src/engine/crypto-service-randomizer.ts +++ b/libs/tools/generator/core/src/engine/crypto-service-randomizer.ts @@ -31,9 +31,9 @@ export class CryptoServiceRandomizer implements Randomizer { async shuffle(items: Array, 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;