ts-ioc-container 35.2.0 → 35.2.2
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/cjm/container/IContainer.js +3 -3
- package/cjm/registration/IRegistration.js +4 -0
- package/esm/container/IContainer.js +3 -3
- package/esm/registration/IRegistration.js +4 -0
- package/package.json +2 -2
- package/typings/container/IContainer.d.ts +3 -3
- package/typings/registration/IRegistration.d.ts +1 -1
|
@@ -5,7 +5,7 @@ function isDependencyKey(token) {
|
|
|
5
5
|
return ['string', 'symbol'].includes(typeof token);
|
|
6
6
|
}
|
|
7
7
|
exports.isDependencyKey = isDependencyKey;
|
|
8
|
-
|
|
9
|
-
return typeof
|
|
10
|
-
}
|
|
8
|
+
const isConstructor = (T) => {
|
|
9
|
+
return typeof T === 'function' && !!T.prototype && !!T.prototype.constructor;
|
|
10
|
+
};
|
|
11
11
|
exports.isConstructor = isConstructor;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = exports.getTransformers = exports.scope = exports.redirectFrom = exports.key = void 0;
|
|
4
|
+
const IContainer_1 = require("../container/IContainer");
|
|
4
5
|
const metadata_1 = require("../metadata");
|
|
5
6
|
const by_1 = require("../by");
|
|
6
7
|
const key = (...keys) => (r) => {
|
|
@@ -19,6 +20,9 @@ const register = (...mappers) => (0, metadata_1.setMetadata)(METADATA_KEY, mappe
|
|
|
19
20
|
if ((0, by_1.isDepKey)(m)) {
|
|
20
21
|
return index === 0 ? m.register : m.redirectFrom;
|
|
21
22
|
}
|
|
23
|
+
if ((0, IContainer_1.isDependencyKey)(m)) {
|
|
24
|
+
return (r) => (index === 0 ? r.fromKey(m) : r.redirectFrom(m));
|
|
25
|
+
}
|
|
22
26
|
return m;
|
|
23
27
|
}));
|
|
24
28
|
exports.register = register;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function isDependencyKey(token) {
|
|
2
2
|
return ['string', 'symbol'].includes(typeof token);
|
|
3
3
|
}
|
|
4
|
-
export
|
|
5
|
-
return typeof
|
|
6
|
-
}
|
|
4
|
+
export const isConstructor = (T) => {
|
|
5
|
+
return typeof T === 'function' && !!T.prototype && !!T.prototype.constructor;
|
|
6
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDependencyKey } from '../container/IContainer';
|
|
1
2
|
import { getMetadata, setMetadata } from '../metadata';
|
|
2
3
|
import { isDepKey } from '../by';
|
|
3
4
|
export const key = (...keys) => (r) => {
|
|
@@ -12,5 +13,8 @@ export const register = (...mappers) => setMetadata(METADATA_KEY, mappers.map((m
|
|
|
12
13
|
if (isDepKey(m)) {
|
|
13
14
|
return index === 0 ? m.register : m.redirectFrom;
|
|
14
15
|
}
|
|
16
|
+
if (isDependencyKey(m)) {
|
|
17
|
+
return (r) => (index === 0 ? r.fromKey(m) : r.redirectFrom(m));
|
|
18
|
+
}
|
|
15
19
|
return m;
|
|
16
20
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-ioc-container",
|
|
3
|
-
"version": "35.2.
|
|
3
|
+
"version": "35.2.2",
|
|
4
4
|
"description": "Typescript IoC container",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"ts-node": "^10.9.1",
|
|
60
60
|
"typescript": "5.4.3"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "9084581b693b3e8644fda248392cc3ec5f07423d"
|
|
63
63
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { IProvider } from '../provider/IProvider';
|
|
2
|
-
import { constructor } from '../utils';
|
|
2
|
+
import { constructor, MapFn } from '../utils';
|
|
3
3
|
import { IRegistration } from '../registration/IRegistration';
|
|
4
4
|
export type Tag = string;
|
|
5
5
|
export type DependencyKey = string | symbol;
|
|
6
|
-
export declare function isDependencyKey
|
|
7
|
-
export declare
|
|
6
|
+
export declare function isDependencyKey(token: constructor<any> | DependencyKey | MapFn<any>): token is DependencyKey;
|
|
7
|
+
export declare const isConstructor: <T>(T: unknown) => T is constructor<T>;
|
|
8
8
|
export type InjectionToken<T = unknown> = constructor<T> | DependencyKey;
|
|
9
9
|
export type ResolveOptions = {
|
|
10
10
|
args?: unknown[];
|
|
@@ -14,4 +14,4 @@ export declare const key: (...keys: DependencyKey[]) => MapFn<IRegistration>;
|
|
|
14
14
|
export declare const redirectFrom: (...keys: DependencyKey[]) => MapFn<IRegistration>;
|
|
15
15
|
export declare const scope: (predicate: ScopePredicate) => MapFn<IRegistration>;
|
|
16
16
|
export declare const getTransformers: (Target: constructor<unknown>) => MapFn<IRegistration<any>>[];
|
|
17
|
-
export declare const register: (...mappers: (MapFn<IRegistration> | DepKey<
|
|
17
|
+
export declare const register: (...mappers: (MapFn<IRegistration> | DepKey<any> | DependencyKey)[]) => ClassDecorator;
|