@@ -25,27 +25,28 @@ export enum Chars {
2525 WordSafe32 = '23456789CFGHJMPQRVWXcfghjmpqrvwx'
2626}
2727
28- export const charsName = ( chars : string ) : string => {
29- if ( chars === Chars . Alpha ) return 'alpha'
30- if ( chars === Chars . AlphaLower ) return 'alphaLower'
31- if ( chars === Chars . AlphaUpper ) return 'alphaUpper'
32- if ( chars === Chars . AlphaNum ) return 'alphaNum'
33- if ( chars === Chars . AlphaNumLower ) return 'alphaNumLower'
34- if ( chars === Chars . AlphaNumUpper ) return 'alphaNumUpper'
35- if ( chars === Chars . Base16 ) return 'base16'
36- if ( chars === Chars . Base32 ) return 'base32'
37- if ( chars === Chars . Base32Hex ) return 'base32Hex'
38- if ( chars === Chars . Base32HexUpper ) return 'base32HexUpper'
39- if ( chars === Chars . Crockford32 ) return 'crockford32'
40- if ( chars === Chars . Hex ) return 'hex'
41- if ( chars === Chars . Safe32 ) return 'safe32'
42- if ( chars === Chars . Safe64 ) return 'safe64'
43- if ( chars === Chars . SafeAscii ) return 'safeAscii'
44- if ( chars === Chars . Symbol ) return 'symbol'
45- if ( chars === Chars . WordSafe32 ) return 'wordSafe32'
46- return 'custom'
28+ const CHARS_NAME_MAP : Record < string , string > = {
29+ [ Chars . Alpha ] : 'alpha' ,
30+ [ Chars . AlphaLower ] : 'alphaLower' ,
31+ [ Chars . AlphaUpper ] : 'alphaUpper' ,
32+ [ Chars . AlphaNum ] : 'alphaNum' ,
33+ [ Chars . AlphaNumLower ] : 'alphaNumLower' ,
34+ [ Chars . AlphaNumUpper ] : 'alphaNumUpper' ,
35+ [ Chars . Base16 ] : 'base16' ,
36+ [ Chars . Base32 ] : 'base32' ,
37+ [ Chars . Base32Hex ] : 'base32Hex' ,
38+ [ Chars . Base32HexUpper ] : 'base32HexUpper' ,
39+ [ Chars . Crockford32 ] : 'crockford32' ,
40+ [ Chars . Hex ] : 'hex' ,
41+ [ Chars . Safe32 ] : 'safe32' ,
42+ [ Chars . Safe64 ] : 'safe64' ,
43+ [ Chars . SafeAscii ] : 'safeAscii' ,
44+ [ Chars . Symbol ] : 'symbol' ,
45+ [ Chars . WordSafe32 ] : 'wordSafe32'
4746}
4847
48+ export const charsName = ( chars : string ) : string => CHARS_NAME_MAP [ chars ] ?? 'custom'
49+
4950const validChar = ( char : string ) : boolean => {
5051 if ( char . codePointAt ( 1 ) ) return false
5152
0 commit comments