@armscye/container 0.4.0 → 0.5.4

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.
package/README.md CHANGED
@@ -23,10 +23,10 @@ yarn add @armscye/container --dev
23
23
  Configures the `Container` to return an instance of `useClass` for a token.
24
24
 
25
25
  ```ts
26
- interface ClassProvider<T = any> {
26
+ interface ClassProvider {
27
27
  provide: ProviderToken;
28
28
 
29
- useClass: NoArgument<T>;
29
+ useClass: NoArgument<any>;
30
30
 
31
31
  shared?: boolean;
32
32
  }
@@ -34,11 +34,11 @@ interface ClassProvider<T = any> {
34
34
 
35
35
  **Properties**
36
36
 
37
- | Property | Description |
38
- | ------------------------- | ------------------------------------------ |
39
- | provide: ProviderToken | A provider token. |
40
- | useClass: NoArgument<any> | A class to instantiate for the `token`. |
41
- | shared?: boolean | When true, the created instance is cached. |
37
+ | Property | Description |
38
+ | --------------------------- | ------------------------------------------ |
39
+ | provide: `ProviderToken` | A provider token. |
40
+ | useClass: `NoArgument<any>` | A class to instantiate for the `token`. |
41
+ | shared?: boolean | When true, the created instance is cached. |
42
42
 
43
43
  ### Container `Interface`
44
44
 
@@ -54,7 +54,7 @@ interface Container {
54
54
 
55
55
  **Methods**
56
56
 
57
- get(token: ProviderToken): T
57
+ #### `get<T>(token: ProviderToken): T`
58
58
 
59
59
  Retrieves an entry from the container based on its provider token.
60
60
 
@@ -70,13 +70,13 @@ _Throws_
70
70
 
71
71
  `Error` if the entry doesn't exist or an error occurs during retrieval.
72
72
 
73
- has(token: ProviderToken): boolean
73
+ #### `has(token: ProviderToken): boolean`
74
74
 
75
75
  Checks whether an entry for a specific provider token exists in the container.
76
76
 
77
77
  _Parameters_
78
78
 
79
- `token`: The unique identifier of the entry to check for.
79
+ - `token`: The unique identifier of the entry to check for.
80
80
 
81
81
  _Returns_
82
82
 
@@ -87,10 +87,10 @@ _Returns_
87
87
  Configures the `Container` to return a value of another `useExisting` token.
88
88
 
89
89
  ```ts
90
- interface ExistingProvider<T = any> {
90
+ interface ExistingProvider {
91
91
  provide: ProviderToken;
92
92
 
93
- useExisting: T;
93
+ useExisting: ProviderToken;
94
94
 
95
95
  shared?: boolean;
96
96
  }
@@ -98,21 +98,21 @@ interface ExistingProvider<T = any> {
98
98
 
99
99
  **Properties**
100
100
 
101
- | Property | Description |
102
- | -------------------------- | ------------------------------------------ |
103
- | provide: ProviderToken | A provider token. |
104
- | useExisting: ProviderToken | Existing `token` to return. |
105
- | shared?: boolean | When true, the created instance is cached. |
101
+ | Property | Description |
102
+ | ---------------------------- | ------------------------------------------ |
103
+ | provide: `ProviderToken` | A provider token. |
104
+ | useExisting: `ProviderToken` | Existing `token` to return. |
105
+ | shared?: boolean | When true, the created instance is cached. |
106
106
 
107
107
  ### FactoryProvider `Interface`
108
108
 
109
109
  Configures the `Container` to return a value by invoking a `useFactory` function.
110
110
 
111
111
  ```ts
112
- interface FactoryProvider<T = any> {
112
+ interface FactoryProvider {
113
113
  provide: ProviderToken;
114
114
 
115
- useFactory: Factory<T>;
115
+ useFactory: Factory<any>;
116
116
 
117
117
  shared?: boolean;
118
118
  }
@@ -120,11 +120,11 @@ interface FactoryProvider<T = any> {
120
120
 
121
121
  **Properties**
122
122
 
123
- | Property | Description |
124
- | ---------------------- | ----------------------------------------------------------------- |
125
- | provide: ProviderToken | A provider token. |
126
- | useFactory: Factory | A factory function to invoke to create an object for the `token`. |
127
- | shared?: boolean | When true, the created instance is cached. |
123
+ | Property | Description |
124
+ | -------------------------- | ----------------------------------------------------------------- |
125
+ | provide: `ProviderToken` | A provider token. |
126
+ | useFactory: `Factory<any>` | A factory function to invoke to create an object for the `token`. |
127
+ | shared?: boolean | When true, the created instance is cached. |
128
128
 
129
129
  ### Factory `Type`
130
130
 
@@ -147,11 +147,11 @@ type ProviderToken = string | symbol;
147
147
  Describes how the `Container` should be configured.
148
148
 
149
149
  ```ts
150
- type Provider<T = any> =
151
- | ValueProvider<T>
152
- | ClassProvider<T>
153
- | FactoryProvider<T>
154
- | ExistingProvider<T>;
150
+ type Provider =
151
+ | ValueProvider
152
+ | ClassProvider
153
+ | FactoryProvider
154
+ | ExistingProvider;
155
155
  ```
156
156
 
157
157
  ### ValueProvider `Interface`
@@ -159,19 +159,19 @@ type Provider<T = any> =
159
159
  Configures the `Container` to return a value for a token.
160
160
 
161
161
  ```ts
162
- interface ValueProvider<T = any> {
162
+ interface ValueProvider {
163
163
  provide: ProviderToken;
164
164
 
165
- useValue: T;
165
+ useValue: any;
166
166
  }
167
167
  ```
168
168
 
169
169
  **Properties**
170
170
 
171
- | Property | Description |
172
- | ---------------------- | ----------------------------------------------------------- |
173
- | provide: ProviderToken | A provider token. |
174
- | useValue: any | The actual value that will be provided for the given token. |
171
+ | Property | Description |
172
+ | ------------------------ | ----------------------------------------------------------- |
173
+ | provide: `ProviderToken` | A provider token. |
174
+ | useValue: any | The actual value that will be provided for the given token. |
175
175
 
176
176
  ## License
177
177
 
@@ -2,7 +2,7 @@ import { ProviderToken } from './provider-token';
2
2
  /**
3
3
  * Configures the `Container` to return a value of another `useExisting` token.
4
4
  */
5
- export interface ExistingProvider<T = any> {
5
+ export interface ExistingProvider {
6
6
  /**
7
7
  * Provider token.
8
8
  */
@@ -10,7 +10,7 @@ export interface ExistingProvider<T = any> {
10
10
  /**
11
11
  * Existing `token` to return.
12
12
  */
13
- useExisting: T;
13
+ useExisting: ProviderToken;
14
14
  /**
15
15
  * Whether the created instance should be cached.
16
16
  */
@@ -3,7 +3,7 @@ import { ProviderToken } from './provider-token';
3
3
  /**
4
4
  * Configures the `Container` to return a value by invoking a `useFactory` function.
5
5
  */
6
- export interface FactoryProvider<T = any> {
6
+ export interface FactoryProvider {
7
7
  /**
8
8
  * Provider token.
9
9
  */
@@ -12,7 +12,7 @@ export interface FactoryProvider<T = any> {
12
12
  * A function to invoke to create an instance for this `token`. The function is
13
13
  * invoked with resolved values of token`s from an instance of the container.
14
14
  */
15
- useFactory: Factory<T>;
15
+ useFactory: Factory<any>;
16
16
  /**
17
17
  * Whether the created instance should be cached.
18
18
  */
@@ -2,4 +2,4 @@ import { ClassProvider } from './class-provider';
2
2
  import { ExistingProvider } from './existing-provider';
3
3
  import { FactoryProvider } from './factory-provider';
4
4
  import { ValueProvider } from './value-provider';
5
- export type Provider<T = any> = ValueProvider<T> | ClassProvider<T> | FactoryProvider<T> | ExistingProvider<T>;
5
+ export type Provider = ValueProvider | ClassProvider | FactoryProvider | ExistingProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@armscye/container",
3
- "version": "0.4.0",
3
+ "version": "0.5.4",
4
4
  "description": "A collection of shared standard TypeScript definitions (@container)",
5
5
  "author": "Augustus Kamau",
6
6
  "license": "MIT",
@@ -15,7 +15,7 @@
15
15
  "container"
16
16
  ],
17
17
  "dependencies": {
18
- "@armscye/core": "^0.3.0"
18
+ "@armscye/core": "^0.4.2"
19
19
  },
20
20
  "homepage": "https://github.com/armscye/armscye#readme",
21
21
  "repository": {
@@ -28,5 +28,5 @@
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "a26e3829ccbd43eae0ab1a1dd165af7ae7b355c1"
31
+ "gitHead": "7c8f94ea75171d4dada09e03df8a49cc9773b357"
32
32
  }