@stompbox/tape-delay 0.0.6 → 0.0.9
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 -14
- package/dist/index.cjs +5 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,24 +14,16 @@ Plug-and-play DI based on Inversify.
|
|
|
14
14
|
import { TapeDelay, injectable } from '@stompbox/tape-delay'
|
|
15
15
|
|
|
16
16
|
@injectable()
|
|
17
|
-
class A {
|
|
18
|
-
sayHello = () => { console.log('hello') }
|
|
19
|
-
}
|
|
17
|
+
class A { hello = () => 'hello' }
|
|
20
18
|
|
|
21
19
|
@injectable()
|
|
22
|
-
class TestB {
|
|
23
|
-
method = () => { console.log('Hello from test') }
|
|
24
|
-
}
|
|
20
|
+
class TestB { method = () => 'test' }
|
|
25
21
|
|
|
26
22
|
@injectable()
|
|
27
|
-
class DevB {
|
|
28
|
-
method = () => { console.log('Hello from dev') }
|
|
29
|
-
}
|
|
23
|
+
class DevB { method = () => 'dev' }
|
|
30
24
|
|
|
31
25
|
@injectable()
|
|
32
|
-
class ProdB {
|
|
33
|
-
method = () => { console.log('Hello from prod') }
|
|
34
|
-
}
|
|
26
|
+
class ProdB { method = () => 'prod' }
|
|
35
27
|
|
|
36
28
|
const container = new TapeDelay({
|
|
37
29
|
// one implementation for all environments
|
|
@@ -42,7 +34,7 @@ const container = new TapeDelay({
|
|
|
42
34
|
|
|
43
35
|
// all types and keys are infered automatically
|
|
44
36
|
const aInstance = container.instance('A')
|
|
45
|
-
aInstance.
|
|
37
|
+
console.log(aInstance.hello())
|
|
46
38
|
const bInstance = container.instance('B')
|
|
47
|
-
bInstance.method()
|
|
39
|
+
console.log(bInstance.method())
|
|
48
40
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -42,10 +42,14 @@ const Request = (EntryClass)=>[
|
|
|
42
42
|
EntryClass,
|
|
43
43
|
(x)=>x.inRequestScope()
|
|
44
44
|
];
|
|
45
|
+
const ConstantValue = (value)=>({
|
|
46
|
+
constantValue: value
|
|
47
|
+
});
|
|
45
48
|
const Lifespans = {
|
|
46
49
|
Singleton,
|
|
47
50
|
Transient,
|
|
48
|
-
Request
|
|
51
|
+
Request,
|
|
52
|
+
ConstantValue
|
|
49
53
|
};
|
|
50
54
|
class TapeDelay {
|
|
51
55
|
entries;
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare const Lifespans: {
|
|
|
16
16
|
Singleton: <T>(EntryClass: ClassEntry<T>) => EntryDescription<T>;
|
|
17
17
|
Transient: <T>(EntryClass: ClassEntry<T>) => EntryDescription<T>;
|
|
18
18
|
Request: <T>(EntryClass: ClassEntry<T>) => EntryDescription<T>;
|
|
19
|
+
ConstantValue: <T>(value: T) => ConstantValueEntry<T>;
|
|
19
20
|
};
|
|
20
21
|
export declare class TapeDelay<T extends Entries> {
|
|
21
22
|
private readonly entries;
|
package/dist/index.js
CHANGED
|
@@ -11,10 +11,14 @@ const Request = (EntryClass)=>[
|
|
|
11
11
|
EntryClass,
|
|
12
12
|
(x)=>x.inRequestScope()
|
|
13
13
|
];
|
|
14
|
+
const ConstantValue = (value)=>({
|
|
15
|
+
constantValue: value
|
|
16
|
+
});
|
|
14
17
|
const Lifespans = {
|
|
15
18
|
Singleton: Singleton,
|
|
16
19
|
Transient: Transient,
|
|
17
|
-
Request: Request
|
|
20
|
+
Request: Request,
|
|
21
|
+
ConstantValue: ConstantValue
|
|
18
22
|
};
|
|
19
23
|
class TapeDelay {
|
|
20
24
|
entries;
|