nano-injector 1.0.3 → 1.0.5
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/LICENSE +21 -21
- package/README.md +240 -221
- package/lib/Binder.js +83 -86
- package/lib/Injector.js +158 -159
- package/lib/InjectorsStack.js +33 -33
- package/lib/Provider.js +60 -59
- package/lib/index.js +18 -14
- package/package.json +52 -57
- package/typings/Binder.d.ts +44 -47
- package/typings/Injector.d.ts +93 -96
- package/typings/InjectorsStack.d.ts +16 -16
- package/typings/Provider.d.ts +48 -50
- package/typings/index.d.ts +2 -2
package/typings/Provider.d.ts
CHANGED
|
@@ -1,50 +1,48 @@
|
|
|
1
|
-
export
|
|
2
|
-
/**
|
|
3
|
-
* Symbol used
|
|
4
|
-
*/
|
|
5
|
-
declare const ID_SYMBOL: unique symbol;
|
|
6
|
-
/**
|
|
7
|
-
* Symbol used for storing the name of a provider
|
|
8
|
-
*/
|
|
9
|
-
declare const NAME_SYMBOL: unique symbol;
|
|
10
|
-
/**
|
|
11
|
-
* Provider is a
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
export interface Provider<T> {
|
|
15
|
-
readonly [ID_SYMBOL]: number;
|
|
16
|
-
readonly [NAME_SYMBOL]
|
|
17
|
-
/**
|
|
18
|
-
* Returns bound to this provider
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export declare function getProviderName(provider: Provider<unknown>): string | undefined;
|
|
50
|
-
export {};
|
|
1
|
+
export type ProviderValueType<T extends Provider<any>> = T extends Provider<infer R> ? R : never;
|
|
2
|
+
/**
|
|
3
|
+
* Symbol used to store the unique ID of a provider.
|
|
4
|
+
*/
|
|
5
|
+
declare const ID_SYMBOL: unique symbol;
|
|
6
|
+
/**
|
|
7
|
+
* Symbol used for storing the name of a provider
|
|
8
|
+
*/
|
|
9
|
+
declare const NAME_SYMBOL: unique symbol;
|
|
10
|
+
/**
|
|
11
|
+
* A Provider is a core concept in the library. It is essentially a function
|
|
12
|
+
* that facilitates binding to a specific value.
|
|
13
|
+
*/
|
|
14
|
+
export interface Provider<T> {
|
|
15
|
+
readonly [ID_SYMBOL]: number;
|
|
16
|
+
readonly [NAME_SYMBOL]?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the value bound to this provider. Throws an exception if the value is not found.
|
|
19
|
+
* To avoid an exception, pass a default value.
|
|
20
|
+
*/
|
|
21
|
+
(): T;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the value bound to this provider, or the default value if the bound value is not found.
|
|
24
|
+
* @param defValue
|
|
25
|
+
*/
|
|
26
|
+
<DefValT>(defValue: DefValT): T | DefValT;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new provider for a specific value type.
|
|
30
|
+
* @param name name for this provider used mainly for debugging purposes
|
|
31
|
+
*/
|
|
32
|
+
export declare function createProvider<T>(name?: string): Provider<T>;
|
|
33
|
+
/**
|
|
34
|
+
* Determines whether the given value is a provider.
|
|
35
|
+
* @param value value which should be tested
|
|
36
|
+
*/
|
|
37
|
+
export declare function isProvider<T = unknown>(value: unknown): value is Provider<T>;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the unique ID of the specified provider.
|
|
40
|
+
* @param provider
|
|
41
|
+
*/
|
|
42
|
+
export declare function getProviderID(provider: Provider<unknown>): number;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the name of the specified provider
|
|
45
|
+
* @param provider
|
|
46
|
+
*/
|
|
47
|
+
export declare function getProviderName(provider: Provider<unknown>): string | undefined;
|
|
48
|
+
export {};
|
package/typings/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './Injector';
|
|
2
|
-
export * from './Provider';
|
|
1
|
+
export * from './Injector';
|
|
2
|
+
export * from './Provider';
|