e22m4u 1 год назад
Родитель
Сommit
de6340f3ac
1 измененных файлов с 6 добавлено и 3 удалено
  1. 6 3
      src/service-container.js

+ 6 - 3
src/service-container.js

@@ -1,3 +1,4 @@
+import {Service} from './service.js';
 import {InvalidArgumentError} from './errors/index.js';
 import {InvalidArgumentError} from './errors/index.js';
 
 
 /**
 /**
@@ -63,7 +64,9 @@ export class ServiceContainer {
     // новый экземпляр
     // новый экземпляр
     if (!service || args.length) {
     if (!service || args.length) {
       service =
       service =
-        ctor.kind === 'Service' ? new ctor(this, ...args) : new ctor(...args);
+        ctor.kind === Service.kind
+          ? new ctor(this, ...args)
+          : new ctor(...args);
       this._services.set(ctor, service);
       this._services.set(ctor, service);
       // instantiates from a factory function
       // instantiates from a factory function
     } else if (typeof service === 'function') {
     } else if (typeof service === 'function') {
@@ -100,7 +103,7 @@ export class ServiceContainer {
         ctor,
         ctor,
       );
       );
     const factory = () =>
     const factory = () =>
-      ctor.kind === 'Service' ? new ctor(this, ...args) : new ctor(...args);
+      ctor.kind === Service.kind ? new ctor(this, ...args) : new ctor(...args);
     this._services.set(ctor, factory);
     this._services.set(ctor, factory);
     return this;
     return this;
   }
   }
@@ -120,7 +123,7 @@ export class ServiceContainer {
         ctor,
         ctor,
       );
       );
     const service =
     const service =
-      ctor.kind === 'Service' ? new ctor(this, ...args) : new ctor(...args);
+      ctor.kind === Service.kind ? new ctor(this, ...args) : new ctor(...args);
     this._services.set(ctor, service);
     this._services.set(ctor, service);
     return this;
     return this;
   }
   }