ts-ioc-container 56.1.1 → 56.2.0

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.
@@ -63,7 +63,7 @@ class Container {
63
63
  }
64
64
  resolveOneByAlias(alias, { args = [], child = this, lazy } = {}) {
65
65
  this.validateContainer();
66
- const [key, ..._] = this.aliases.getKeysByAlias(alias);
66
+ const [key] = this.aliases.getKeysByAlias(alias);
67
67
  const provider = key ? this.findProviderByKeyOrFail(key) : undefined;
68
68
  return provider?.hasAccess({ invocationScope: child, providerScope: this, args })
69
69
  ? provider.resolve(this, { args, lazy })
@@ -74,7 +74,7 @@ class Container {
74
74
  const scope = new Container({ injector: this.injector, parent: this, tags })
75
75
  .addOnConstructHook(...this.onConstructHookList)
76
76
  .addOnDisposeHook(...this.onDisposeHookList);
77
- for (const registration of [...this.parent.getRegistrations(), ...this.registrations]) {
77
+ for (const registration of this.getRegistrations()) {
78
78
  registration.applyTo(scope);
79
79
  }
80
80
  this.scopes.push(scope);
@@ -89,14 +89,14 @@ class Container {
89
89
  }
90
90
  this.parent.removeScope(this);
91
91
  this.parent = new EmptyContainer_1.EmptyContainer();
92
- for (const [_, provider] of this.providers) {
92
+ for (const provider of this.providers.values()) {
93
93
  provider.dispose();
94
94
  }
95
95
  this.providers.clear();
96
96
  this.aliases.destroy();
97
97
  this.instances = [];
98
98
  this.registrations = [];
99
- this.onConstructHookList.splice(0, this.onConstructHookList.length);
99
+ this.onConstructHookList.length = 0;
100
100
  }
101
101
  addRegistration(registration) {
102
102
  this.registrations.push(registration);
@@ -60,7 +60,7 @@ export class Container {
60
60
  }
61
61
  resolveOneByAlias(alias, { args = [], child = this, lazy } = {}) {
62
62
  this.validateContainer();
63
- const [key, ..._] = this.aliases.getKeysByAlias(alias);
63
+ const [key] = this.aliases.getKeysByAlias(alias);
64
64
  const provider = key ? this.findProviderByKeyOrFail(key) : undefined;
65
65
  return provider?.hasAccess({ invocationScope: child, providerScope: this, args })
66
66
  ? provider.resolve(this, { args, lazy })
@@ -71,7 +71,7 @@ export class Container {
71
71
  const scope = new Container({ injector: this.injector, parent: this, tags })
72
72
  .addOnConstructHook(...this.onConstructHookList)
73
73
  .addOnDisposeHook(...this.onDisposeHookList);
74
- for (const registration of [...this.parent.getRegistrations(), ...this.registrations]) {
74
+ for (const registration of this.getRegistrations()) {
75
75
  registration.applyTo(scope);
76
76
  }
77
77
  this.scopes.push(scope);
@@ -86,14 +86,14 @@ export class Container {
86
86
  }
87
87
  this.parent.removeScope(this);
88
88
  this.parent = new EmptyContainer();
89
- for (const [_, provider] of this.providers) {
89
+ for (const provider of this.providers.values()) {
90
90
  provider.dispose();
91
91
  }
92
92
  this.providers.clear();
93
93
  this.aliases.destroy();
94
94
  this.instances = [];
95
95
  this.registrations = [];
96
- this.onConstructHookList.splice(0, this.onConstructHookList.length);
96
+ this.onConstructHookList.length = 0;
97
97
  }
98
98
  addRegistration(registration) {
99
99
  this.registrations.push(registration);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-ioc-container",
3
- "version": "56.1.1",
3
+ "version": "56.2.0",
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
  "publishConfig": {
6
6
  "access": "public",
@@ -1,14 +1,11 @@
1
1
  export type constructor<T> = new (...args: any[]) => T;
2
- export interface InstanceOfClass<T = unknown> {
3
- new (...args: unknown[]): T;
4
- }
5
2
  export interface Instance<T = unknown> {
6
3
  new (...args: unknown[]): T;
7
4
  }
8
5
  export declare const Is: {
9
6
  nullish: <T>(value: T | undefined | null) => value is null | undefined;
10
7
  object: (target: unknown) => target is object;
11
- instance: (target: unknown) => target is InstanceOfClass;
8
+ instance: (target: unknown) => target is Instance;
12
9
  constructor: (target: unknown) => target is constructor<unknown>;
13
10
  };
14
11
  export declare function resolveConstructor(target: object): object;