Files
medusa-store/packages/admin-ui/ui/src/utils/trim-values.ts
2023-03-03 10:09:16 +01:00

12 lines
292 B
TypeScript

export const trimValues = <T extends object>(obj: T) => {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === "string") {
obj[key] = obj[key].trim()
} else if (obj[key] && obj[key].constructor.name === "Object") {
trimValues(obj[key])
}
})
return obj
}