class InjectorService {
  constructor() {
    this.data = []
  }

  provide(useClass, params = []) {
    const alreadyExist = this.data
      .filter(service => service.useClass === useClass)
      .length > 0

    if (alreadyExist) {
      return
    }

    this.data.push({
      useClass,
      params: params.map(param => {
        if (param.useValue != null || param.useClass != null) {
          return param
        }

        return {
          useClass: param
        }
      })
    })
  }

  get(useClass) {
    const previousInstance = InjectorService.instances.find(instance => instance instanceof useClass)

    if (previousInstance != null) {
      return previousInstance
    }

    const data = this.data.find(data => data.useClass === useClass)

    if (data != null) {
      const Class = data.useClass
      const instance = new Class(...data.params.map(param => {
        if (param.useClass != null) {
          return this.get(param.useClass)
        }

        return param.useValue
      }))

      InjectorService.instances.push(instance)

      return instance
    }

    return null
  }

  static getMainInstance() {
    const previousInstance = InjectorService.instances.find(instance => instance instanceof InjectorService)

    if (previousInstance != null) {
      return previousInstance
    }

    InjectorService.instances.push(new InjectorService())

    return InjectorService.getMainInstance()
  }
}

InjectorService.instances = []

module.exports = exports = { InjectorService }

@@ -59,16 +59,337 @@
 %5B%5D%0A  %7D%0A%0A
+  static getMainInstance() %7B%0A    const previousInstance = InjectorService.instances.find(instance =%3E instance instanceof InjectorService)%0A%0A    if (previousInstance != null) %7B%0A      return previousInstance%0A    %7D%0A%0A    InjectorService.instances.push(new InjectorService())%0A%0A    return InjectorService.getMainInstance()%0A  %7D%0A%0A
   provid
@@ -1430,329 +1430,8 @@
 %0A  %7D
-%0A%0A  static getMainInstance() %7B%0A    const previousInstance = InjectorService.instances.find(instance =%3E instance instanceof InjectorService)%0A%0A    if (previousInstance != null) %7B%0A      return previousInstance%0A    %7D%0A%0A    InjectorService.instances.push(new InjectorService())%0A%0A    return InjectorService.getMainInstance()%0A  %7D
 %0A%7D%0A%0A

Reorganize injector class