( currentValue: any, compareValue: any, compareWith?: string | CompareFn | null )
| 8 | * @param compareWith The function or property name to use to compare values. |
| 9 | */ |
| 10 | export const compareOptions = ( |
| 11 | currentValue: any, |
| 12 | compareValue: any, |
| 13 | compareWith?: string | CompareFn | null |
| 14 | ): boolean => { |
| 15 | if (typeof compareWith === 'function') { |
| 16 | return compareWith(currentValue, compareValue); |
| 17 | } else if (typeof compareWith === 'string') { |
| 18 | return currentValue[compareWith] === compareValue[compareWith]; |
| 19 | } else { |
| 20 | return Array.isArray(compareValue) ? compareValue.includes(currentValue) : currentValue === compareValue; |
| 21 | } |
| 22 | }; |
| 23 | |
| 24 | /** |
| 25 | * Compares a value against the current value(s) to determine if it is selected. |
no outgoing calls
no test coverage detected