ts-ioc-container 32.15.0 → 32.16.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.
|
@@ -60,12 +60,19 @@ class Container {
|
|
|
60
60
|
this.instances.clear();
|
|
61
61
|
this.registrations.splice(0, this.registrations.length);
|
|
62
62
|
}
|
|
63
|
-
getInstances() {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
getInstances(direction = 'child') {
|
|
64
|
+
switch (direction) {
|
|
65
|
+
case 'parent': {
|
|
66
|
+
return [...this.instances.values(), ...this.parent.getInstances('parent')];
|
|
67
|
+
}
|
|
68
|
+
case 'child': {
|
|
69
|
+
const instances = [...this.instances.values()];
|
|
70
|
+
for (const scope of this.scopes) {
|
|
71
|
+
instances.push(...scope.getInstances('child'));
|
|
72
|
+
}
|
|
73
|
+
return instances;
|
|
74
|
+
}
|
|
67
75
|
}
|
|
68
|
-
return instances;
|
|
69
76
|
}
|
|
70
77
|
hasTag(tag) {
|
|
71
78
|
return this.tags.has(tag);
|
|
@@ -57,12 +57,19 @@ export class Container {
|
|
|
57
57
|
this.instances.clear();
|
|
58
58
|
this.registrations.splice(0, this.registrations.length);
|
|
59
59
|
}
|
|
60
|
-
getInstances() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
getInstances(direction = 'child') {
|
|
61
|
+
switch (direction) {
|
|
62
|
+
case 'parent': {
|
|
63
|
+
return [...this.instances.values(), ...this.parent.getInstances('parent')];
|
|
64
|
+
}
|
|
65
|
+
case 'child': {
|
|
66
|
+
const instances = [...this.instances.values()];
|
|
67
|
+
for (const scope of this.scopes) {
|
|
68
|
+
instances.push(...scope.getInstances('child'));
|
|
69
|
+
}
|
|
70
|
+
return instances;
|
|
71
|
+
}
|
|
64
72
|
}
|
|
65
|
-
return instances;
|
|
66
73
|
}
|
|
67
74
|
hasTag(tag) {
|
|
68
75
|
return this.tags.has(tag);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-ioc-container",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.16.0",
|
|
4
4
|
"description": "Typescript IoC container",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"ts-node": "^10.9.1",
|
|
60
60
|
"typescript": "5.4.3"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "35d35987c4c2a08c30a650e4e973083d0019dc51"
|
|
63
63
|
}
|
|
@@ -25,7 +25,7 @@ export declare class Container implements IContainer {
|
|
|
25
25
|
resolve<T>(token: InjectionToken<T>, { args, child, lazy }?: ResolveOptions): T;
|
|
26
26
|
createScope(...tags: Tag[]): Container;
|
|
27
27
|
dispose(): void;
|
|
28
|
-
getInstances(): object[];
|
|
28
|
+
getInstances(direction?: 'parent' | 'child'): object[];
|
|
29
29
|
hasTag(tag: Tag): boolean;
|
|
30
30
|
use(module: IContainerModule): this;
|
|
31
31
|
hasDependency(key: DependencyKey): boolean;
|
|
@@ -35,7 +35,7 @@ export interface IContainer extends Resolvable, Tagged {
|
|
|
35
35
|
register(key: DependencyKey, value: IProvider): this;
|
|
36
36
|
add(registration: IRegistration): this;
|
|
37
37
|
removeScope(child: IContainer): void;
|
|
38
|
-
getInstances(): object[];
|
|
38
|
+
getInstances(direction?: 'parent' | 'child'): object[];
|
|
39
39
|
dispose(): void;
|
|
40
40
|
use(module: IContainerModule): this;
|
|
41
41
|
getRegistrations(): IRegistration[];
|