JavaScript Dependency Injection Factory