revamp template

This commit is contained in:
fro1991
2025-02-01 16:44:51 +07:00
parent c432df568a
commit 276a289580
1212 changed files with 112762 additions and 0 deletions

26
src/utils/Object.ts Normal file
View File

@ -0,0 +1,26 @@
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
});
};