You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Everything in ts-enum-util related to key validation/comparison is case sensitive, so there's no direct support for what you want to do.
Your solution seems reasonable, unless you test and identify it to be a source of a performance issue. If you need to optimize it, then I would suggest building a lookup object whose keys are the lowercased keys of your enum, and the values are the original keys of the enum (build it once and store it for reuse). Then when you need to perform a case-insensitive conversion from a string to a valid key, you can lowercase the string and do a simple lookup into the object.
I want to get the proper key (mixing upper and lower cases) from a string (lower case).
How can I do without looping through the whole array?
Here is my current implementation. Any better like using
asKeyOrDefault
?The text was updated successfully, but these errors were encountered: