@stompbox/tape-delay 1.0.4 → 1.0.6

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 CHANGED
@@ -77,7 +77,7 @@ const container = new TapeDelay({
77
77
  // singleton scope in test
78
78
  Scopes.Singleton(A),
79
79
  // transient scope in development
80
- Scopes.Transient(new A()),
80
+ Scopes.Transient(A),
81
81
  // request scope on production
82
82
  Scopes.Request(A)
83
83
  ],
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
- container = (environment)=>{
63
- const globalContainer = globalThis;
64
- let container;
65
- const containerKey = `tape-delay-${environment}-${this.key}`;
66
- const index = ()=>{
67
- switch(environment){
68
- case 'test':
69
- return 0;
70
- case 'development':
71
- return 1;
72
- default:
73
- return 2;
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
- if ('constantValue' in ruleContent) {
92
- container.bind(rule).toConstantValue(ruleContent.constantValue);
93
- continue;
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
- container = globalContainer[containerKey];
99
- return container;
100
- };
101
- instance = (entryName)=>{
102
- const environment = this.getEnvironment ? this.getEnvironment() : process.env.NODE_ENV;
103
- const container = this.container(environment);
104
- return container.get(entryName.toString());
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
- container = (environment)=>{
32
- const globalContainer = globalThis;
33
- let container;
34
- const containerKey = `tape-delay-${environment}-${this.key}`;
35
- const index = ()=>{
36
- switch(environment){
37
- case 'test':
38
- return 0;
39
- case 'development':
40
- return 1;
41
- default:
42
- return 2;
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
- if ('constantValue' in ruleContent) {
61
- container.bind(rule).toConstantValue(ruleContent.constantValue);
62
- continue;
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
- container = globalContainer[containerKey];
68
- return container;
69
- };
70
- instance = (entryName)=>{
71
- const environment = this.getEnvironment ? this.getEnvironment() : process.env.NODE_ENV;
72
- const container = this.container(environment);
73
- return container.get(entryName.toString());
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stompbox/tape-delay",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Plug-and-play DI based on Inversify",
5
5
  "repository": {
6
6
  "type": "git",