import { anyPass, isEmpty, isNil, reject } from 'ramda'; export function toDots( obj: Record, path = '' ): Record { return Object.entries(obj).reduce((acc, [key, value]) => { if (typeof value === 'object' && value !== null) { return { ...acc, ...toDots(value as Record, `${path}${key}.`), }; } return { ...acc, [`${path}${key}`]: value, }; }, {}); } export const strip = reject(anyPass([isEmpty, isNil])); export function getSafeJson(str: string): T | null { try { return JSON.parse(str); } catch (e) { return null; } }