ts-ioc-container 55.4.0 → 55.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,6 @@ const ContainerDisposedError_1 = require("../errors/ContainerDisposedError");
6
6
  const MetadataInjector_1 = require("../injector/MetadataInjector");
7
7
  const AliasMap_1 = require("./AliasMap");
8
8
  const DependencyNotFoundError_1 = require("../errors/DependencyNotFoundError");
9
- const ContainerNotFoundError_1 = require("../errors/ContainerNotFoundError");
10
9
  const basic_1 = require("../utils/basic");
11
10
  const array_1 = require("../utils/array");
12
11
  class Container {
@@ -137,15 +136,10 @@ class Container {
137
136
  }
138
137
  getScopeByInstanceOrFail(instance) {
139
138
  this.validateContainer();
140
- const queue = [this];
141
- while (queue.length > 0) {
142
- const scope = queue.shift();
143
- if (scope.hasInstance(instance)) {
144
- return scope;
145
- }
146
- queue.push(...scope.getScopes());
139
+ if (this.hasInstance(instance)) {
140
+ return this;
147
141
  }
148
- throw new ContainerNotFoundError_1.ContainerNotFoundError('Cannot find scope for the given instance');
142
+ return this.parent.getScopeByInstanceOrFail(instance);
149
143
  }
150
144
  removeScope(child) {
151
145
  this.scopes = this.scopes.filter((s) => s !== child);
@@ -3,7 +3,6 @@ import { ContainerDisposedError } from '../errors/ContainerDisposedError';
3
3
  import { MetadataInjector } from '../injector/MetadataInjector';
4
4
  import { AliasMap } from './AliasMap';
5
5
  import { DependencyNotFoundError } from '../errors/DependencyNotFoundError';
6
- import { ContainerNotFoundError } from '../errors/ContainerNotFoundError';
7
6
  import { Is } from '../utils/basic';
8
7
  import { Filter as F } from '../utils/array';
9
8
  export class Container {
@@ -134,15 +133,10 @@ export class Container {
134
133
  }
135
134
  getScopeByInstanceOrFail(instance) {
136
135
  this.validateContainer();
137
- const queue = [this];
138
- while (queue.length > 0) {
139
- const scope = queue.shift();
140
- if (scope.hasInstance(instance)) {
141
- return scope;
142
- }
143
- queue.push(...scope.getScopes());
136
+ if (this.hasInstance(instance)) {
137
+ return this;
144
138
  }
145
- throw new ContainerNotFoundError('Cannot find scope for the given instance');
139
+ return this.parent.getScopeByInstanceOrFail(instance);
146
140
  }
147
141
  removeScope(child) {
148
142
  this.scopes = this.scopes.filter((s) => s !== child);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-ioc-container",
3
- "version": "55.4.0",
3
+ "version": "55.4.1",
4
4
  "description": "Fast, lightweight TypeScript dependency injection container with a clean API, scoped lifecycles, decorators, tokens, hooks, lazy injection, customizable providers, and no global container objects.",
5
5
  "workspaces": [
6
6
  "docs"