File tree Expand file tree Collapse file tree 4 files changed +57
-1
lines changed Expand file tree Collapse file tree 4 files changed +57
-1
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## 0.6.1
4
+
5
+ * added ` Container.has ` method
6
+
3
7
## 0.6.0
4
8
5
9
* added multiple containers support
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " typedi" ,
3
- "version" : " 0.6.0 " ,
3
+ "version" : " 0.6.1 " ,
4
4
"description" : " Dependency injection for TypeScript" ,
5
5
"license" : " MIT" ,
6
6
"readmeFilename" : " README.md" ,
Original file line number Diff line number Diff line change @@ -49,6 +49,32 @@ export class Container {
49
49
return container ;
50
50
}
51
51
52
+ /**
53
+ * Checks if the service with given name or type is registered service container.
54
+ * Optionally, parameters can be passed in case if instance is initialized in the container for the first time.
55
+ */
56
+ static has < T > ( type : ObjectType < T > ) : boolean ;
57
+
58
+ /**
59
+ * Checks if the service with given name or type is registered service container.
60
+ * Optionally, parameters can be passed in case if instance is initialized in the container for the first time.
61
+ */
62
+ static has < T > ( id : string ) : boolean ;
63
+
64
+ /**
65
+ * Checks if the service with given name or type is registered service container.
66
+ * Optionally, parameters can be passed in case if instance is initialized in the container for the first time.
67
+ */
68
+ static has < T > ( id : Token < T > ) : boolean ;
69
+
70
+ /**
71
+ * Checks if the service with given name or type is registered service container.
72
+ * Optionally, parameters can be passed in case if instance is initialized in the container for the first time.
73
+ */
74
+ static has < T > ( identifier : ServiceIdentifier ) : boolean {
75
+ return this . globalInstance . has ( identifier as any ) ;
76
+ }
77
+
52
78
/**
53
79
* Retrieves the service with given name or type from the service container.
54
80
* Optionally, parameters can be passed in case if instance is initialized in the container for the first time.
Original file line number Diff line number Diff line change @@ -42,6 +42,32 @@ export class ContainerInstance {
42
42
// Public Methods
43
43
// -------------------------------------------------------------------------
44
44
45
+ /**
46
+ * Checks if the service with given name or type is registered service container.
47
+ * Optionally, parameters can be passed in case if instance is initialized in the container for the first time.
48
+ */
49
+ has < T > ( type : ObjectType < T > ) : boolean ;
50
+
51
+ /**
52
+ * Checks if the service with given name or type is registered service container.
53
+ * Optionally, parameters can be passed in case if instance is initialized in the container for the first time.
54
+ */
55
+ has < T > ( id : string ) : boolean ;
56
+
57
+ /**
58
+ * Checks if the service with given name or type is registered service container.
59
+ * Optionally, parameters can be passed in case if instance is initialized in the container for the first time.
60
+ */
61
+ has < T > ( id : Token < T > ) : boolean ;
62
+
63
+ /**
64
+ * Checks if the service with given name or type is registered service container.
65
+ * Optionally, parameters can be passed in case if instance is initialized in the container for the first time.
66
+ */
67
+ has < T > ( identifier : ServiceIdentifier ) : boolean {
68
+ return ! ! this . findService ( identifier ) ;
69
+ }
70
+
45
71
/**
46
72
* Retrieves the service with given name or type from the service container.
47
73
* Optionally, parameters can be passed in case if instance is initialized in the container for the first time.
You can’t perform that action at this time.
0 commit comments