From 42d679566624aaedd01eb5c0d9fa54104008016c Mon Sep 17 00:00:00 2001 From: Shinigami Date: Mon, 2 May 2022 20:17:48 +0200 Subject: fix: replace deprecated arrayElement calls (#903) --- src/random.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/random.ts b/src/random.ts index 3cf4c0aa..87976828 100644 --- a/src/random.ts +++ b/src/random.ts @@ -360,12 +360,12 @@ export class Random { do { // randomly pick from the many faker methods that can generate words - const randomWordMethod = this.arrayElement(wordMethods); + const randomWordMethod = this.faker.helpers.arrayElement(wordMethods); result = randomWordMethod(); } while (!result || bannedChars.some((char) => result.includes(char))); - return this.arrayElement(result.split(' ')); + return this.faker.helpers.arrayElement(result.split(' ')); } /** @@ -419,7 +419,7 @@ export class Random { * faker.random.locale() // 'el' */ locale(): string { - return this.arrayElement(Object.keys(this.faker.locales)); + return this.faker.helpers.arrayElement(Object.keys(this.faker.locales)); } /** @@ -485,7 +485,7 @@ export class Random { let wholeString = ''; for (let i = 0; i < count; i++) { - wholeString += this.arrayElement(charsArray); + wholeString += this.faker.helpers.arrayElement(charsArray); } return upcase ? wholeString.toUpperCase() : wholeString; @@ -558,7 +558,7 @@ export class Random { let wholeString = ''; for (let i = 0; i < count; i++) { - wholeString += this.arrayElement(charsArray); + wholeString += this.faker.helpers.arrayElement(charsArray); } return wholeString; @@ -610,13 +610,13 @@ export class Random { let result = ''; if (!allowLeadingZeros && !bannedDigits.includes('0')) { - result += this.arrayElement( + result += this.faker.helpers.arrayElement( allowedDigits.filter((digit) => digit !== '0') ); } while (result.length < length) { - result += this.arrayElement(allowedDigits); + result += this.faker.helpers.arrayElement(allowedDigits); } return result; -- cgit v1.2.3