export const flatten = ( source , path = [ ] ) : { [ key ] : any ; } => { if ( ! ( source instanceof Object ) ) { return { [ path . join ( '.' ) ] : source , } ; } return Object . keys ( source ) . reduce ( ( result , key ) => { const flattened = flatten ( source [ key ] , [ ... path , key ] ) ; return { ... result , ... flattened , } ; } , { } ) ; } ;