| 54 | * @param target flat target |
| 55 | */ |
| 56 | export function flatObject(target: object): object { |
| 57 | const flatted = {}; |
| 58 | const recurse = (parent: string, target: object) => { |
| 59 | for (const prop in target) { |
| 60 | if (prop) { |
| 61 | const value = target[prop]; |
| 62 | const path = parent ? `${parent}.${prop}` : prop; |
| 63 | if (typeof value === 'object') { |
| 64 | recurse(path, value); |
| 65 | } else { |
| 66 | flatted[path] = value; |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | }; |
| 71 | recurse('', target); |
| 72 | return flatted; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * It's converts a flatted object to a normal object, |