* Gets the index of the given value in the given list of options. * @param cache The cache of indices found so far * @param value The value to find * @return The index of the value in the options list
(cache: Map<T, number>, value: T)
| 941 | * @return The index of the value in the options list |
| 942 | */ |
| 943 | private _getIndexForValue(cache: Map<T, number>, value: T) { |
| 944 | const isEqual = this.compareWith || Object.is; |
| 945 | if (!cache.has(value)) { |
| 946 | let index = -1; |
| 947 | for (let i = 0; i < this.options.length; i++) { |
| 948 | if (isEqual(value, this.options.get(i)!.value)) { |
| 949 | index = i; |
| 950 | break; |
| 951 | } |
| 952 | } |
| 953 | cache.set(value, index); |
| 954 | } |
| 955 | return cache.get(value)!; |
| 956 | } |
| 957 | |
| 958 | /** |
| 959 | * Handle the user clicking an option. |
no test coverage detected