@slimlib/injector 1.0.2 → 1.0.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Konstantin Shutkin
3
+ Copyright (c) 2023 Konstantin Shutkin
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -8,17 +8,19 @@ 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
+
13
+ [Changelog](./CHANGELOG.md)
12
14
 
13
15
  ## API
14
16
 
15
17
  ### createInject()
16
18
 
17
- returns new instance of an injector function to work with.
19
+ returns a new instance of an injector function to work with.
18
20
 
19
21
  ### injector(function, scope)
20
22
 
21
- injects arguments into function and invoke it
23
+ injects arguments into function and invokes it
22
24
 
23
25
  `function` - *required*, function to inject parameters and call
24
26
  `scope` - *optional*, *default* = `{}`, this argument for the function
@@ -30,7 +32,7 @@ predefined injectable function
30
32
  `key` - string, required
31
33
  `value` - unknown
32
34
 
33
- to get it, inject it in the function
35
+ to get it, inject it into the function
34
36
 
35
37
  ```typescript
36
38
  inject(($provide: Provider) => {
@@ -61,18 +63,18 @@ inject(async (config: Json) => {
61
63
 
62
64
  # FAQ
63
65
 
64
- 1. Is it good solution to mock something in unit tests?
66
+ 1. Is it a good solution to mock something in unit tests?
65
67
 
66
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.
67
69
 
68
- 2. Is it good solution to use in frontend code?
70
+ 2. Is it a good solution to use in frontend code?
69
71
 
70
72
  - no, it will not work after minification
71
73
 
72
74
  3. Is it good for nodejs applications?
73
75
 
74
- - only in some edge cases, please use singletones / factories / something else if possible
76
+ - only in some edge cases, please use singletons/factories/something else if possible
75
77
 
76
78
  # License
77
79
 
78
- [MIT](./LICENSE)
80
+ [MIT](https://github.com/kshutkin/slimlib/blob/main/LICENSE)
package/dist/index.cjs CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  var getParameterNames = require('get-parameter-names');
4
4
 
5
- var index = () => {
6
- const dependencies = Object.create(null);
7
- dependencies['$provide'] = (key, value) => {
8
- dependencies[key] = value;
9
- };
10
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
- return (func, scope = {}) => func.apply(scope, getParameterNames(func)
12
- .map((key) => dependencies[key]));
5
+ var index = () => {
6
+ const dependencies = Object.create(null);
7
+ dependencies['$provide'] = (key, value) => {
8
+ dependencies[key] = value;
9
+ };
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ return (func, scope = {}) => func.apply(scope, getParameterNames(func)
12
+ .map((key) => dependencies[key]));
13
13
  };
14
14
 
15
15
  module.exports = index;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare type Provider = (key: string, value: unknown) => void;
2
- declare const _default: () => <F extends (...args: any[]) => any>(func: F, scope?: object) => ReturnType<F>;
3
- export default _default;
1
+ export type Provider = (key: string, value: unknown) => void;
2
+ declare const _default: () => <F extends (...args: any[]) => any>(func: F, scope?: object) => ReturnType<F>;
3
+ export default _default;
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import getParameterNames from 'get-parameter-names';
2
2
 
3
- var index = () => {
4
- const dependencies = Object.create(null);
5
- dependencies['$provide'] = (key, value) => {
6
- dependencies[key] = value;
7
- };
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- return (func, scope = {}) => func.apply(scope, getParameterNames(func)
10
- .map((key) => dependencies[key]));
3
+ var index = () => {
4
+ const dependencies = Object.create(null);
5
+ dependencies['$provide'] = (key, value) => {
6
+ dependencies[key] = value;
7
+ };
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ return (func, scope = {}) => func.apply(scope, getParameterNames(func)
10
+ .map((key) => dependencies[key]));
11
11
  };
12
12
 
13
13
  export { index as default };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.2",
2
+ "version": "1.0.4",
3
3
  "license": "MIT",
4
4
  "name": "@slimlib/injector",
5
5
  "author": "Konstantin Shutkin",
@@ -37,32 +37,12 @@
37
37
  "dependency injection",
38
38
  "nodejs"
39
39
  ],
40
+ "dependencies": {
41
+ "get-parameter-names": "0.3.0"
42
+ },
40
43
  "scripts": {
41
44
  "build": "pkgbld-internal",
42
45
  "test": "jest --collectCoverage",
43
- "lint": "eslint ./src",
44
- "semantic-release": "npx semantic-release"
45
- },
46
- "devDependencies": {
47
- "@semantic-release/changelog": "6.0.1",
48
- "@semantic-release/commit-analyzer": "9.0.2",
49
- "@semantic-release/git": "10.0.1",
50
- "@semantic-release/npm": "9.0.0",
51
- "@semantic-release/release-notes-generator": "10.0.3",
52
- "@types/jest": "27.4.0",
53
- "@typescript-eslint/eslint-plugin": "5.11.0",
54
- "@typescript-eslint/parser": "5.11.0",
55
- "conventional-changelog-angular": "5.0.13",
56
- "eslint": "8.8.0",
57
- "jest": "27.5.1",
58
- "semantic-release": "19.0.2",
59
- "semantic-release-monorepo": "7.0.5",
60
- "ts-jest": "27.1.3",
61
- "typescript": "4.5.x",
62
- "update-monorepo-package-json": "0.2.0",
63
- "pkgbld-internal": "1.0.8"
64
- },
65
- "dependencies": {
66
- "get-parameter-names": "0.3.0"
46
+ "lint": "eslint ./src"
67
47
  }
68
- }
48
+ }