@armscye/container 0.1.0 → 0.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/dist/{class-provider.interface.d.ts → class-provider.d.ts} +6 -2
- package/dist/{container.interface.d.ts → container.d.ts} +3 -1
- package/dist/{existing-provider.interface.d.ts → existing-provider.d.ts} +5 -1
- package/dist/{factory-provider.interface.d.ts → factory-provider.d.ts} +6 -2
- package/dist/{factory.interface.d.ts → factory.d.ts} +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/provider.d.ts +5 -0
- package/dist/{value-provider.interface.d.ts → value-provider.d.ts} +1 -1
- package/package.json +3 -3
- package/dist/provider.interface.d.ts +0 -5
- /package/dist/{provider-token.interface.d.ts → provider-token.d.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NoArgument } from '@armscye/core';
|
|
2
|
-
import { ProviderToken } from './provider-token
|
|
2
|
+
import { ProviderToken } from './provider-token';
|
|
3
3
|
/**
|
|
4
|
-
* Configures the `Container` to return
|
|
4
|
+
* Configures the `Container` to return a value by instantiating `useClass` class.
|
|
5
5
|
*/
|
|
6
6
|
export interface ClassProvider<T = any> {
|
|
7
7
|
/**
|
|
@@ -12,4 +12,8 @@ export interface ClassProvider<T = any> {
|
|
|
12
12
|
* Class to instantiate for the `token`.
|
|
13
13
|
*/
|
|
14
14
|
useClass: NoArgument<T>;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the created instance should be cached.
|
|
17
|
+
*/
|
|
18
|
+
shared?: boolean;
|
|
15
19
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ProviderToken } from './provider-token
|
|
1
|
+
import { ProviderToken } from './provider-token';
|
|
2
2
|
/**
|
|
3
3
|
* Describes the interface of a container that exposes methods to read its entries.
|
|
4
4
|
*/
|
|
5
5
|
export interface Container {
|
|
6
6
|
/**
|
|
7
7
|
* Find an entry of the container based on the provided token.
|
|
8
|
+
*
|
|
8
9
|
* @param token the provider token of the entry to look for
|
|
9
10
|
* @returns an entry from the container if defined
|
|
10
11
|
* @throws Error if no entry was found for the token
|
|
@@ -13,6 +14,7 @@ export interface Container {
|
|
|
13
14
|
get<T>(token: ProviderToken): T;
|
|
14
15
|
/**
|
|
15
16
|
* Check if an entry for the given provider token exists.
|
|
17
|
+
*
|
|
16
18
|
* @param token the provider token of the entry to look for
|
|
17
19
|
* @returns whether an entry for the given provider exists
|
|
18
20
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProviderToken } from './provider-token
|
|
1
|
+
import { ProviderToken } from './provider-token';
|
|
2
2
|
/**
|
|
3
3
|
* Configures the `Container` to return a value of another `useExisting` token.
|
|
4
4
|
*/
|
|
@@ -11,4 +11,8 @@ export interface ExistingProvider<T = any> {
|
|
|
11
11
|
* Existing `token` to return.
|
|
12
12
|
*/
|
|
13
13
|
useExisting: T;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the created instance should be cached.
|
|
16
|
+
*/
|
|
17
|
+
shared?: boolean;
|
|
14
18
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Factory } from './factory
|
|
2
|
-
import { ProviderToken } from './provider-token
|
|
1
|
+
import { Factory } from './factory';
|
|
2
|
+
import { ProviderToken } from './provider-token';
|
|
3
3
|
/**
|
|
4
4
|
* Configures the `Container` to return a value by invoking a `useFactory` function.
|
|
5
5
|
*/
|
|
@@ -13,4 +13,8 @@ export interface FactoryProvider<T = any> {
|
|
|
13
13
|
* invoked with resolved values of token`s from an instance of the container.
|
|
14
14
|
*/
|
|
15
15
|
useFactory: Factory<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the created instance should be cached.
|
|
18
|
+
*/
|
|
19
|
+
shared?: boolean;
|
|
16
20
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Container } from './container
|
|
1
|
+
import { Container } from './container';
|
|
2
2
|
/**
|
|
3
3
|
* Represents type for a factory. A factory is a function that is able to create an object.
|
|
4
4
|
* It is provided with an instance of the container in order to access required dependencies.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './class-provider
|
|
2
|
-
export * from './container
|
|
3
|
-
export * from './existing-provider
|
|
4
|
-
export * from './factory-provider
|
|
5
|
-
export * from './factory
|
|
6
|
-
export * from './provider-token
|
|
7
|
-
export * from './provider
|
|
8
|
-
export * from './value-provider
|
|
1
|
+
export * from './class-provider';
|
|
2
|
+
export * from './container';
|
|
3
|
+
export * from './existing-provider';
|
|
4
|
+
export * from './factory-provider';
|
|
5
|
+
export * from './factory';
|
|
6
|
+
export * from './provider-token';
|
|
7
|
+
export * from './provider';
|
|
8
|
+
export * from './value-provider';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ClassProvider } from './class-provider';
|
|
2
|
+
import { ExistingProvider } from './existing-provider';
|
|
3
|
+
import { FactoryProvider } from './factory-provider';
|
|
4
|
+
import { ValueProvider } from './value-provider';
|
|
5
|
+
export type Provider<T = any> = ValueProvider<T> | ClassProvider<T> | FactoryProvider<T> | ExistingProvider<T>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@armscye/container",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A collection of shared standard TypeScript definitions",
|
|
5
5
|
"author": "Augustus Kamau",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"types"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@armscye/core": "^0.
|
|
17
|
+
"@armscye/core": "^0.2.0"
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://github.com/armscye/armscye#readme",
|
|
20
20
|
"repository": {
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "f2c94ab8ecb4161f6f8c82820a8bbad758d83209"
|
|
31
31
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ClassProvider } from './class-provider.interface';
|
|
2
|
-
import { ExistingProvider } from './existing-provider.interface';
|
|
3
|
-
import { FactoryProvider } from './factory-provider.interface';
|
|
4
|
-
import { ValueProvider } from './value-provider.interface';
|
|
5
|
-
export type Provider<T = any> = ValueProvider<T> | ClassProvider<T> | FactoryProvider<T> | ExistingProvider<T>;
|
|
File without changes
|