export type Resolver = ( x : any , key : string , obj : object ) => any ; export type ResolverMap = { [ k ] : Resolver | ResolverMap | boolean ; } ; export function resolveWith < T extends { [ k ] : any ; } , V extends { [ k ] : any ; } > ( config = { } , resolvers ) { const result = { } ; for ( const [ key , resolver ] of Object . entries ( resolvers ) ) switch ( typeof resolver ) { case 'function' : result [ key ] = resolver . call ( result , config [ key ] , key , config ) ; break ; case 'object' : result [ key ] = resolveWith ( config [ key ] , resolver ) ; break ; case 'boolean' : if ( resolver ) result [ key ] = config [ key ] ; break ; } return result ; }