Ad
Strings
Code
Diff
  • export const transform = (source: Record<string, any>): Record<string, any> => Object.fromEntries(
        Object.entries(source).map(([ key, value ]) => {
          const match = key.match(/^([^_]+)_(.+)$/)
          if (match) return [ match[1], transform({ [match[2]]: value }) ] 
          return [ key, value ];
          }
        ))
    • export const transform = (source: Record<string, any>): Record<string, any> => {
    • return Object.fromEntries(
    • export const transform = (source: Record<string, any>): Record<string, any> => Object.fromEntries(
    • Object.entries(source).map(([ key, value ]) => {
    • const match = key.match(/^([^_]+)_(.+)$/);
    • if (match) {
    • return [ match[1], transform({ [match[2]]: value }) ];
    • } else {
    • return [ key, value ];
    • const match = key.match(/^([^_]+)_(.+)$/)
    • if (match) return [ match[1], transform({ [match[2]]: value }) ]
    • return [ key, value ];
    • }
    • }),
    • );
    • }
    • ))