xdash / toEnum
Function: toEnum()
toEnum<
T
,CapitalizeKeys
,CapitalizeValues
>(list
,options
):EnumFromList
<T
,CapitalizeKeys
,CapitalizeValues
>
Converts a list of strings to an enum.
Type parameters
• T extends readonly string
[]
• CapitalizeKeys extends boolean
= true
• CapitalizeValues extends boolean
= false
Parameters
• list: T
list of strings to convert to an enum
• options= {}
options to customize the enum
• options.capitalizeKeys?: CapitalizeKeys
• options.capitalizeValues?: CapitalizeValues
Returns
EnumFromList
<T
, CapitalizeKeys
, CapitalizeValues
>
an enum from the list