@stompbox/tape-delay 1.0.4 → 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/dist/index.cjs +43 -45
- package/dist/index.js +43 -45
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -52,57 +52,55 @@ const Scope = {
|
|
|
52
52
|
ConstantValue
|
|
53
53
|
};
|
|
54
54
|
class TapeDelay {
|
|
55
|
-
entries;
|
|
56
|
-
getEnvironment;
|
|
57
|
-
key = Math.random().toString();
|
|
58
55
|
constructor(entries, getEnvironment){
|
|
59
56
|
this.entries = entries;
|
|
60
57
|
this.getEnvironment = getEnvironment;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
if (!globalContainer[containerKey]) {
|
|
77
|
-
globalContainer[containerKey] = new external_inversify_namespaceObject.Container();
|
|
78
|
-
container = globalContainer[containerKey];
|
|
79
|
-
for(const rule in this.entries){
|
|
80
|
-
const ruleContentRaw = this.entries[rule];
|
|
81
|
-
if ('constantValue' in ruleContentRaw) {
|
|
82
|
-
container.bind(rule).toConstantValue(ruleContentRaw.constantValue);
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
const ruleContent = Array.isArray(ruleContentRaw) && 3 === ruleContentRaw.length ? ruleContentRaw[index()] : ruleContentRaw;
|
|
86
|
-
if (Array.isArray(ruleContent)) {
|
|
87
|
-
const [Entry, builder] = ruleContent;
|
|
88
|
-
builder(container.bind(rule).to(Entry));
|
|
89
|
-
continue;
|
|
58
|
+
this.key = Math.random().toString();
|
|
59
|
+
this.container = (environment)=>{
|
|
60
|
+
const globalContainer = globalThis;
|
|
61
|
+
let container;
|
|
62
|
+
const containerKey = `tape-delay-${environment}-${this.key}`;
|
|
63
|
+
const index = ()=>{
|
|
64
|
+
switch(environment){
|
|
65
|
+
case 'test':
|
|
66
|
+
return 0;
|
|
67
|
+
case 'development':
|
|
68
|
+
return 1;
|
|
69
|
+
default:
|
|
70
|
+
return 2;
|
|
90
71
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
72
|
+
};
|
|
73
|
+
if (!globalContainer[containerKey]) {
|
|
74
|
+
globalContainer[containerKey] = new external_inversify_namespaceObject.Container();
|
|
75
|
+
container = globalContainer[containerKey];
|
|
76
|
+
for(const rule in this.entries){
|
|
77
|
+
const ruleContentRaw = this.entries[rule];
|
|
78
|
+
if ('constantValue' in ruleContentRaw) {
|
|
79
|
+
container.bind(rule).toConstantValue(ruleContentRaw.constantValue);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const ruleContent = Array.isArray(ruleContentRaw) && 3 === ruleContentRaw.length ? ruleContentRaw[index()] : ruleContentRaw;
|
|
83
|
+
if (Array.isArray(ruleContent)) {
|
|
84
|
+
const [Entry, builder] = ruleContent;
|
|
85
|
+
builder(container.bind(rule).to(Entry));
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if ('constantValue' in ruleContent) {
|
|
89
|
+
container.bind(rule).toConstantValue(ruleContent.constantValue);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
container.bind(rule).to(ruleContent);
|
|
94
93
|
}
|
|
95
|
-
container.bind(rule).to(ruleContent);
|
|
96
94
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
95
|
+
container = globalContainer[containerKey];
|
|
96
|
+
return container;
|
|
97
|
+
};
|
|
98
|
+
this.instance = (entryName)=>{
|
|
99
|
+
const environment = this.getEnvironment ? this.getEnvironment() : process.env.NODE_ENV;
|
|
100
|
+
const container = this.container(environment);
|
|
101
|
+
return container.get(entryName.toString());
|
|
102
|
+
};
|
|
103
|
+
}
|
|
106
104
|
}
|
|
107
105
|
const inject = (entryKey)=>(0, external_inversify_namespaceObject.inject)(entryKey);
|
|
108
106
|
exports.Scope = __webpack_exports__.Scope;
|
package/dist/index.js
CHANGED
|
@@ -21,57 +21,55 @@ const Scope = {
|
|
|
21
21
|
ConstantValue: ConstantValue
|
|
22
22
|
};
|
|
23
23
|
class TapeDelay {
|
|
24
|
-
entries;
|
|
25
|
-
getEnvironment;
|
|
26
|
-
key = Math.random().toString();
|
|
27
24
|
constructor(entries, getEnvironment){
|
|
28
25
|
this.entries = entries;
|
|
29
26
|
this.getEnvironment = getEnvironment;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
if (!globalContainer[containerKey]) {
|
|
46
|
-
globalContainer[containerKey] = new Container();
|
|
47
|
-
container = globalContainer[containerKey];
|
|
48
|
-
for(const rule in this.entries){
|
|
49
|
-
const ruleContentRaw = this.entries[rule];
|
|
50
|
-
if ('constantValue' in ruleContentRaw) {
|
|
51
|
-
container.bind(rule).toConstantValue(ruleContentRaw.constantValue);
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
const ruleContent = Array.isArray(ruleContentRaw) && 3 === ruleContentRaw.length ? ruleContentRaw[index()] : ruleContentRaw;
|
|
55
|
-
if (Array.isArray(ruleContent)) {
|
|
56
|
-
const [Entry, builder] = ruleContent;
|
|
57
|
-
builder(container.bind(rule).to(Entry));
|
|
58
|
-
continue;
|
|
27
|
+
this.key = Math.random().toString();
|
|
28
|
+
this.container = (environment)=>{
|
|
29
|
+
const globalContainer = globalThis;
|
|
30
|
+
let container;
|
|
31
|
+
const containerKey = `tape-delay-${environment}-${this.key}`;
|
|
32
|
+
const index = ()=>{
|
|
33
|
+
switch(environment){
|
|
34
|
+
case 'test':
|
|
35
|
+
return 0;
|
|
36
|
+
case 'development':
|
|
37
|
+
return 1;
|
|
38
|
+
default:
|
|
39
|
+
return 2;
|
|
59
40
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
41
|
+
};
|
|
42
|
+
if (!globalContainer[containerKey]) {
|
|
43
|
+
globalContainer[containerKey] = new Container();
|
|
44
|
+
container = globalContainer[containerKey];
|
|
45
|
+
for(const rule in this.entries){
|
|
46
|
+
const ruleContentRaw = this.entries[rule];
|
|
47
|
+
if ('constantValue' in ruleContentRaw) {
|
|
48
|
+
container.bind(rule).toConstantValue(ruleContentRaw.constantValue);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const ruleContent = Array.isArray(ruleContentRaw) && 3 === ruleContentRaw.length ? ruleContentRaw[index()] : ruleContentRaw;
|
|
52
|
+
if (Array.isArray(ruleContent)) {
|
|
53
|
+
const [Entry, builder] = ruleContent;
|
|
54
|
+
builder(container.bind(rule).to(Entry));
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if ('constantValue' in ruleContent) {
|
|
58
|
+
container.bind(rule).toConstantValue(ruleContent.constantValue);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
container.bind(rule).to(ruleContent);
|
|
63
62
|
}
|
|
64
|
-
container.bind(rule).to(ruleContent);
|
|
65
63
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
64
|
+
container = globalContainer[containerKey];
|
|
65
|
+
return container;
|
|
66
|
+
};
|
|
67
|
+
this.instance = (entryName)=>{
|
|
68
|
+
const environment = this.getEnvironment ? this.getEnvironment() : process.env.NODE_ENV;
|
|
69
|
+
const container = this.container(environment);
|
|
70
|
+
return container.get(entryName.toString());
|
|
71
|
+
};
|
|
72
|
+
}
|
|
75
73
|
}
|
|
76
74
|
const src_inject = (entryKey)=>inject(entryKey);
|
|
77
75
|
export { Scope, TapeDelay, injectable, src_inject as inject };
|