@slimlib/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/README.md +6 -6
- package/package.json +11 -13
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Parameter names based dependency injector for nodejs.
|
|
|
8
8
|
- minification of code is not supported
|
|
9
9
|
- not typesafe
|
|
10
10
|
- classes not supported
|
|
11
|
-
- slower than normal function call
|
|
11
|
+
- slower than a normal function call
|
|
12
12
|
|
|
13
13
|
[Changelog](./CHANGELOG.md)
|
|
14
14
|
|
|
@@ -16,11 +16,11 @@ Parameter names based dependency injector for nodejs.
|
|
|
16
16
|
|
|
17
17
|
### createInject()
|
|
18
18
|
|
|
19
|
-
returns new instance of an injector function to work with.
|
|
19
|
+
returns a new instance of an injector function to work with.
|
|
20
20
|
|
|
21
21
|
### injector(function, scope)
|
|
22
22
|
|
|
23
|
-
injects arguments into function and
|
|
23
|
+
injects arguments into function and invokes it
|
|
24
24
|
|
|
25
25
|
`function` - *required*, function to inject parameters and call
|
|
26
26
|
`scope` - *optional*, *default* = `{}`, this argument for the function
|
|
@@ -32,7 +32,7 @@ predefined injectable function
|
|
|
32
32
|
`key` - string, required
|
|
33
33
|
`value` - unknown
|
|
34
34
|
|
|
35
|
-
to get it, inject it
|
|
35
|
+
to get it, inject it into the function
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
38
|
inject(($provide: Provider) => {
|
|
@@ -63,7 +63,7 @@ inject(async (config: Json) => {
|
|
|
63
63
|
|
|
64
64
|
# FAQ
|
|
65
65
|
|
|
66
|
-
1. Is it good solution to mock something in unit tests?
|
|
66
|
+
1. Is it a good solution to mock something in unit tests?
|
|
67
67
|
|
|
68
68
|
- no, please use [jest](https://jestjs.io/), [vitest](https://vitest.dev/), [proxyquire](https://www.npmjs.com/package/proxyquire), [proxyrequire](https://www.npmjs.com/package/proxyrequire) and other similar approaches to mock modules.
|
|
69
69
|
|
|
@@ -73,7 +73,7 @@ inject(async (config: Json) => {
|
|
|
73
73
|
|
|
74
74
|
3. Is it good for nodejs applications?
|
|
75
75
|
|
|
76
|
-
- only in some edge cases, please use singletons
|
|
76
|
+
- only in some edge cases, please use singletons/factories/something else if possible
|
|
77
77
|
|
|
78
78
|
# License
|
|
79
79
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
2
|
+
"type": "module",
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"name": "@slimlib/injector",
|
|
5
|
+
"description": "Parameter names based dependency injector for nodejs",
|
|
6
|
+
"license": "MIT",
|
|
5
7
|
"author": "Konstantin Shutkin",
|
|
6
|
-
"
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.mjs",
|
|
7
10
|
"exports": {
|
|
8
11
|
".": {
|
|
9
12
|
"require": "./dist/index.cjs",
|
|
@@ -11,26 +14,21 @@
|
|
|
11
14
|
},
|
|
12
15
|
"./package.json": "./package.json"
|
|
13
16
|
},
|
|
14
|
-
"
|
|
15
|
-
"module": "./dist/index.mjs",
|
|
16
|
-
"typings": "./dist/index.d.ts",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
17
18
|
"files": [
|
|
18
|
-
"dist"
|
|
19
|
-
"LICENSE"
|
|
19
|
+
"dist"
|
|
20
20
|
],
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=15"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
|
26
|
-
"url": "git+https://github.com/kshutkin/slimlib.git"
|
|
27
|
-
|
|
28
|
-
"bugs": {
|
|
29
|
-
"url": "https://github.com/kshutkin/slimlib/issues"
|
|
26
|
+
"url": "git+https://github.com/kshutkin/slimlib.git",
|
|
27
|
+
"directory": "injector"
|
|
30
28
|
},
|
|
29
|
+
"bugs": "https://github.com/kshutkin/slimlib/issues",
|
|
31
30
|
"homepage": "https://github.com/kshutkin/slimlib/blob/main/injector/README.md",
|
|
32
31
|
"readme": "README.md",
|
|
33
|
-
"description": "Parameter names based dependency injector for nodejs",
|
|
34
32
|
"keywords": [
|
|
35
33
|
"@slimlib",
|
|
36
34
|
"injector",
|