export function getKeyForKeypath()

in src/ObjectStoreProviderUtils.ts [90:107]


export function getKeyForKeypath(
  obj: any,
  keyPathRaw: KeyPathType
): KeyType | undefined {
  const keyPathArray = arrayify(keyPathRaw);

  const values = map(keyPathArray, (kp) => getValueForSingleKeypath(obj, kp));
  if (some(values, (val) => isNull(val) || isUndefined(val))) {
    // If any components of the key are null/undefined, then the result is undefined
    return undefined;
  }

  if (!isArray(keyPathRaw)) {
    return values[0];
  } else {
    return values;
  }
}