From c0330442be99988db57e9dad12ebdcd3b3a92213 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Tue, 17 Oct 2023 22:03:32 +0200 Subject: infra(unicorn): prefer-spread (#2421) Co-authored-by: ST-DDT --- src/modules/string/index.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/modules/string') 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 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split( - '' -); -const LOWER_CHARS: ReadonlyArray = 'abcdefghijklmnopqrstuvwxyz'.split( - '' -); -const DIGIT_CHARS: ReadonlyArray = '0123456789'.split(''); +const UPPER_CHARS: ReadonlyArray = [...'ABCDEFGHIJKLMNOPQRSTUVWXYZ']; +const LOWER_CHARS: ReadonlyArray = [...'abcdefghijklmnopqrstuvwxyz']; +const DIGIT_CHARS: ReadonlyArray = [...'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( -- cgit v1.2.3