@spinajs/di 2.0.180 → 2.0.182
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/lib/cjs/array.d.ts +10 -10
- package/lib/cjs/array.js +13 -13
- package/lib/cjs/binder.d.ts +39 -39
- package/lib/cjs/binder.js +96 -96
- package/lib/cjs/container-cache.d.ts +17 -17
- package/lib/cjs/container-cache.js +63 -63
- package/lib/cjs/container.d.ts +133 -133
- package/lib/cjs/container.js +466 -466
- package/lib/cjs/container.js.map +1 -1
- package/lib/cjs/decorators.d.ts +141 -141
- package/lib/cjs/decorators.js +303 -303
- package/lib/cjs/enums.d.ts +31 -31
- package/lib/cjs/enums.js +35 -35
- package/lib/cjs/enums.js.map +1 -1
- package/lib/cjs/exceptions.d.ts +17 -17
- package/lib/cjs/exceptions.js +25 -25
- package/lib/cjs/helpers.d.ts +35 -35
- package/lib/cjs/helpers.js +86 -86
- package/lib/cjs/index.d.ts +12 -12
- package/lib/cjs/index.js +41 -41
- package/lib/cjs/interfaces.d.ts +172 -172
- package/lib/cjs/interfaces.js +53 -53
- package/lib/cjs/registry.d.ts +14 -14
- package/lib/cjs/registry.js +80 -80
- package/lib/cjs/root.d.ts +108 -108
- package/lib/cjs/root.js +216 -217
- package/lib/cjs/root.js.map +1 -1
- package/lib/cjs/types.d.ts +13 -13
- package/lib/cjs/types.js +2 -2
- package/lib/mjs/array.d.ts +10 -10
- package/lib/mjs/array.js +9 -9
- package/lib/mjs/binder.d.ts +39 -39
- package/lib/mjs/binder.js +92 -92
- package/lib/mjs/container-cache.d.ts +17 -17
- package/lib/mjs/container-cache.js +59 -59
- package/lib/mjs/container.d.ts +133 -133
- package/lib/mjs/container.js +459 -459
- package/lib/mjs/container.js.map +1 -1
- package/lib/mjs/decorators.d.ts +141 -141
- package/lib/mjs/decorators.js +266 -266
- package/lib/mjs/enums.d.ts +31 -31
- package/lib/mjs/enums.js +32 -32
- package/lib/mjs/enums.js.map +1 -1
- package/lib/mjs/exceptions.d.ts +17 -17
- package/lib/mjs/exceptions.js +19 -19
- package/lib/mjs/helpers.d.ts +35 -35
- package/lib/mjs/helpers.js +72 -72
- package/lib/mjs/index.d.ts +12 -12
- package/lib/mjs/index.js +12 -12
- package/lib/mjs/interfaces.d.ts +172 -172
- package/lib/mjs/interfaces.js +45 -45
- package/lib/mjs/registry.d.ts +14 -14
- package/lib/mjs/registry.js +76 -76
- package/lib/mjs/root.d.ts +108 -108
- package/lib/mjs/root.js +159 -159
- package/lib/mjs/types.d.ts +13 -13
- package/lib/mjs/types.js +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +2 -2
package/lib/cjs/enums.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResolveType = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* How to resolve class
|
|
6
|
-
*/
|
|
7
|
-
var ResolveType;
|
|
8
|
-
(function (ResolveType) {
|
|
9
|
-
/**
|
|
10
|
-
* Application wise single instance. Default behaviour
|
|
11
|
-
*/
|
|
12
|
-
ResolveType[ResolveType["Singleton"] = 0] = "Singleton";
|
|
13
|
-
/**
|
|
14
|
-
* New instance every time is requested
|
|
15
|
-
*/
|
|
16
|
-
ResolveType[ResolveType["NewInstance"] = 1] = "NewInstance";
|
|
17
|
-
/**
|
|
18
|
-
* New instance per child DI container.
|
|
19
|
-
*/
|
|
20
|
-
ResolveType[ResolveType["PerChildContainer"] = 2] = "PerChildContainer";
|
|
21
|
-
/**
|
|
22
|
-
* Singleton per target type
|
|
23
|
-
*
|
|
24
|
-
* eg. if we have multiple registered types at one base type
|
|
25
|
-
* we can resolve any of it once
|
|
26
|
-
*
|
|
27
|
-
* In comparison, Singleton flag means that only one instance can be resolved
|
|
28
|
-
* for base class
|
|
29
|
-
*/
|
|
30
|
-
ResolveType[ResolveType["PerInstance"] = 3] = "PerInstance";
|
|
31
|
-
/**
|
|
32
|
-
* Only one instance with given name can exists of the same service
|
|
33
|
-
*/
|
|
34
|
-
ResolveType[ResolveType["PerInstanceCheck"] = 4] = "PerInstanceCheck";
|
|
35
|
-
})(ResolveType
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResolveType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* How to resolve class
|
|
6
|
+
*/
|
|
7
|
+
var ResolveType;
|
|
8
|
+
(function (ResolveType) {
|
|
9
|
+
/**
|
|
10
|
+
* Application wise single instance. Default behaviour
|
|
11
|
+
*/
|
|
12
|
+
ResolveType[ResolveType["Singleton"] = 0] = "Singleton";
|
|
13
|
+
/**
|
|
14
|
+
* New instance every time is requested
|
|
15
|
+
*/
|
|
16
|
+
ResolveType[ResolveType["NewInstance"] = 1] = "NewInstance";
|
|
17
|
+
/**
|
|
18
|
+
* New instance per child DI container.
|
|
19
|
+
*/
|
|
20
|
+
ResolveType[ResolveType["PerChildContainer"] = 2] = "PerChildContainer";
|
|
21
|
+
/**
|
|
22
|
+
* Singleton per target type
|
|
23
|
+
*
|
|
24
|
+
* eg. if we have multiple registered types at one base type
|
|
25
|
+
* we can resolve any of it once
|
|
26
|
+
*
|
|
27
|
+
* In comparison, Singleton flag means that only one instance can be resolved
|
|
28
|
+
* for base class
|
|
29
|
+
*/
|
|
30
|
+
ResolveType[ResolveType["PerInstance"] = 3] = "PerInstance";
|
|
31
|
+
/**
|
|
32
|
+
* Only one instance with given name can exists of the same service
|
|
33
|
+
*/
|
|
34
|
+
ResolveType[ResolveType["PerInstanceCheck"] = 4] = "PerInstanceCheck";
|
|
35
|
+
})(ResolveType || (exports.ResolveType = ResolveType = {}));
|
|
36
36
|
//# sourceMappingURL=enums.js.map
|
package/lib/cjs/enums.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../src/enums.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,WA+BX;AA/BD,WAAY,WAAW;IACrB;;OAEG;IACH,uDAAS,CAAA;IAET;;OAEG;IACH,2DAAW,CAAA;IAEX;;OAEG;IACH,uEAAiB,CAAA;IAEjB;;;;;;;;OAQG;IACH,2DAAW,CAAA;IAEX;;OAEG;IACH,qEAAgB,CAAA;AAClB,CAAC,EA/BW,WAAW,
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../src/enums.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,WA+BX;AA/BD,WAAY,WAAW;IACrB;;OAEG;IACH,uDAAS,CAAA;IAET;;OAEG;IACH,2DAAW,CAAA;IAEX;;OAEG;IACH,uEAAiB,CAAA;IAEjB;;;;;;;;OAQG;IACH,2DAAW,CAAA;IAEX;;OAEG;IACH,qEAAgB,CAAA;AAClB,CAAC,EA/BW,WAAW,2BAAX,WAAW,QA+BtB"}
|
package/lib/cjs/exceptions.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exception thrown when cannot resolve type
|
|
3
|
-
*/
|
|
4
|
-
export declare class ResolveException extends Error {
|
|
5
|
-
/**
|
|
6
|
-
* Constructs new exception with message
|
|
7
|
-
* @param message - error message
|
|
8
|
-
*/
|
|
9
|
-
constructor(message?: string);
|
|
10
|
-
}
|
|
11
|
-
export declare class BindException extends Error {
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Service is not registered in DI container
|
|
15
|
-
*/
|
|
16
|
-
export declare class ServiceNotFound extends Error {
|
|
17
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Exception thrown when cannot resolve type
|
|
3
|
+
*/
|
|
4
|
+
export declare class ResolveException extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Constructs new exception with message
|
|
7
|
+
* @param message - error message
|
|
8
|
+
*/
|
|
9
|
+
constructor(message?: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class BindException extends Error {
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Service is not registered in DI container
|
|
15
|
+
*/
|
|
16
|
+
export declare class ServiceNotFound extends Error {
|
|
17
|
+
}
|
|
18
18
|
//# sourceMappingURL=exceptions.d.ts.map
|
package/lib/cjs/exceptions.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServiceNotFound = exports.BindException = exports.ResolveException = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Exception thrown when cannot resolve type
|
|
6
|
-
*/
|
|
7
|
-
class ResolveException extends Error {
|
|
8
|
-
/**
|
|
9
|
-
* Constructs new exception with message
|
|
10
|
-
* @param message - error message
|
|
11
|
-
*/
|
|
12
|
-
constructor(message) {
|
|
13
|
-
super(message);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.ResolveException = ResolveException;
|
|
17
|
-
class BindException extends Error {
|
|
18
|
-
}
|
|
19
|
-
exports.BindException = BindException;
|
|
20
|
-
/**
|
|
21
|
-
* Service is not registered in DI container
|
|
22
|
-
*/
|
|
23
|
-
class ServiceNotFound extends Error {
|
|
24
|
-
}
|
|
25
|
-
exports.ServiceNotFound = ServiceNotFound;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceNotFound = exports.BindException = exports.ResolveException = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Exception thrown when cannot resolve type
|
|
6
|
+
*/
|
|
7
|
+
class ResolveException extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Constructs new exception with message
|
|
10
|
+
* @param message - error message
|
|
11
|
+
*/
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.ResolveException = ResolveException;
|
|
17
|
+
class BindException extends Error {
|
|
18
|
+
}
|
|
19
|
+
exports.BindException = BindException;
|
|
20
|
+
/**
|
|
21
|
+
* Service is not registered in DI container
|
|
22
|
+
*/
|
|
23
|
+
class ServiceNotFound extends Error {
|
|
24
|
+
}
|
|
25
|
+
exports.ServiceNotFound = ServiceNotFound;
|
|
26
26
|
//# sourceMappingURL=exceptions.js.map
|
package/lib/cjs/helpers.d.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { TypedArray } from './array.js';
|
|
2
|
-
import { AsyncService, SyncService } from './interfaces.js';
|
|
3
|
-
import { Factory, Class } from './types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Checks if value is constructable type.
|
|
6
|
-
* Checks for [[Construct]] internal function in object.
|
|
7
|
-
*
|
|
8
|
-
* @param value - value to test
|
|
9
|
-
*/
|
|
10
|
-
export declare function isConstructor(value: any): value is Class<unknown>;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* Dirty way for check if type is class type
|
|
14
|
-
* NOTE: it will not work with transpilers that
|
|
15
|
-
* compile js class into functions
|
|
16
|
-
*
|
|
17
|
-
* @param obj
|
|
18
|
-
* @returns
|
|
19
|
-
*/
|
|
20
|
-
export declare function isClass(obj: any): boolean;
|
|
21
|
-
export declare function isFactory(value: any): value is Factory<any>;
|
|
22
|
-
export declare function isObject(value: any): value is object;
|
|
23
|
-
export declare function isAsyncService(value: any): value is AsyncService;
|
|
24
|
-
export declare function isPromise(value: any): value is Promise<any>;
|
|
25
|
-
export declare function isSyncService(value: any): value is SyncService;
|
|
26
|
-
/**
|
|
27
|
-
* For DI purpose we treat Map as array to inject. Difference is, that we fill map by some key
|
|
28
|
-
* provided by mapFunc in \@Autoinject
|
|
29
|
-
* @param value - value to check type
|
|
30
|
-
* @returns
|
|
31
|
-
*/
|
|
32
|
-
export declare function isTypedArray(value: any): value is TypedArray<any>;
|
|
33
|
-
export declare function isMap(value: any): value is Map<string, any>;
|
|
34
|
-
export declare function uniqBy<T>(arr: T[], comparator: (a: T, b: T) => boolean): T[];
|
|
35
|
-
export declare function getTypeName(type: TypedArray<any> | Class<any> | string | object): string;
|
|
1
|
+
import { TypedArray } from './array.js';
|
|
2
|
+
import { AsyncService, SyncService } from './interfaces.js';
|
|
3
|
+
import { Factory, Class } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Checks if value is constructable type.
|
|
6
|
+
* Checks for [[Construct]] internal function in object.
|
|
7
|
+
*
|
|
8
|
+
* @param value - value to test
|
|
9
|
+
*/
|
|
10
|
+
export declare function isConstructor(value: any): value is Class<unknown>;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* Dirty way for check if type is class type
|
|
14
|
+
* NOTE: it will not work with transpilers that
|
|
15
|
+
* compile js class into functions
|
|
16
|
+
*
|
|
17
|
+
* @param obj
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare function isClass(obj: any): boolean;
|
|
21
|
+
export declare function isFactory(value: any): value is Factory<any>;
|
|
22
|
+
export declare function isObject(value: any): value is object;
|
|
23
|
+
export declare function isAsyncService(value: any): value is AsyncService;
|
|
24
|
+
export declare function isPromise(value: any): value is Promise<any>;
|
|
25
|
+
export declare function isSyncService(value: any): value is SyncService;
|
|
26
|
+
/**
|
|
27
|
+
* For DI purpose we treat Map as array to inject. Difference is, that we fill map by some key
|
|
28
|
+
* provided by mapFunc in \@Autoinject
|
|
29
|
+
* @param value - value to check type
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
export declare function isTypedArray(value: any): value is TypedArray<any>;
|
|
33
|
+
export declare function isMap(value: any): value is Map<string, any>;
|
|
34
|
+
export declare function uniqBy<T>(arr: T[], comparator: (a: T, b: T) => boolean): T[];
|
|
35
|
+
export declare function getTypeName(type: TypedArray<any> | Class<any> | string | object): string;
|
|
36
36
|
//# sourceMappingURL=helpers.d.ts.map
|
package/lib/cjs/helpers.js
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTypeName = exports.uniqBy = exports.isMap = exports.isTypedArray = exports.isSyncService = exports.isPromise = exports.isAsyncService = exports.isObject = exports.isFactory = exports.isClass = exports.isConstructor = void 0;
|
|
4
|
-
const interfaces_js_1 = require("./interfaces.js");
|
|
5
|
-
/**
|
|
6
|
-
* Checks if value is constructable type.
|
|
7
|
-
* Checks for [[Construct]] internal function in object.
|
|
8
|
-
*
|
|
9
|
-
* @param value - value to test
|
|
10
|
-
*/
|
|
11
|
-
function isConstructor(value) {
|
|
12
|
-
try {
|
|
13
|
-
Reflect.construct(String, [], value);
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
exports.isConstructor = isConstructor;
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* Dirty way for check if type is class type
|
|
24
|
-
* NOTE: it will not work with transpilers that
|
|
25
|
-
* compile js class into functions
|
|
26
|
-
*
|
|
27
|
-
* @param obj
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
30
|
-
function isClass(obj) {
|
|
31
|
-
const isCtorClass = obj.constructor && obj.constructor.toString().substring(0, 5) === 'class';
|
|
32
|
-
if (obj.prototype === undefined) {
|
|
33
|
-
return isCtorClass;
|
|
34
|
-
}
|
|
35
|
-
const isPrototypeCtorClass = obj.prototype.constructor && obj.prototype.constructor.toString && obj.prototype.constructor.toString().substring(0, 5) === 'class';
|
|
36
|
-
return isCtorClass || isPrototypeCtorClass;
|
|
37
|
-
}
|
|
38
|
-
exports.isClass = isClass;
|
|
39
|
-
function isFactory(value) {
|
|
40
|
-
return !isConstructor(value) && typeof value === 'function';
|
|
41
|
-
}
|
|
42
|
-
exports.isFactory = isFactory;
|
|
43
|
-
function isObject(value) {
|
|
44
|
-
return typeof value === 'object';
|
|
45
|
-
}
|
|
46
|
-
exports.isObject = isObject;
|
|
47
|
-
function isAsyncService(value) {
|
|
48
|
-
return value instanceof interfaces_js_1.AsyncService;
|
|
49
|
-
}
|
|
50
|
-
exports.isAsyncService = isAsyncService;
|
|
51
|
-
function isPromise(value) {
|
|
52
|
-
return value instanceof Promise;
|
|
53
|
-
}
|
|
54
|
-
exports.isPromise = isPromise;
|
|
55
|
-
function isSyncService(value) {
|
|
56
|
-
return value instanceof interfaces_js_1.SyncService;
|
|
57
|
-
}
|
|
58
|
-
exports.isSyncService = isSyncService;
|
|
59
|
-
/**
|
|
60
|
-
* For DI purpose we treat Map as array to inject. Difference is, that we fill map by some key
|
|
61
|
-
* provided by mapFunc in \@Autoinject
|
|
62
|
-
* @param value - value to check type
|
|
63
|
-
* @returns
|
|
64
|
-
*/
|
|
65
|
-
function isTypedArray(value) {
|
|
66
|
-
return (value instanceof Array && value.constructor.name === 'TypedArray') || isMap(value);
|
|
67
|
-
}
|
|
68
|
-
exports.isTypedArray = isTypedArray;
|
|
69
|
-
function isMap(value) {
|
|
70
|
-
return value instanceof Map && value.constructor.name === 'Map';
|
|
71
|
-
}
|
|
72
|
-
exports.isMap = isMap;
|
|
73
|
-
function uniqBy(arr, comparator) {
|
|
74
|
-
const uniques = [];
|
|
75
|
-
for (const a of arr) {
|
|
76
|
-
if (uniques.findIndex((u) => comparator(a, u)) === -1) {
|
|
77
|
-
uniques.push(a);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return uniques;
|
|
81
|
-
}
|
|
82
|
-
exports.uniqBy = uniqBy;
|
|
83
|
-
function getTypeName(type) {
|
|
84
|
-
return typeof type === 'string' ? type : isTypedArray(type) ? getTypeName(type.Type) : isConstructor(type) ? type.name : type.constructor.name;
|
|
85
|
-
}
|
|
86
|
-
exports.getTypeName = getTypeName;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTypeName = exports.uniqBy = exports.isMap = exports.isTypedArray = exports.isSyncService = exports.isPromise = exports.isAsyncService = exports.isObject = exports.isFactory = exports.isClass = exports.isConstructor = void 0;
|
|
4
|
+
const interfaces_js_1 = require("./interfaces.js");
|
|
5
|
+
/**
|
|
6
|
+
* Checks if value is constructable type.
|
|
7
|
+
* Checks for [[Construct]] internal function in object.
|
|
8
|
+
*
|
|
9
|
+
* @param value - value to test
|
|
10
|
+
*/
|
|
11
|
+
function isConstructor(value) {
|
|
12
|
+
try {
|
|
13
|
+
Reflect.construct(String, [], value);
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
exports.isConstructor = isConstructor;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* Dirty way for check if type is class type
|
|
24
|
+
* NOTE: it will not work with transpilers that
|
|
25
|
+
* compile js class into functions
|
|
26
|
+
*
|
|
27
|
+
* @param obj
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
function isClass(obj) {
|
|
31
|
+
const isCtorClass = obj.constructor && obj.constructor.toString().substring(0, 5) === 'class';
|
|
32
|
+
if (obj.prototype === undefined) {
|
|
33
|
+
return isCtorClass;
|
|
34
|
+
}
|
|
35
|
+
const isPrototypeCtorClass = obj.prototype.constructor && obj.prototype.constructor.toString && obj.prototype.constructor.toString().substring(0, 5) === 'class';
|
|
36
|
+
return isCtorClass || isPrototypeCtorClass;
|
|
37
|
+
}
|
|
38
|
+
exports.isClass = isClass;
|
|
39
|
+
function isFactory(value) {
|
|
40
|
+
return !isConstructor(value) && typeof value === 'function';
|
|
41
|
+
}
|
|
42
|
+
exports.isFactory = isFactory;
|
|
43
|
+
function isObject(value) {
|
|
44
|
+
return typeof value === 'object';
|
|
45
|
+
}
|
|
46
|
+
exports.isObject = isObject;
|
|
47
|
+
function isAsyncService(value) {
|
|
48
|
+
return value instanceof interfaces_js_1.AsyncService;
|
|
49
|
+
}
|
|
50
|
+
exports.isAsyncService = isAsyncService;
|
|
51
|
+
function isPromise(value) {
|
|
52
|
+
return value instanceof Promise;
|
|
53
|
+
}
|
|
54
|
+
exports.isPromise = isPromise;
|
|
55
|
+
function isSyncService(value) {
|
|
56
|
+
return value instanceof interfaces_js_1.SyncService;
|
|
57
|
+
}
|
|
58
|
+
exports.isSyncService = isSyncService;
|
|
59
|
+
/**
|
|
60
|
+
* For DI purpose we treat Map as array to inject. Difference is, that we fill map by some key
|
|
61
|
+
* provided by mapFunc in \@Autoinject
|
|
62
|
+
* @param value - value to check type
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
function isTypedArray(value) {
|
|
66
|
+
return (value instanceof Array && value.constructor.name === 'TypedArray') || isMap(value);
|
|
67
|
+
}
|
|
68
|
+
exports.isTypedArray = isTypedArray;
|
|
69
|
+
function isMap(value) {
|
|
70
|
+
return value instanceof Map && value.constructor.name === 'Map';
|
|
71
|
+
}
|
|
72
|
+
exports.isMap = isMap;
|
|
73
|
+
function uniqBy(arr, comparator) {
|
|
74
|
+
const uniques = [];
|
|
75
|
+
for (const a of arr) {
|
|
76
|
+
if (uniques.findIndex((u) => comparator(a, u)) === -1) {
|
|
77
|
+
uniques.push(a);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return uniques;
|
|
81
|
+
}
|
|
82
|
+
exports.uniqBy = uniqBy;
|
|
83
|
+
function getTypeName(type) {
|
|
84
|
+
return typeof type === 'string' ? type : isTypedArray(type) ? getTypeName(type.Type) : isConstructor(type) ? type.name : type.constructor.name;
|
|
85
|
+
}
|
|
86
|
+
exports.getTypeName = getTypeName;
|
|
87
87
|
//# sourceMappingURL=helpers.js.map
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from './interfaces.js';
|
|
2
|
-
export * from './array.js';
|
|
3
|
-
export * from './decorators.js';
|
|
4
|
-
export * from './enums.js';
|
|
5
|
-
export * from './types.js';
|
|
6
|
-
export * from './helpers.js';
|
|
7
|
-
export * from './container-cache.js';
|
|
8
|
-
export * from './binder.js';
|
|
9
|
-
export * from './registry.js';
|
|
10
|
-
export * from './container.js';
|
|
11
|
-
export * as DI from './root.js';
|
|
12
|
-
export * from './exceptions.js';
|
|
1
|
+
export * from './interfaces.js';
|
|
2
|
+
export * from './array.js';
|
|
3
|
+
export * from './decorators.js';
|
|
4
|
+
export * from './enums.js';
|
|
5
|
+
export * from './types.js';
|
|
6
|
+
export * from './helpers.js';
|
|
7
|
+
export * from './container-cache.js';
|
|
8
|
+
export * from './binder.js';
|
|
9
|
+
export * from './registry.js';
|
|
10
|
+
export * from './container.js';
|
|
11
|
+
export * as DI from './root.js';
|
|
12
|
+
export * from './exceptions.js';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
-
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.DI = void 0;
|
|
30
|
-
__exportStar(require("./interfaces.js"), exports);
|
|
31
|
-
__exportStar(require("./array.js"), exports);
|
|
32
|
-
__exportStar(require("./decorators.js"), exports);
|
|
33
|
-
__exportStar(require("./enums.js"), exports);
|
|
34
|
-
__exportStar(require("./types.js"), exports);
|
|
35
|
-
__exportStar(require("./helpers.js"), exports);
|
|
36
|
-
__exportStar(require("./container-cache.js"), exports);
|
|
37
|
-
__exportStar(require("./binder.js"), exports);
|
|
38
|
-
__exportStar(require("./registry.js"), exports);
|
|
39
|
-
__exportStar(require("./container.js"), exports);
|
|
40
|
-
exports.DI = __importStar(require("./root.js"));
|
|
41
|
-
__exportStar(require("./exceptions.js"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.DI = void 0;
|
|
30
|
+
__exportStar(require("./interfaces.js"), exports);
|
|
31
|
+
__exportStar(require("./array.js"), exports);
|
|
32
|
+
__exportStar(require("./decorators.js"), exports);
|
|
33
|
+
__exportStar(require("./enums.js"), exports);
|
|
34
|
+
__exportStar(require("./types.js"), exports);
|
|
35
|
+
__exportStar(require("./helpers.js"), exports);
|
|
36
|
+
__exportStar(require("./container-cache.js"), exports);
|
|
37
|
+
__exportStar(require("./binder.js"), exports);
|
|
38
|
+
__exportStar(require("./registry.js"), exports);
|
|
39
|
+
__exportStar(require("./container.js"), exports);
|
|
40
|
+
exports.DI = __importStar(require("./root.js"));
|
|
41
|
+
__exportStar(require("./exceptions.js"), exports);
|
|
42
42
|
//# sourceMappingURL=index.js.map
|