MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / compareOptions

Function compareOptions

core/src/utils/forms/compare-with-utils.ts:10–22  ·  view source on GitHub ↗
(
  currentValue: any,
  compareValue: any,
  compareWith?: string | CompareFn | null
)

Source from the content-addressed store, hash-verified

8 * @param compareWith The function or property name to use to compare values.
9 */
10export 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.

Callers 2

textForValueFunction · 0.90
isOptionSelectedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected