ts-lambda-local-dev
Version:
typescript lambda local development server
18 lines (16 loc) • 532 B
text/typescript
export function flattenArraysInJSON(json: Record<string, any>): Record<string, any> {
const flattenedJson = json;
for (const [key, value] of Object.entries(json)) {
if (Array.isArray(value)) {
flattenedJson[key] = value.join(',');
} else if (typeof value === 'object' && value !== null) {
flattenedJson[key] = flattenArraysInJSON(value);
} else {
flattenedJson[key] = value;
}
}
return flattenedJson;
}
export function cloneDeep<T>(obj: T): T {
return JSON.parse(JSON.stringify(obj));
}