fable 3.1.46 → 3.1.47

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.1.46",
3
+ "version": "3.1.47",
4
4
  "description": "A service dependency injection, configuration and logging library.",
5
5
  "main": "source/Fable.js",
6
6
  "scripts": {
@@ -59,7 +59,7 @@
59
59
  "cachetrax": "^1.0.4",
60
60
  "cookie": "^1.0.2",
61
61
  "data-arithmatic": "^1.0.7",
62
- "dayjs": "^1.11.18",
62
+ "dayjs": "^1.11.19",
63
63
  "fable-log": "^3.0.16",
64
64
  "fable-serviceproviderbase": "^3.0.15",
65
65
  "fable-settings": "^3.0.12",
@@ -70,22 +70,23 @@ class ExpressionParserValueMarshal extends libExpressionParserOperationBase
70
70
  {
71
71
  tmpResults.ExpressionParserLog.push(`INFO: ExpressionParser.substituteValuesInTokenizedObjects found a value [${tmpValue}] for the state address ${tmpToken.Token} at index ${i}`);
72
72
  if (this.LogNoisiness > 1) this.log.info(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);
73
- try
73
+ if (typeof tmpValue === 'object') // this encapsulates POJOs and arrays
74
74
  {
75
- let tmpValueParsed = new this.fable.Utility.bigNumber(tmpValue);
75
+ // this must be checked first, which works around an edge case where bigNumber turns single-element arrays into numbers, which we never want
76
76
  tmpToken.Resolved = true;
77
- tmpToken.Value = tmpValueParsed.toString();
77
+ tmpToken.Value = tmpValue;
78
78
  }
79
- catch(pError)
79
+ else
80
80
  {
81
- // TODO: Should we allow this to be a function? Good god the complexity and beauty of that...
82
- if (Array.isArray(tmpValue) || (typeof(tmpValue) === 'object'))
81
+ try
83
82
  {
83
+ const tmpValueParsed = new this.fable.Utility.bigNumber(tmpValue);
84
84
  tmpToken.Resolved = true;
85
- tmpToken.Value = tmpValue;
85
+ tmpToken.Value = tmpValueParsed.toString();
86
86
  }
87
- else
87
+ catch(pError)
88
88
  {
89
+ // TODO: Should we allow this to be a function? Good god the complexity and beauty of that...
89
90
  tmpToken.Resolved = true;
90
91
  tmpToken.Value = tmpValue;
91
92
  tmpResults.ExpressionParserLog.push(`INFO: ExpressionParser.substituteValuesInTokenizedObjects found a non-numeric value for the state address ${tmpToken.Token} at index ${i}; using raw value.`);
@@ -145,6 +145,41 @@ suite
145
145
  }
146
146
  );
147
147
  test
148
+ (
149
+ 'Capture array -> number bug',
150
+ (fDone) =>
151
+ {
152
+ let _Parser = getExpressionParser();
153
+
154
+ let tmpResultObject = {};
155
+ let tmpDataObject = { W: ['3', '4', '5'], X: ['5'], Y: 3, Z: 75, Depth: 3, Width: 2 };
156
+ let tmpDestinationObject = {};
157
+
158
+ let tmpArea = _Parser.solve('Area = X * Y * Z', tmpDataObject, tmpResultObject, false, tmpDestinationObject);
159
+
160
+ Expect(tmpArea).to.equal("1125");
161
+
162
+ let tmpSliced = _Parser.solve('SlicedSingleElementArray = SLICE(X, 0, 1)', tmpDataObject, tmpResultObject, false, tmpDestinationObject);
163
+
164
+ Expect(tmpSliced).to.be.an('array');
165
+ Expect(tmpSliced.length).to.equal(1);
166
+ Expect(tmpSliced[0]).to.equal('5');
167
+
168
+ let tmpNonNumberTreatedAsZero = _Parser.solve('NonNumberTreatedAsZero = W + 3.456', tmpDataObject, tmpResultObject, false, tmpDestinationObject);
169
+
170
+ Expect(tmpNonNumberTreatedAsZero).to.equal('3.456');
171
+
172
+ let tmpLargerSlice = _Parser.solve('SLICE(W, 1, 3)', tmpDataObject, tmpResultObject, false, tmpDestinationObject);
173
+
174
+ Expect(tmpLargerSlice).to.be.an('array');
175
+ Expect(tmpLargerSlice.length).to.equal(2);
176
+ Expect(tmpLargerSlice[0]).to.equal('4');
177
+ Expect(tmpLargerSlice[1]).to.equal('5');
178
+
179
+ return fDone();
180
+ }
181
+ );
182
+ test
148
183
  (
149
184
  'Exercise Marshaling to Value at a Hashed Address',
150
185
  (fDone) =>