Function
valueOfChoice
(choice: SelectDefChoice<T>)
Source from the content-addressed store, hash-verified
| 47 | const nameOfChoice = (choice: SelectDefChoice<T>): string => |
| 48 | typeof choice === 'object' ? choice.name : choice.toString() |
| 49 | const valueOfChoice = (choice: SelectDefChoice<T>): T => |
| 50 | (typeof choice === 'number' || typeof choice === 'string' ? choice : choice.value) as T |
| 51 | |
| 52 | const namesByValue = new Map(choices.map(choice => [valueOfChoice(choice), nameOfChoice(choice)])) |
| 53 | |
Tested by
no test coverage detected