export const excludeKeys = (obj: any, keysToExclude: any) => {
  return Object.keys(obj).reduce((filteredObj: any, key) => {
    if (!keysToExclude.includes(key)) {
      filteredObj[key] = obj[key];
    }
    return filteredObj;
  }, {});
};

export const changeValueImmutable = (obj: any, targetKey: any, sourceKey: any) => {
  if (obj.hasOwnProperty(sourceKey)) {
    return { ...obj, [targetKey]: obj[sourceKey] };
  }
  return obj;
  // Example usage:
  // const updatedImmutable = changeValueImmutable(original, 'name', 'location');
};

export const updateKeyValueInArray = (arr: [], targetKey: any, sourceKey: any) => {
  return arr.map((obj: any) => {
    if (obj.hasOwnProperty(sourceKey)) {
      return { ...obj, [targetKey]: obj[sourceKey] };
    }
    return obj; // If sourceKey doesn't exist, return the object unchanged
  });
};
