ditox 2.2.0 → 2.3.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.
package/docs/README.md CHANGED
@@ -8,7 +8,7 @@ ditox
8
8
 
9
9
  - [ResolverError](classes/ResolverError.md)
10
10
 
11
- ### Type aliases
11
+ ### Type Aliases
12
12
 
13
13
  - [BindModuleOptions](README.md#bindmoduleoptions)
14
14
  - [Container](README.md#container)
@@ -33,11 +33,11 @@ ditox
33
33
  - [optional](README.md#optional)
34
34
  - [resolveValue](README.md#resolvevalue)
35
35
  - [resolveValues](README.md#resolvevalues)
36
- - [token](README.md#token)
36
+ - [token](README.md#token-1)
37
37
  - [tryResolveValue](README.md#tryresolvevalue)
38
38
  - [tryResolveValues](README.md#tryresolvevalues)
39
39
 
40
- ## Type aliases
40
+ ## Type Aliases
41
41
 
42
42
  ### BindModuleOptions
43
43
 
@@ -46,20 +46,21 @@ ditox
46
46
  Options for module binding.
47
47
 
48
48
  `scope` types:
49
- - `singleton` - **This is the default**. The module is created and cached by the container which registered the factory.
50
- - `scoped` - The module is created and cached by the container which starts resolving.
49
+
50
+ - `singleton` - **This is the default**. The module is created and cached by the container which registered the factory.
51
+ - `scoped` - The module is created and cached by the container which starts resolving.
51
52
 
52
53
  #### Type declaration
53
54
 
54
- | Name | Type |
55
- | :------ | :------ |
56
- | `scope?` | ``"scoped"`` \| ``"singleton"`` |
55
+ | Name | Type |
56
+ | :------- | :-------------------------- |
57
+ | `scope?` | `"scoped"` \| `"singleton"` |
57
58
 
58
59
  #### Defined in
59
60
 
60
- [packages/ditox/src/modules.ts:76](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/modules.ts#L76)
61
+ [packages/ditox/src/modules.ts:78](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/modules.ts#L78)
61
62
 
62
- ___
63
+ ---
63
64
 
64
65
  ### Container
65
66
 
@@ -69,58 +70,61 @@ Dependency container.
69
70
 
70
71
  #### Type declaration
71
72
 
72
- | Name | Type |
73
- | :------ | :------ |
73
+ | Name | Type |
74
+ | :------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
74
75
  | `bindFactory` | <T\>(`token`: [`Token`](README.md#token)<`T`\>, `factory`: (`container`: [`Container`](README.md#container)) => `T`, `options?`: [`FactoryOptions`](README.md#factoryoptions)<`T`\>) => `void` |
75
- | `bindValue` | <T\>(`token`: [`Token`](README.md#token)<`T`\>, `value`: `T`) => `void` |
76
- | `get` | <T\>(`token`: [`Token`](README.md#token)<`T`\>) => `undefined` \| `T` |
77
- | `hasToken` | (`token`: [`Token`](README.md#token)<`unknown`\>) => `boolean` |
78
- | `remove` | <T\>(`token`: [`Token`](README.md#token)<`T`\>) => `void` |
79
- | `removeAll` | () => `void` |
80
- | `resolve` | <T\>(`token`: [`Token`](README.md#token)<`T`\>) => `T` |
76
+ | `bindValue` | <T\>(`token`: [`Token`](README.md#token)<`T`\>, `value`: `T`) => `void` |
77
+ | `get` | <T\>(`token`: [`Token`](README.md#token)<`T`\>) => `undefined` \| `T` |
78
+ | `hasToken` | (`token`: [`Token`](README.md#token)<`unknown`\>) => `boolean` |
79
+ | `remove` | <T\>(`token`: [`Token`](README.md#token)<`T`\>) => `void` |
80
+ | `removeAll` | () => `void` |
81
+ | `resolve` | <T\>(`token`: [`Token`](README.md#token)<`T`\>) => `T` |
81
82
 
82
83
  #### Defined in
83
84
 
84
- [packages/ditox/src/ditox.ts:95](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/ditox.ts#L95)
85
+ [packages/ditox/src/ditox.ts:95](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/ditox.ts#L95)
85
86
 
86
- ___
87
+ ---
87
88
 
88
89
  ### FactoryOptions
89
90
 
90
- Ƭ **FactoryOptions**<`T`\>: { `scope?`: ``"scoped"`` \| ``"singleton"`` ; `onRemoved?`: (`value`: `T`) => `void` } \| { `scope`: ``"transient"`` }
91
+ Ƭ **FactoryOptions**<`T`\>: { `onRemoved?`: (`value`: `T`) => `void` ; `scope?`: `"scoped"` \| `"singleton"` } \| { `scope`: `"transient"` }
91
92
 
92
93
  Options for factory binding.
93
94
 
94
95
  `scope` types:
95
- - `singleton` - **This is the default**. The value is created and cached by the container which registered the factory.
96
- - `scoped` - The value is created and cached by the container which starts resolving.
97
- - `transient` - The value is created every time it is resolved.
96
+
97
+ - `singleton` - **This is the default**. The value is created and cached by the container which registered the factory.
98
+ - `scoped` - The value is created and cached by the container which starts resolving.
99
+ - `transient` - The value is created every time it is resolved.
98
100
 
99
101
  `scoped` and `singleton` scopes can have `onRemoved` callback. It is called when a token is removed from the container.
100
102
 
101
103
  #### Type parameters
102
104
 
103
105
  | Name |
104
- | :------ |
105
- | `T` |
106
+ | :--- |
107
+ | `T` |
106
108
 
107
109
  #### Defined in
108
110
 
109
- [packages/ditox/src/ditox.ts:83](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/ditox.ts#L83)
111
+ [packages/ditox/src/ditox.ts:83](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/ditox.ts#L83)
110
112
 
111
- ___
113
+ ---
112
114
 
113
115
  ### FactoryScope
114
116
 
115
- Ƭ **FactoryScope**: ``"scoped"`` \| ``"singleton"`` \| ``"transient"``
117
+ Ƭ **FactoryScope**: `"scoped"` \| `"singleton"` \| `"transient"`
116
118
 
117
- **`see`** https://github.com/mnasyrov/ditox#factory-lifetimes
119
+ **`See`**
120
+
121
+ https://github.com/mnasyrov/ditox#factory-lifetimes
118
122
 
119
123
  #### Defined in
120
124
 
121
- [packages/ditox/src/ditox.ts:71](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/ditox.ts#L71)
125
+ [packages/ditox/src/ditox.ts:71](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/ditox.ts#L71)
122
126
 
123
- ___
127
+ ---
124
128
 
125
129
  ### Module
126
130
 
@@ -128,7 +132,8 @@ ___
128
132
 
129
133
  Dependency module
130
134
 
131
- **`example`**
135
+ **`Example`**
136
+
132
137
  ```ts
133
138
  type LoggerModule = Module<{
134
139
  logger: Logger;
@@ -137,25 +142,25 @@ type LoggerModule = Module<{
137
142
 
138
143
  #### Type parameters
139
144
 
140
- | Name | Type |
141
- | :------ | :------ |
145
+ | Name | Type |
146
+ | :------------ | :---------------------------------- |
142
147
  | `ModuleProps` | extends `AnyObject` = `EmptyObject` |
143
148
 
144
149
  #### Defined in
145
150
 
146
- [packages/ditox/src/modules.ts:22](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/modules.ts#L22)
151
+ [packages/ditox/src/modules.ts:22](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/modules.ts#L22)
147
152
 
148
- ___
153
+ ---
149
154
 
150
155
  ### ModuleBindingEntry
151
156
 
152
- Ƭ **ModuleBindingEntry**: [`ModuleDeclaration`](README.md#moduledeclaration)<`AnyObject`\> \| { `module`: [`ModuleDeclaration`](README.md#moduledeclaration)<`AnyObject`\> ; `options`: [`BindModuleOptions`](README.md#bindmoduleoptions) }
157
+ Ƭ **ModuleBindingEntry**: [`ModuleDeclaration`](README.md#moduledeclaration)<`AnyObject`\> \| { `module`: [`ModuleDeclaration`](README.md#moduledeclaration)<`AnyObject`\> ; `options`: [`BindModuleOptions`](README.md#bindmoduleoptions) }
153
158
 
154
159
  #### Defined in
155
160
 
156
- [packages/ditox/src/modules.ts:80](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/modules.ts#L80)
161
+ [packages/ditox/src/modules.ts:82](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/modules.ts#L82)
157
162
 
158
- ___
163
+ ---
159
164
 
160
165
  ### ModuleDeclaration
161
166
 
@@ -163,16 +168,17 @@ ___
163
168
 
164
169
  Description how to bind the module in declarative way.
165
170
 
166
- **`example`**
171
+ **`Example`**
172
+
167
173
  ```ts
168
174
  const LOGGER_MODULE: ModuleDeclaration<LoggerModule> = {
169
175
  token: LOGGER_MODULE_TOKEN,
170
176
  factory: (container) => {
171
177
  const transport = container.resolve(TRANSPORT_TOKEN).open();
172
178
  return {
173
- logger: { log: (message) => transport.write(message) },
179
+ logger: {log: (message) => transport.write(message)},
174
180
  destroy: () => transport.close(),
175
- }
181
+ };
176
182
  },
177
183
  exports: {
178
184
  logger: LOGGER_TOKEN,
@@ -182,26 +188,26 @@ const LOGGER_MODULE: ModuleDeclaration<LoggerModule> = {
182
188
 
183
189
  #### Type parameters
184
190
 
185
- | Name | Type |
186
- | :------ | :------ |
187
- | `T` | extends [`Module`](README.md#module)<`AnyObject`\> |
191
+ | Name | Type |
192
+ | :--- | :------------------------------------------------- |
193
+ | `T` | extends [`Module`](README.md#module)<`AnyObject`\> |
188
194
 
189
195
  #### Type declaration
190
196
 
191
- | Name | Type | Description |
192
- | :------ | :------ | :------ |
193
- | `exports?` | { [K in keyof GetModuleProps<T\>]?: Token<GetModuleProps<T\>[K]\> } | Dictionary of module properties which are bound to tokens. |
194
- | `imports?` | `ReadonlyArray`<[`ModuleBindingEntry`](README.md#modulebindingentry)\> | Modules for binding |
195
- | `token` | [`Token`](README.md#token)<`T`\> | Token for the module |
196
- | `afterBinding?` | (`container`: [`Container`](README.md#container)) => `void` | Callback could be used to export complex dependencies from the module. It is called after binding the module. |
197
- | `beforeBinding?` | (`container`: [`Container`](README.md#container)) => `void` | Callback could be used to prepare an environment. It is called before binding the module. |
198
- | `factory` | (`container`: [`Container`](README.md#container)) => `T` | Factory of the module |
197
+ | Name | Type | Description |
198
+ | :--------------- | :--------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------ |
199
+ | `afterBinding?` | (`container`: [`Container`](README.md#container)) => `void` | Callback could be used to export complex dependencies from the module. It is called after binding the module. |
200
+ | `beforeBinding?` | (`container`: [`Container`](README.md#container)) => `void` | Callback could be used to prepare an environment. It is called before binding the module. |
201
+ | `exports?` | { [K in keyof GetModuleProps<T\>]?: Token<GetModuleProps<T\>[K]\> } | Dictionary of module properties which are bound to tokens. |
202
+ | `factory` | (`container`: [`Container`](README.md#container)) => `T` | Factory of the module |
203
+ | `imports?` | `ReadonlyArray`<[`ModuleBindingEntry`](README.md#modulebindingentry)\> | Modules for binding |
204
+ | `token` | [`Token`](README.md#token)<`T`\> | Token for the module |
199
205
 
200
206
  #### Defined in
201
207
 
202
- [packages/ditox/src/modules.ts:47](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/modules.ts#L47)
208
+ [packages/ditox/src/modules.ts:47](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/modules.ts#L47)
203
209
 
204
- ___
210
+ ---
205
211
 
206
212
  ### Token
207
213
 
@@ -212,12 +218,12 @@ Binding token.
212
218
  #### Type parameters
213
219
 
214
220
  | Name |
215
- | :------ |
216
- | `T` |
221
+ | :--- |
222
+ | `T` |
217
223
 
218
224
  #### Defined in
219
225
 
220
- [packages/ditox/src/ditox.ts:25](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/ditox.ts#L25)
226
+ [packages/ditox/src/ditox.ts:25](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/ditox.ts#L25)
221
227
 
222
228
  ## Functions
223
229
 
@@ -227,24 +233,25 @@ Binding token.
227
233
 
228
234
  Binds the dependency module to the container
229
235
 
230
- **`example`**
236
+ **`Example`**
237
+
231
238
  ```ts
232
239
  bindModule(container, LOGGER_MODULE);
233
240
  ```
234
241
 
235
242
  #### Type parameters
236
243
 
237
- | Name | Type |
238
- | :------ | :------ |
239
- | `T` | extends [`Module`](README.md#module)<`AnyObject`\> |
244
+ | Name | Type |
245
+ | :--- | :------------------------------------------------- |
246
+ | `T` | extends [`Module`](README.md#module)<`AnyObject`\> |
240
247
 
241
248
  #### Parameters
242
249
 
243
- | Name | Type | Description |
244
- | :------ | :------ | :------ |
245
- | `container` | [`Container`](README.md#container) | Dependency container. |
250
+ | Name | Type | Description |
251
+ | :------------------ | :------------------------------------------------------- | :------------------------------------ |
252
+ | `container` | [`Container`](README.md#container) | Dependency container. |
246
253
  | `moduleDeclaration` | [`ModuleDeclaration`](README.md#moduledeclaration)<`T`\> | Declaration of the dependency module. |
247
- | `options?` | [`BindModuleOptions`](README.md#bindmoduleoptions) | Options for module binding. |
254
+ | `options?` | [`BindModuleOptions`](README.md#bindmoduleoptions) | Options for module binding. |
248
255
 
249
256
  #### Returns
250
257
 
@@ -252,9 +259,9 @@ bindModule(container, LOGGER_MODULE);
252
259
 
253
260
  #### Defined in
254
261
 
255
- [packages/ditox/src/modules.ts:98](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/modules.ts#L98)
262
+ [packages/ditox/src/modules.ts:100](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/modules.ts#L100)
256
263
 
257
- ___
264
+ ---
258
265
 
259
266
  ### bindModules
260
267
 
@@ -264,10 +271,10 @@ Binds dependency modules to the container
264
271
 
265
272
  #### Parameters
266
273
 
267
- | Name | Type | Description |
268
- | :------ | :------ | :------ |
269
- | `container` | [`Container`](README.md#container) | Dependency container for binding |
270
- | `modules` | readonly [`ModuleBindingEntry`](README.md#modulebindingentry)[] | Array of module binding entries: module declaration or `{module: ModuleDeclaration, options: BindModuleOptions}` objects. |
274
+ | Name | Type | Description |
275
+ | :---------- | :-------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------ |
276
+ | `container` | [`Container`](README.md#container) | Dependency container for binding |
277
+ | `modules` | readonly [`ModuleBindingEntry`](README.md#modulebindingentry)[] | Array of module binding entries: module declaration or `{module: ModuleDeclaration, options: BindModuleOptions}` objects. |
271
278
 
272
279
  #### Returns
273
280
 
@@ -275,9 +282,9 @@ Binds dependency modules to the container
275
282
 
276
283
  #### Defined in
277
284
 
278
- [packages/ditox/src/modules.ts:159](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/modules.ts#L159)
285
+ [packages/ditox/src/modules.ts:161](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/modules.ts#L161)
279
286
 
280
- ___
287
+ ---
281
288
 
282
289
  ### bindMultiValue
283
290
 
@@ -288,16 +295,16 @@ Rebinds the array by the token with added new value.
288
295
  #### Type parameters
289
296
 
290
297
  | Name |
291
- | :------ |
292
- | `T` |
298
+ | :--- |
299
+ | `T` |
293
300
 
294
301
  #### Parameters
295
302
 
296
- | Name | Type | Description |
297
- | :------ | :------ | :------ |
298
- | `container` | [`Container`](README.md#container) | Dependency container. |
299
- | `token` | [`Token`](README.md#token)<readonly `T`[]\> | Token for an array of values. |
300
- | `value` | `T` | New value which is added to the end of the array. |
303
+ | Name | Type | Description |
304
+ | :---------- | :------------------------------------------ | :------------------------------------------------ |
305
+ | `container` | [`Container`](README.md#container) | Dependency container. |
306
+ | `token` | [`Token`](README.md#token)<readonly `T`[]\> | Token for an array of values. |
307
+ | `value` | `T` | New value which is added to the end of the array. |
301
308
 
302
309
  #### Returns
303
310
 
@@ -305,9 +312,9 @@ Rebinds the array by the token with added new value.
305
312
 
306
313
  #### Defined in
307
314
 
308
- [packages/ditox/src/utils.ts:27](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/utils.ts#L27)
315
+ [packages/ditox/src/utils.ts:27](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/utils.ts#L27)
309
316
 
310
- ___
317
+ ---
311
318
 
312
319
  ### createContainer
313
320
 
@@ -319,8 +326,8 @@ Container can have an optional parent to chain token resolution. The parent is u
319
326
 
320
327
  #### Parameters
321
328
 
322
- | Name | Type | Description |
323
- | :------ | :------ | :------ |
329
+ | Name | Type | Description |
330
+ | :----------------- | :--------------------------------- | :------------------------- |
324
331
  | `parentContainer?` | [`Container`](README.md#container) | Optional parent container. |
325
332
 
326
333
  #### Returns
@@ -329,9 +336,9 @@ Container can have an optional parent to chain token resolution. The parent is u
329
336
 
330
337
  #### Defined in
331
338
 
332
- [packages/ditox/src/ditox.ts:204](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/ditox.ts#L204)
339
+ [packages/ditox/src/ditox.ts:204](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/ditox.ts#L204)
333
340
 
334
- ___
341
+ ---
335
342
 
336
343
  ### declareModule
337
344
 
@@ -339,15 +346,16 @@ ___
339
346
 
340
347
  Declares a module binding
341
348
 
342
- **`example`**
349
+ **`Example`**
350
+
343
351
  ```ts
344
352
  const LOGGER_MODULE = declareModule<LoggerModule>({
345
353
  factory: (container) => {
346
354
  const transport = container.resolve(TRANSPORT_TOKEN).open();
347
355
  return {
348
- logger: { log: (message) => transport.write(message) },
356
+ logger: {log: (message) => transport.write(message)},
349
357
  destroy: () => transport.close(),
350
- }
358
+ };
351
359
  },
352
360
  exports: {
353
361
  logger: LOGGER_TOKEN,
@@ -357,15 +365,15 @@ const LOGGER_MODULE = declareModule<LoggerModule>({
357
365
 
358
366
  #### Type parameters
359
367
 
360
- | Name |
361
- | :------ |
362
- | `T` |
368
+ | Name | Type |
369
+ | :--- | :------------------------------------------------- |
370
+ | `T` | extends [`Module`](README.md#module)<`AnyObject`\> |
363
371
 
364
372
  #### Parameters
365
373
 
366
- | Name | Type | Description |
367
- | :------ | :------ | :------ |
368
- | `declaration` | `Omit`<[`ModuleDeclaration`](README.md#moduledeclaration)<`T`\>, ``"token"``\> & `Partial`<`Pick`<[`ModuleDeclaration`](README.md#moduledeclaration)<`T`\>, ``"token"``\>\> | a module declaration |
374
+ | Name | Type | Description |
375
+ | :------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------- |
376
+ | `declaration` | `Omit`<[`ModuleDeclaration`](README.md#moduledeclaration)<`T`\>, `"token"`\> & `Partial`<`Pick`<[`ModuleDeclaration`](README.md#moduledeclaration)<`T`\>, `"token"`\>\> | a module declaration |
369
377
 
370
378
  #### Returns
371
379
 
@@ -373,9 +381,9 @@ const LOGGER_MODULE = declareModule<LoggerModule>({
373
381
 
374
382
  #### Defined in
375
383
 
376
- [packages/ditox/src/modules.ts:194](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/modules.ts#L194)
384
+ [packages/ditox/src/modules.ts:196](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/modules.ts#L196)
377
385
 
378
- ___
386
+ ---
379
387
 
380
388
  ### declareModuleBindings
381
389
 
@@ -385,8 +393,8 @@ Declares bindings of several modules
385
393
 
386
394
  #### Parameters
387
395
 
388
- | Name | Type | Description |
389
- | :------ | :------ | :------ |
396
+ | Name | Type | Description |
397
+ | :-------- | :-------------------------------------------------------------- | :------------------------- |
390
398
  | `modules` | readonly [`ModuleBindingEntry`](README.md#modulebindingentry)[] | module declaration entries |
391
399
 
392
400
  #### Returns
@@ -395,13 +403,13 @@ Declares bindings of several modules
395
403
 
396
404
  #### Defined in
397
405
 
398
- [packages/ditox/src/modules.ts:206](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/modules.ts#L206)
406
+ [packages/ditox/src/modules.ts:208](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/modules.ts#L208)
399
407
 
400
- ___
408
+ ---
401
409
 
402
410
  ### injectable
403
411
 
404
- ▸ **injectable**<`Tokens`, `Values`, `Result`\>(`factory`, ...`tokens`): (`container`: [`Container`](README.md#container)) => `Result`
412
+ ▸ **injectable**<`Tokens`, `Values`, `Result`\>(`this`, `factory`, `...tokens`): (`container`: [`Container`](README.md#container)) => `Result`
405
413
 
406
414
  Decorates a factory by passing resolved values as factory arguments.
407
415
 
@@ -410,18 +418,19 @@ then returns an object containing resolved values as properties.
410
418
 
411
419
  #### Type parameters
412
420
 
413
- | Name | Type |
414
- | :------ | :------ |
415
- | `Tokens` | extends ([`Token`](README.md#token)<`unknown`\> \| { [key: string]: [`Token`](README.md#token)<`unknown`\>; })[] |
421
+ | Name | Type |
422
+ | :------- | :------------------------------------------------------------------------------------------------------------------------------------ |
423
+ | `Tokens` | extends ([`Token`](README.md#token)<`unknown`\> \| { `[key: string]`: [`Token`](README.md#token)<`unknown`\>; })[] |
416
424
  | `Values` | extends { [K in string \| number \| symbol]: Tokens[K] extends Token<V\> ? V : Tokens[K] extends TokenProps<Props\> ? Props : never } |
417
- | `Result` | `Result` |
425
+ | `Result` | `Result` |
418
426
 
419
427
  #### Parameters
420
428
 
421
- | Name | Type | Description |
422
- | :------ | :------ | :------ |
423
- | `factory` | (...`params`: `Values`) => `Result` | A factory. |
424
- | `...tokens` | `Tokens` | Tokens which correspond to factory arguments. |
429
+ | Name | Type | Description |
430
+ | :---------- | :---------------------------------- | :-------------------------------------------- |
431
+ | `this` | `unknown` | - |
432
+ | `factory` | (...`params`: `Values`) => `Result` | A factory. |
433
+ | `...tokens` | `Tokens` | Tokens which correspond to factory arguments. |
425
434
 
426
435
  #### Returns
427
436
 
@@ -431,32 +440,25 @@ Decorated factory which takes a dependency container as a single argument.
431
440
 
432
441
  ▸ (`container`): `Result`
433
442
 
434
- Decorates a factory by passing resolved values as factory arguments.
435
-
436
- If an argument is an object which has tokens as its properties,
437
- then returns an object containing resolved values as properties.
438
-
439
443
  ##### Parameters
440
444
 
441
- | Name | Type |
442
- | :------ | :------ |
445
+ | Name | Type |
446
+ | :---------- | :--------------------------------- |
443
447
  | `container` | [`Container`](README.md#container) |
444
448
 
445
449
  ##### Returns
446
450
 
447
451
  `Result`
448
452
 
449
- Decorated factory which takes a dependency container as a single argument.
450
-
451
453
  #### Defined in
452
454
 
453
- [packages/ditox/src/utils.ts:178](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/utils.ts#L178)
455
+ [packages/ditox/src/utils.ts:178](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/utils.ts#L178)
454
456
 
455
- ___
457
+ ---
456
458
 
457
459
  ### injectableClass
458
460
 
459
- ▸ **injectableClass**<`Tokens`, `Values`, `Result`\>(`constructor`, ...`tokens`): (`container`: [`Container`](README.md#container)) => `Result`
461
+ ▸ **injectableClass**<`Tokens`, `Values`, `Result`\>(`this`, `constructor`, `...tokens`): (`container`: [`Container`](README.md#container)) => `Result`
460
462
 
461
463
  Decorates a class by passing resolved values as arguments to its constructor.
462
464
 
@@ -465,18 +467,19 @@ then returns an object containing resolved values as properties.
465
467
 
466
468
  #### Type parameters
467
469
 
468
- | Name | Type |
469
- | :------ | :------ |
470
- | `Tokens` | extends ([`Token`](README.md#token)<`unknown`\> \| { [key: string]: [`Token`](README.md#token)<`unknown`\>; })[] |
470
+ | Name | Type |
471
+ | :------- | :------------------------------------------------------------------------------------------------------------------------------------ |
472
+ | `Tokens` | extends ([`Token`](README.md#token)<`unknown`\> \| { `[key: string]`: [`Token`](README.md#token)<`unknown`\>; })[] |
471
473
  | `Values` | extends { [K in string \| number \| symbol]: Tokens[K] extends Token<V\> ? V : Tokens[K] extends TokenProps<Props\> ? Props : never } |
472
- | `Result` | `Result` |
474
+ | `Result` | `Result` |
473
475
 
474
476
  #### Parameters
475
477
 
476
- | Name | Type | Description |
477
- | :------ | :------ | :------ |
478
- | `constructor` | (...`params`: `Values`) => `Result` | Constructor of a class |
479
- | `...tokens` | `Tokens` | Tokens which correspond to constructor arguments |
478
+ | Name | Type | Description |
479
+ | :------------ | :---------------------------------- | :----------------------------------------------- |
480
+ | `this` | `unknown` | - |
481
+ | `constructor` | (...`params`: `Values`) => `Result` | Constructor of a class |
482
+ | `...tokens` | `Tokens` | Tokens which correspond to constructor arguments |
480
483
 
481
484
  #### Returns
482
485
 
@@ -487,29 +490,21 @@ and returns a new created class.
487
490
 
488
491
  ▸ (`container`): `Result`
489
492
 
490
- Decorates a class by passing resolved values as arguments to its constructor.
491
-
492
- If an argument is an object which has tokens as its properties,
493
- then returns an object containing resolved values as properties.
494
-
495
493
  ##### Parameters
496
494
 
497
- | Name | Type |
498
- | :------ | :------ |
495
+ | Name | Type |
496
+ | :---------- | :--------------------------------- |
499
497
  | `container` | [`Container`](README.md#container) |
500
498
 
501
499
  ##### Returns
502
500
 
503
501
  `Result`
504
502
 
505
- A factory function which takes a dependency container as a single argument
506
- and returns a new created class.
507
-
508
503
  #### Defined in
509
504
 
510
- [packages/ditox/src/utils.ts:211](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/utils.ts#L211)
505
+ [packages/ditox/src/utils.ts:211](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/utils.ts#L211)
511
506
 
512
- ___
507
+ ---
513
508
 
514
509
  ### isToken
515
510
 
@@ -520,13 +515,13 @@ Checks if a value is the token
520
515
  #### Type parameters
521
516
 
522
517
  | Name |
523
- | :------ |
524
- | `T` |
518
+ | :--- |
519
+ | `T` |
525
520
 
526
521
  #### Parameters
527
522
 
528
- | Name | Type |
529
- | :------ | :------ |
523
+ | Name | Type |
524
+ | :------ | :-------- |
530
525
  | `value` | `unknown` |
531
526
 
532
527
  #### Returns
@@ -535,9 +530,9 @@ value is Token<T\>
535
530
 
536
531
  #### Defined in
537
532
 
538
- [packages/ditox/src/utils.ts:11](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/utils.ts#L11)
533
+ [packages/ditox/src/utils.ts:11](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/utils.ts#L11)
539
534
 
540
- ___
535
+ ---
541
536
 
542
537
  ### optional
543
538
 
@@ -549,15 +544,15 @@ This value is be used as default value in case a container does not have registe
549
544
  #### Type parameters
550
545
 
551
546
  | Name |
552
- | :------ |
553
- | `T` |
547
+ | :--- |
548
+ | `T` |
554
549
 
555
550
  #### Parameters
556
551
 
557
- | Name | Type | Description |
558
- | :------ | :------ | :------ |
559
- | `token` | [`Token`](README.md#token)<`T`\> | Existed token. |
560
- | `optionalValue` | `T` | Default value for the resolver. |
552
+ | Name | Type | Description |
553
+ | :-------------- | :------------------------------- | :------------------------------ |
554
+ | `token` | [`Token`](README.md#token)<`T`\> | Existed token. |
555
+ | `optionalValue` | `T` | Default value for the resolver. |
561
556
 
562
557
  #### Returns
563
558
 
@@ -565,20 +560,20 @@ This value is be used as default value in case a container does not have registe
565
560
 
566
561
  #### Defined in
567
562
 
568
- [packages/ditox/src/ditox.ts:41](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/ditox.ts#L41)
563
+ [packages/ditox/src/ditox.ts:41](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/ditox.ts#L41)
569
564
 
570
565
  ▸ **optional**<`T`\>(`token`): `OptionalToken`<`T` \| `undefined`\>
571
566
 
572
567
  #### Type parameters
573
568
 
574
569
  | Name |
575
- | :------ |
576
- | `T` |
570
+ | :--- |
571
+ | `T` |
577
572
 
578
573
  #### Parameters
579
574
 
580
- | Name | Type |
581
- | :------ | :------ |
575
+ | Name | Type |
576
+ | :------ | :------------------------------- |
582
577
  | `token` | [`Token`](README.md#token)<`T`\> |
583
578
 
584
579
  #### Returns
@@ -587,9 +582,9 @@ This value is be used as default value in case a container does not have registe
587
582
 
588
583
  #### Defined in
589
584
 
590
- [packages/ditox/src/ditox.ts:45](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/ditox.ts#L45)
585
+ [packages/ditox/src/ditox.ts:45](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/ditox.ts#L45)
591
586
 
592
- ___
587
+ ---
593
588
 
594
589
  ### resolveValue
595
590
 
@@ -602,7 +597,8 @@ then returns an object containing resolved values as properties.
602
597
 
603
598
  If a value is not found by the token, then `ResolverError` is thrown.
604
599
 
605
- **`example`**
600
+ **`Example`**
601
+
606
602
  ```ts
607
603
  const value = resolveValue(container, tokenA);
608
604
  console.log(value); // 1
@@ -613,17 +609,17 @@ console.log(props); // {a: 1, b: 2}
613
609
 
614
610
  #### Type parameters
615
611
 
616
- | Name | Type |
617
- | :------ | :------ |
618
- | `Tokens` | extends [`Token`](README.md#token)<`unknown`\> \| { [key: string]: [`Token`](README.md#token)<`unknown`\>; } |
619
- | `Values` | extends `unknown` |
612
+ | Name | Type |
613
+ | :------- | :------------------------------------------------------------------------------------------------------------- |
614
+ | `Tokens` | extends [`Token`](README.md#token)<`unknown`\> \| { `[key: string]`: [`Token`](README.md#token)<`unknown`\>; } |
615
+ | `Values` | extends `unknown` |
620
616
 
621
617
  #### Parameters
622
618
 
623
- | Name | Type |
624
- | :------ | :------ |
619
+ | Name | Type |
620
+ | :---------- | :--------------------------------- |
625
621
  | `container` | [`Container`](README.md#container) |
626
- | `token` | `Tokens` |
622
+ | `token` | `Tokens` |
627
623
 
628
624
  #### Returns
629
625
 
@@ -631,13 +627,13 @@ console.log(props); // {a: 1, b: 2}
631
627
 
632
628
  #### Defined in
633
629
 
634
- [packages/ditox/src/utils.ts:118](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/utils.ts#L118)
630
+ [packages/ditox/src/utils.ts:118](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/utils.ts#L118)
635
631
 
636
- ___
632
+ ---
637
633
 
638
634
  ### resolveValues
639
635
 
640
- ▸ **resolveValues**<`Tokens`, `Values`\>(`container`, ...`tokens`): `Values`
636
+ ▸ **resolveValues**<`Tokens`, `Values`\>(`container`, `...tokens`): `Values`
641
637
 
642
638
  Returns an array of resolved values or objects with resolved values.
643
639
 
@@ -646,7 +642,8 @@ then returns an object containing resolved values as properties.
646
642
 
647
643
  If a token is not found, then `ResolverError` is thrown.
648
644
 
649
- **`example`**
645
+ **`Example`**
646
+
650
647
  ```ts
651
648
  const items1 = resolveValues(container, tokenA);
652
649
  console.log(items1); // [1]
@@ -657,17 +654,17 @@ console.log(items2); // [1, {a: 1, b: 2}]
657
654
 
658
655
  #### Type parameters
659
656
 
660
- | Name | Type |
661
- | :------ | :------ |
662
- | `Tokens` | extends ([`Token`](README.md#token)<`unknown`\> \| { [key: string]: [`Token`](README.md#token)<`unknown`\>; })[] |
657
+ | Name | Type |
658
+ | :------- | :------------------------------------------------------------------------------------------------------------------------------------ |
659
+ | `Tokens` | extends ([`Token`](README.md#token)<`unknown`\> \| { `[key: string]`: [`Token`](README.md#token)<`unknown`\>; })[] |
663
660
  | `Values` | extends { [K in string \| number \| symbol]: Tokens[K] extends Token<V\> ? V : Tokens[K] extends TokenProps<Props\> ? Props : never } |
664
661
 
665
662
  #### Parameters
666
663
 
667
- | Name | Type |
668
- | :------ | :------ |
664
+ | Name | Type |
665
+ | :---------- | :--------------------------------- |
669
666
  | `container` | [`Container`](README.md#container) |
670
- | `...tokens` | `Tokens` |
667
+ | `...tokens` | `Tokens` |
671
668
 
672
669
  #### Returns
673
670
 
@@ -675,9 +672,9 @@ console.log(items2); // [1, {a: 1, b: 2}]
675
672
 
676
673
  #### Defined in
677
674
 
678
- [packages/ditox/src/utils.ts:154](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/utils.ts#L154)
675
+ [packages/ditox/src/utils.ts:154](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/utils.ts#L154)
679
676
 
680
- ___
677
+ ---
681
678
 
682
679
  ### token
683
680
 
@@ -688,13 +685,13 @@ Creates a new binding token.
688
685
  #### Type parameters
689
686
 
690
687
  | Name |
691
- | :------ |
692
- | `T` |
688
+ | :--- |
689
+ | `T` |
693
690
 
694
691
  #### Parameters
695
692
 
696
- | Name | Type | Description |
697
- | :------ | :------ | :------ |
693
+ | Name | Type | Description |
694
+ | :------------- | :------- | :------------------------------------------- |
698
695
  | `description?` | `string` | Token description for better error messages. |
699
696
 
700
697
  #### Returns
@@ -703,9 +700,9 @@ Creates a new binding token.
703
700
 
704
701
  #### Defined in
705
702
 
706
- [packages/ditox/src/ditox.ts:31](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/ditox.ts#L31)
703
+ [packages/ditox/src/ditox.ts:31](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/ditox.ts#L31)
707
704
 
708
- ___
705
+ ---
709
706
 
710
707
  ### tryResolveValue
711
708
 
@@ -718,7 +715,8 @@ then returns an object containing resolved values as properties.
718
715
 
719
716
  If a token is not found, then `undefined` value is used.
720
717
 
721
- **`example`**
718
+ **`Example`**
719
+
722
720
  ```ts
723
721
  const value = tryResolveValue(container, tokenA);
724
722
  console.log(value); // 1
@@ -729,17 +727,17 @@ console.log(props); // {a: 1, b: 2}
729
727
 
730
728
  #### Type parameters
731
729
 
732
- | Name | Type |
733
- | :------ | :------ |
734
- | `Tokens` | extends [`Token`](README.md#token)<`unknown`\> \| { [key: string]: [`Token`](README.md#token)<`unknown`\>; } |
735
- | `Values` | extends `unknown` |
730
+ | Name | Type |
731
+ | :------- | :------------------------------------------------------------------------------------------------------------- |
732
+ | `Tokens` | extends [`Token`](README.md#token)<`unknown`\> \| { `[key: string]`: [`Token`](README.md#token)<`unknown`\>; } |
733
+ | `Values` | extends `unknown` |
736
734
 
737
735
  #### Parameters
738
736
 
739
- | Name | Type |
740
- | :------ | :------ |
737
+ | Name | Type |
738
+ | :---------- | :--------------------------------- |
741
739
  | `container` | [`Container`](README.md#container) |
742
- | `token` | `Tokens` |
740
+ | `token` | `Tokens` |
743
741
 
744
742
  #### Returns
745
743
 
@@ -747,13 +745,13 @@ console.log(props); // {a: 1, b: 2}
747
745
 
748
746
  #### Defined in
749
747
 
750
- [packages/ditox/src/utils.ts:54](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/utils.ts#L54)
748
+ [packages/ditox/src/utils.ts:54](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/utils.ts#L54)
751
749
 
752
- ___
750
+ ---
753
751
 
754
752
  ### tryResolveValues
755
753
 
756
- ▸ **tryResolveValues**<`Tokens`, `Values`\>(`container`, ...`tokens`): `Values`
754
+ ▸ **tryResolveValues**<`Tokens`, `Values`\>(`container`, `...tokens`): `Values`
757
755
 
758
756
  Returns an array of resolved values or objects with resolved values.
759
757
 
@@ -762,7 +760,8 @@ then returns an object containing resolved values as properties.
762
760
 
763
761
  If a token is not found, then `undefined` value is used.
764
762
 
765
- **`example`**
763
+ **`Example`**
764
+
766
765
  ```ts
767
766
  const items1 = tryResolveValues(container, tokenA);
768
767
  console.log(items1); // [1]
@@ -773,17 +772,17 @@ console.log(items2); // [1, {a: 1, b: 2}]
773
772
 
774
773
  #### Type parameters
775
774
 
776
- | Name | Type |
777
- | :------ | :------ |
778
- | `Tokens` | extends ([`Token`](README.md#token)<`unknown`\> \| { [key: string]: [`Token`](README.md#token)<`unknown`\>; })[] |
775
+ | Name | Type |
776
+ | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------- |
777
+ | `Tokens` | extends ([`Token`](README.md#token)<`unknown`\> \| { `[key: string]`: [`Token`](README.md#token)<`unknown`\>; })[] |
779
778
  | `Values` | extends { [K in string \| number \| symbol]: Tokens[K] extends Token<V\> ? undefined \| V : Tokens[K] extends TokenProps<Props\> ? Partial<Props\> : never } |
780
779
 
781
780
  #### Parameters
782
781
 
783
- | Name | Type |
784
- | :------ | :------ |
782
+ | Name | Type |
783
+ | :---------- | :--------------------------------- |
785
784
  | `container` | [`Container`](README.md#container) |
786
- | `...tokens` | `Tokens` |
785
+ | `...tokens` | `Tokens` |
787
786
 
788
787
  #### Returns
789
788
 
@@ -791,4 +790,4 @@ console.log(items2); // [1, {a: 1, b: 2}]
791
790
 
792
791
  #### Defined in
793
792
 
794
- [packages/ditox/src/utils.ts:88](https://github.com/mnasyrov/ditox/blob/a821171/packages/ditox/src/utils.ts#L88)
793
+ [packages/ditox/src/utils.ts:88](https://github.com/mnasyrov/ditox/blob/37f658c/packages/ditox/src/utils.ts#L88)