mesh-ioc 1.1.2 → 1.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/README.md +1 -1
- package/out/main/index.d.ts +0 -1
- package/out/main/index.js +0 -1
- package/out/main/mesh.d.ts +1 -0
- package/out/main/mesh.js +10 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Mesh IoC solves the problem of dependency management of application services. It
|
|
|
6
6
|
|
|
7
7
|
## Key features
|
|
8
8
|
|
|
9
|
-
- 👗 Very slim — about
|
|
9
|
+
- 👗 Very slim — about 2KB minified, few hundred bytes gzipped
|
|
10
10
|
- ⚡️ Blazing fast
|
|
11
11
|
- 🧩 Flexible and composable
|
|
12
12
|
- 🌿 Ergonomic
|
package/out/main/index.d.ts
CHANGED
package/out/main/index.js
CHANGED
|
@@ -11,7 +11,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./decorators/dep"), exports);
|
|
14
|
-
__exportStar(require("./decorators/service"), exports);
|
|
15
14
|
__exportStar(require("./errors"), exports);
|
|
16
15
|
__exportStar(require("./mesh"), exports);
|
|
17
16
|
__exportStar(require("./scope"), exports);
|
package/out/main/mesh.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare class Mesh {
|
|
|
14
14
|
constant<T>(key: ServiceKey<T>, value: T): this;
|
|
15
15
|
alias<T>(key: AbstractClass<T> | string, referenceKey: AbstractClass<T> | string): this;
|
|
16
16
|
resolve<T>(key: ServiceKey<T>): T;
|
|
17
|
+
tryResolve<T>(key: ServiceKey<T>): T | undefined;
|
|
17
18
|
connect<T>(value: T): T;
|
|
18
19
|
use(fn: Middleware): this;
|
|
19
20
|
scope(scopeId: string): Scope;
|
package/out/main/mesh.js
CHANGED
|
@@ -28,6 +28,14 @@ class Mesh {
|
|
|
28
28
|
return this;
|
|
29
29
|
}
|
|
30
30
|
resolve(key) {
|
|
31
|
+
const instance = this.tryResolve(key);
|
|
32
|
+
if (instance === undefined) {
|
|
33
|
+
const k = util_1.keyToString(key);
|
|
34
|
+
throw new errors_1.MeshBindingNotFound(this.name, k);
|
|
35
|
+
}
|
|
36
|
+
return instance;
|
|
37
|
+
}
|
|
38
|
+
tryResolve(key) {
|
|
31
39
|
const k = util_1.keyToString(key);
|
|
32
40
|
let instance = this.instances.get(k);
|
|
33
41
|
if (instance) {
|
|
@@ -41,9 +49,9 @@ class Mesh {
|
|
|
41
49
|
return instance;
|
|
42
50
|
}
|
|
43
51
|
if (this.parent) {
|
|
44
|
-
return this.parent.
|
|
52
|
+
return this.parent.tryResolve(key);
|
|
45
53
|
}
|
|
46
|
-
|
|
54
|
+
return undefined;
|
|
47
55
|
}
|
|
48
56
|
connect(value) {
|
|
49
57
|
const res = this.applyMiddleware(value);
|
|
@@ -66,7 +74,6 @@ class Mesh {
|
|
|
66
74
|
const childScope = this.childScopes.get(scopeId);
|
|
67
75
|
const newScope = new scope_1.Scope(scopeName, childScope !== null && childScope !== void 0 ? childScope : []);
|
|
68
76
|
const mesh = new Mesh(scopeId, this, newScope);
|
|
69
|
-
// mesh.currentScope = newScope;
|
|
70
77
|
return mesh;
|
|
71
78
|
}
|
|
72
79
|
instantiate(binding) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mesh-ioc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Mesh: Powerful and Lightweight IoC Library",
|
|
5
5
|
"main": "out/main/index.js",
|
|
6
6
|
"types": "out/main/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"test": "NODE_ENV=test mocha",
|
|
16
16
|
"preversion": "npm run lint",
|
|
17
17
|
"version": "npm run compile",
|
|
18
|
-
"postversion": "npm publish --access=public"
|
|
18
|
+
"postversion": "npm publish --access=public && git push origin main --tags"
|
|
19
19
|
},
|
|
20
20
|
"pre-commit": [
|
|
21
21
|
"lint"
|