import { Router } from '../types/router' ; export default function withDependencies < Dependencies > ( dependencies ) { return ( router ) : Router < Dependencies > => { const routerDependencies = dependencies ; router . setDependency = ( dependencyName , dependency ) => { routerDependencies [ dependencyName ] = dependency ; return router ; } ; router . setDependencies = deps => { Object . keys ( deps ) . forEach ( name => router . setDependency ( name , deps [ name ] ) ) ; return router ; } ; router . getDependencies = ( ) => routerDependencies ; router . getInjectables = ( ) => [ router , router . getDependencies ( ) ] ; router . executeFactory = factoryFunction => factoryFunction ( ... router . getInjectables ( ) ) ; return router ; } ; }