diff options
| author | Shinigami <[email protected]> | 2023-10-17 22:03:32 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-17 20:03:32 +0000 |
| commit | c0330442be99988db57e9dad12ebdcd3b3a92213 (patch) | |
| tree | 49a7814ef2a3b3a05b147e8be790c4712ef414e8 /src/modules | |
| parent | f3de0f61dc517a4548150fd40498a9df6d4b97e6 (diff) | |
| download | faker-c0330442be99988db57e9dad12ebdcd3b3a92213.tar.xz faker-c0330442be99988db57e9dad12ebdcd3b3a92213.zip | |
infra(unicorn): prefer-spread (#2421)
Co-authored-by: ST-DDT <[email protected]>
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/color/index.ts | 2 | ||||
| -rw-r--r-- | src/modules/company/index.ts | 2 | ||||
| -rw-r--r-- | src/modules/finance/index.ts | 6 | ||||
| -rw-r--r-- | src/modules/helpers/index.ts | 6 | ||||
| -rw-r--r-- | src/modules/internet/index.ts | 7 | ||||
| -rw-r--r-- | src/modules/string/index.ts | 18 | ||||
| -rw-r--r-- | src/modules/system/index.ts | 6 |
7 files changed, 20 insertions, 27 deletions
diff --git a/src/modules/color/index.ts b/src/modules/color/index.ts index 790a6925..5855cd86 100644 --- a/src/modules/color/index.ts +++ b/src/modules/color/index.ts @@ -86,7 +86,7 @@ function toBinary(values: number[]): string { const buffer = new ArrayBuffer(4); new DataView(buffer).setFloat32(0, value); const bytes = new Uint8Array(buffer); - return toBinary(Array.from(bytes)).split(' ').join(''); + return toBinary([...bytes]).replace(/ /g, ''); } return (value >>> 0).toString(2).padStart(8, '0'); diff --git a/src/modules/company/index.ts b/src/modules/company/index.ts index c24ea7f3..36144961 100644 --- a/src/modules/company/index.ts +++ b/src/modules/company/index.ts @@ -42,7 +42,7 @@ export class CompanyModule { }); // Don't want the source array exposed to modification, so return a copy // eslint-disable-next-line deprecation/deprecation - return this.faker.definitions.company.suffix.slice(0); + return [...this.faker.definitions.company.suffix]; } /** diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts index 43cd16a1..ce4b2889 100644 --- a/src/modules/finance/index.ts +++ b/src/modules/finance/index.ts @@ -722,9 +722,9 @@ export class FinanceModule { let address = this.faker.helpers.arrayElement(['L', 'M', '3']); for (let i = 0; i < addressLength - 1; i++) - address += this.faker.helpers.arrayElement( - '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'.split('') - ); + address += this.faker.helpers.arrayElement([ + ...'123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', + ]); return address; } diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts index f4ceaaf4..ab0ec5b8 100644 --- a/src/modules/helpers/index.ts +++ b/src/modules/helpers/index.ts @@ -704,7 +704,7 @@ export class SimpleHelpersModule { uniqueArray<T>(source: ReadonlyArray<T> | (() => T), length: number): T[] { if (Array.isArray(source)) { const set = new Set<T>(source); - const array = Array.from(set); + const array = [...set]; return this.shuffle(array).splice(0, length); } @@ -722,7 +722,7 @@ export class SimpleHelpersModule { // Ignore } - return Array.from(set); + return [...set]; } /** @@ -1003,7 +1003,7 @@ export class SimpleHelpersModule { return []; } - const arrayCopy = array.slice(0); + const arrayCopy = [...array]; let i = array.length; const min = i - numElements; let temp: T; diff --git a/src/modules/internet/index.ts b/src/modules/internet/index.ts index 6e8f822f..947edfba 100644 --- a/src/modules/internet/index.ts +++ b/src/modules/internet/index.ts @@ -271,8 +271,8 @@ export class InternetModule { // We limit to 50 chars to be more realistic localPart = localPart.substring(0, 50); if (allowSpecialCharacters) { - const usernameChars: string[] = '._-'.split(''); - const specialChars: string[] = ".!#$%&'*+-/=?^_`{|}~".split(''); + const usernameChars: string[] = [...'._-']; + const specialChars: string[] = [...".!#$%&'*+-/=?^_`{|}~"]; localPart = localPart.replace( this.faker.helpers.arrayElement(usernameChars), this.faker.helpers.arrayElement(specialChars) @@ -638,8 +638,7 @@ export class InternetModule { .normalize('NFKD') //for example è decomposes to as e + ̀ .replace(/[\u0300-\u036f]/g, ''); // removes combining marks - result = result - .split('') + result = [...result] .map((char) => { // If we have a mapping for this character, (for Cyrillic, Greek etc) use it if (charMapping[char]) { diff --git a/src/modules/string/index.ts b/src/modules/string/index.ts index 8167ebea..a370c386 100644 --- a/src/modules/string/index.ts +++ b/src/modules/string/index.ts @@ -5,13 +5,9 @@ import type { LiteralUnion } from '../../utils/types'; export type Casing = 'upper' | 'lower' | 'mixed'; -const UPPER_CHARS: ReadonlyArray<string> = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split( - '' -); -const LOWER_CHARS: ReadonlyArray<string> = 'abcdefghijklmnopqrstuvwxyz'.split( - '' -); -const DIGIT_CHARS: ReadonlyArray<string> = '0123456789'.split(''); +const UPPER_CHARS: ReadonlyArray<string> = [...'ABCDEFGHIJKLMNOPQRSTUVWXYZ']; +const LOWER_CHARS: ReadonlyArray<string> = [...'abcdefghijklmnopqrstuvwxyz']; +const DIGIT_CHARS: ReadonlyArray<string> = [...'0123456789']; export type LowerAlphaChar = | 'a' @@ -145,7 +141,7 @@ export class StringModule { } if (typeof characters === 'string') { - characters = characters.split(''); + characters = [...characters]; } if (characters.length === 0) { @@ -229,7 +225,7 @@ export class StringModule { let { exclude = [] } = options; if (typeof exclude === 'string') { - exclude = exclude.split(''); + exclude = [...exclude]; } let charsArray: string[]; @@ -319,7 +315,7 @@ export class StringModule { let { exclude = [] } = options; if (typeof exclude === 'string') { - exclude = exclude.split(''); + exclude = [...exclude]; } let charsArray = [...DIGIT_CHARS]; @@ -596,7 +592,7 @@ export class StringModule { let { exclude = [] } = options; if (typeof exclude === 'string') { - exclude = exclude.split(''); + exclude = [...exclude]; } const allowedDigits = DIGIT_CHARS.filter( diff --git a/src/modules/system/index.ts b/src/modules/system/index.ts index 89fd23f1..8a21a39b 100644 --- a/src/modules/system/index.ts +++ b/src/modules/system/index.ts @@ -159,8 +159,7 @@ export class SystemModule { const typeSet = new Set( Object.keys(mimeTypes).map((key) => key.split('/')[0]) ); - const types = Array.from(typeSet); - return this.faker.helpers.arrayElement(types); + return this.faker.helpers.arrayElement([...typeSet]); } /** @@ -184,8 +183,7 @@ export class SystemModule { const extensionSet = new Set( Object.values(mimeTypes).flatMap(({ extensions }) => extensions) ); - const extensions = Array.from(extensionSet); - return this.faker.helpers.arrayElement(extensions); + return this.faker.helpers.arrayElement([...extensionSet]); } /** |
