@stompbox/tape-delay 0.0.10 → 0.0.12
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 +27 -0
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -57,4 +57,31 @@ const randomEnvDetector: EnvironmentDetector = () => {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
const container = new TapeDelay({}, randomEnvDetector)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Scopes
|
|
63
|
+
|
|
64
|
+
Scopes can be customized for every entry. There are four options - `Singleton`, `Transient` (default), `Request`, `ConstantValue`.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { TapeDelay, injectable, Scopes } from '@stompbox/tape-delay'
|
|
68
|
+
|
|
69
|
+
@injectable()
|
|
70
|
+
class A { }
|
|
71
|
+
|
|
72
|
+
@injectable()
|
|
73
|
+
class B { }
|
|
74
|
+
|
|
75
|
+
const container = new TapeDelay({
|
|
76
|
+
A: [
|
|
77
|
+
// singleton scope in test
|
|
78
|
+
Scopes.Singleton(A),
|
|
79
|
+
// transient scope in development
|
|
80
|
+
Scopes.Transient(new A()),
|
|
81
|
+
// request scope on production
|
|
82
|
+
Scopes.Request(A)
|
|
83
|
+
],
|
|
84
|
+
// constant value for all environments
|
|
85
|
+
B: Scopes.ConstantValue(new B())
|
|
86
|
+
})
|
|
60
87
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -24,9 +24,9 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
Scope: ()=>Scope,
|
|
27
28
|
inject: ()=>external_inversify_namespaceObject.inject,
|
|
28
29
|
injectable: ()=>external_inversify_namespaceObject.injectable,
|
|
29
|
-
Lifespans: ()=>Lifespans,
|
|
30
30
|
TapeDelay: ()=>TapeDelay
|
|
31
31
|
});
|
|
32
32
|
const external_inversify_namespaceObject = require("inversify");
|
|
@@ -45,7 +45,7 @@ const Request = (EntryClass)=>[
|
|
|
45
45
|
const ConstantValue = (value)=>({
|
|
46
46
|
constantValue: value
|
|
47
47
|
});
|
|
48
|
-
const
|
|
48
|
+
const Scope = {
|
|
49
49
|
Singleton,
|
|
50
50
|
Transient,
|
|
51
51
|
Request,
|
|
@@ -104,12 +104,12 @@ class TapeDelay {
|
|
|
104
104
|
return container.get(entryName.toString());
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
-
exports.
|
|
107
|
+
exports.Scope = __webpack_exports__.Scope;
|
|
108
108
|
exports.TapeDelay = __webpack_exports__.TapeDelay;
|
|
109
109
|
exports.inject = __webpack_exports__.inject;
|
|
110
110
|
exports.injectable = __webpack_exports__.injectable;
|
|
111
111
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
112
|
-
"
|
|
112
|
+
"Scope",
|
|
113
113
|
"TapeDelay",
|
|
114
114
|
"inject",
|
|
115
115
|
"injectable"
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ type Entry<T> = [EntryDescription<T>, EntryDescription<T>, EntryDescription<T>]
|
|
|
13
13
|
export type Entries = Record<string, Entry<unknown>>;
|
|
14
14
|
export type EnvironmentDetector = () => Environment;
|
|
15
15
|
type EntryType<T> = T extends Entry<infer G> ? PublicFields<G> : never;
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const Scope: {
|
|
17
17
|
Singleton: <T>(EntryClass: ClassEntry<T>) => EntryDescription<T>;
|
|
18
18
|
Transient: <T>(EntryClass: ClassEntry<T>) => EntryDescription<T>;
|
|
19
19
|
Request: <T>(EntryClass: ClassEntry<T>) => EntryDescription<T>;
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const Request = (EntryClass)=>[
|
|
|
14
14
|
const ConstantValue = (value)=>({
|
|
15
15
|
constantValue: value
|
|
16
16
|
});
|
|
17
|
-
const
|
|
17
|
+
const Scope = {
|
|
18
18
|
Singleton: Singleton,
|
|
19
19
|
Transient: Transient,
|
|
20
20
|
Request: Request,
|
|
@@ -73,4 +73,4 @@ class TapeDelay {
|
|
|
73
73
|
return container.get(entryName.toString());
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
export {
|
|
76
|
+
export { Scope, TapeDelay, inject, injectable };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stompbox/tape-delay",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "Plug-and-play DI based on Inversify",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
"inversify": "^8.1.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"reflect-metadata": "
|
|
38
|
+
"reflect-metadata": "*"
|
|
39
39
|
}
|
|
40
40
|
}
|