BaaS_Driver_Android_App/utils/Payments.ts

13 lines
326 B
TypeScript

export const toCamel = (obj: any): any => {
if (Array.isArray(obj)) return obj.map(toCamel);
if (obj && typeof obj === "object") {
return Object.fromEntries(
Object.entries(obj).map(([k, v]) => [
k.replace(/_([a-z])/g, (_, c) => c.toUpperCase()),
toCamel(v),
])
);
}
return obj;
};