fable 3.0.141 → 3.0.143

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fable",
3
- "version": "3.0.141",
3
+ "version": "3.0.143",
4
4
  "description": "A service dependency injection, configuration and logging library.",
5
5
  "main": "source/Fable.js",
6
6
  "scripts": {
package/source/Fable.js CHANGED
@@ -171,13 +171,27 @@ class Fable extends libFableServiceBase.CoreServiceProviderBase
171
171
  {
172
172
  this.addServiceTypeIfNotExists(pServiceType, pServiceClass);
173
173
 
174
- if (!(pServiceType in this.servicesMap))
174
+ if ((!(pServiceType in this.servicesMap)) || (!(pServiceType in this.fable)))
175
175
  {
176
176
  return this.instantiateServiceProvider(pServiceType, {}, `${pServiceType}-Default`);
177
177
  }
178
178
  else
179
179
  {
180
- return this.serviceClasses[pServiceType];
180
+ return this[pServiceType];
181
+ }
182
+ }
183
+
184
+ addAndInstantiateSingletonService(pServiceType, pOptions, pServiceClass)
185
+ {
186
+ this.addServiceTypeIfNotExists(pServiceType, pServiceClass);
187
+
188
+ if ((!(pServiceType in this.servicesMap)) || (!(pServiceType in this.fable)))
189
+ {
190
+ return this.instantiateServiceProvider(pServiceType, {}, `${pServiceType}-Default`);
191
+ }
192
+ else
193
+ {
194
+ return this[pServiceType];
181
195
  }
182
196
  }
183
197
 
@@ -106,7 +106,7 @@ class ExpressionParserSolver extends libExpressionParserOperationBase
106
106
  {
107
107
  try
108
108
  {
109
- this.log.trace(`Solving Function Step ${i} [${tmpStepResultObject.ExpressionStep.VirtualSymbolName}] --> [${tmpStepResultObject.ExpressionStep.Operation.Token}]: ( ${tmpStepResultObject.ExpressionStep.LeftValue.Value} , ${tmpStepResultObject.ExpressionStep.RightValue.Value} )`);
109
+ //this.log.trace(`Solving Function Step ${i} [${tmpStepResultObject.ExpressionStep.VirtualSymbolName}] --> [${tmpStepResultObject.ExpressionStep.Operation.Token}]: ( ${tmpStepResultObject.ExpressionStep.LeftValue.Value} , ${tmpStepResultObject.ExpressionStep.RightValue.Value} )`);
110
110
  // Build the set of arguments to send to the functions.
111
111
  tmpStepResultObject.ExpressionStep.LeftValue.ArgumentString = '';
112
112
  if (typeof(tmpStepResultObject.ExpressionStep.LeftValue.Value) === 'undefined')
@@ -153,7 +153,7 @@ class ExpressionParserSolver extends libExpressionParserOperationBase
153
153
  {
154
154
  try
155
155
  {
156
- this.log.trace(`Solving Step ${i} [${tmpStepResultObject.ExpressionStep.VirtualSymbolName}] --> [${tmpStepResultObject.ExpressionStep.Operation.Token}]: ( ${tmpStepResultObject.ExpressionStep.LeftValue.Value} , ${tmpStepResultObject.ExpressionStep.RightValue.Value} )`);
156
+ //this.log.trace(`Solving Step ${i} [${tmpStepResultObject.ExpressionStep.VirtualSymbolName}] --> [${tmpStepResultObject.ExpressionStep.Operation.Token}]: ( ${tmpStepResultObject.ExpressionStep.LeftValue.Value} , ${tmpStepResultObject.ExpressionStep.RightValue.Value} )`);
157
157
  tmpManifest.setValueAtAddress(tmpResults.VirtualSymbols, tmpStepResultObject.ExpressionStep.VirtualSymbolName, tmpManifest.getValueAtAddress(tmpStepResultObject, `${tmpFunctionAddress}(ExpressionStep.LeftValue.Value,ExpressionStep.RightValue.Value)`));
158
158
  tmpResults.LastResult = tmpManifest.getValueAtAddress(tmpResults.VirtualSymbols, tmpStepResultObject.ExpressionStep.VirtualSymbolName);
159
159
  //this.log.trace(` ---> Step ${i}: ${tmpResults.VirtualSymbols[tmpStepResultObject.ExpressionStep.VirtualSymbolName]}`)
@@ -166,7 +166,24 @@ suite
166
166
  Expect(tmpService).to.be.an('object');
167
167
  }
168
168
  );
169
+ test
170
+ (
171
+ 'Add and instantiate a singleton service',
172
+ function ()
173
+ {
174
+ let testFable = new libFable({});
175
+
176
+ let tmpService = testFable.addAndInstantiateSingletonService('SimpleService', {}, SimpleService);
169
177
 
178
+ Expect(testFable.SimpleService).to.be.an('object');
179
+ Expect(tmpService).to.be.an('object');
180
+
181
+ let tmpService2 = testFable.addAndInstantiateSingletonService('SimpleService', {}, SimpleService);
182
+
183
+ // A second call should not construct another one.
184
+ Expect(tmpService2.Hash).to.equal(tmpService.Hash);
185
+ }
186
+ );
170
187
  test
171
188
  (
172
189
  'Change the default service provider',