fable 3.0.75 → 3.0.78

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.75",
3
+ "version": "3.0.78",
4
4
  "description": "An entity behavior management and API bundling library.",
5
5
  "main": "source/Fable.js",
6
6
  "scripts": {
@@ -54,6 +54,7 @@
54
54
  "dependencies": {
55
55
  "async.eachlimit": "^0.5.2",
56
56
  "async.waterfall": "^0.5.2",
57
+ "big.js": "^6.2.1",
57
58
  "cachetrax": "^1.0.4",
58
59
  "cookie": "^0.5.0",
59
60
  "data-arithmatic": "^1.0.7",
@@ -256,7 +256,13 @@ class DataFormat extends libFableServiceProviderBase
256
256
  */
257
257
  formatterDollars (pValue)
258
258
  {
259
- let tmpDollarAmount = parseFloat(pValue).toFixed(2);
259
+ if (isNaN(pValue))
260
+ {
261
+ return this._Value_NaN_Currency;
262
+ }
263
+
264
+ let tmpDollarAmountArbitrary = this.fable.Utility.bigNumber(pValue);
265
+ let tmpDollarAmount = tmpDollarAmountArbitrary.toFixed(2);
260
266
 
261
267
  if (isNaN(tmpDollarAmount))
262
268
  {
@@ -288,7 +294,15 @@ class DataFormat extends libFableServiceProviderBase
288
294
  {
289
295
  let tmpDigits = (typeof(pDigits) == 'undefined') ? 2 : pDigits;
290
296
 
291
- let tmpValue = parseFloat(pValue).toFixed(tmpDigits);
297
+ if (isNaN(pValue))
298
+ {
299
+ let tmpZed = 0;
300
+ return tmpZed.toFixed(tmpDigits);
301
+ }
302
+
303
+ let tmpAmountArbitrary = this.fable.Utility.bigNumber(pValue);
304
+ let tmpValue = tmpAmountArbitrary.toFixed(tmpDigits);
305
+
292
306
  if (isNaN(tmpValue))
293
307
  {
294
308
  let tmpZed = 0;
@@ -321,11 +335,11 @@ class DataFormat extends libFableServiceProviderBase
321
335
  else
322
336
  {
323
337
  let tmpPadLength = pTargetLength - pString.length;
324
- if (tmpPadLength > pPadString.length)
338
+ if (tmpPadLength > tmpPadString.length)
325
339
  {
326
- pPadString += pPadString.repeat(tmpTargetLength / pPadString.length);
340
+ tmpPadString += tmpPadString.repeat(tmpTargetLength / tmpPadString.length);
327
341
  }
328
- return pPadString.slice(0,tmpPadLength);
342
+ return tmpPadString.slice(0, tmpPadLength);
329
343
  }
330
344
  }
331
345
 
@@ -4,6 +4,8 @@ const libFableServiceBase = require('../Fable-ServiceManager.js').ServiceProvide
4
4
  const libAsyncWaterfall = require('async.waterfall');
5
5
  const libAsyncEachLimit = require('async.eachlimit');
6
6
 
7
+ const libBigNumber = require('big.js');
8
+
7
9
  class FableServiceUtility extends libFableServiceBase
8
10
  {
9
11
  // Underscore and lodash have a behavior, _.template, which compiles a
@@ -24,6 +26,8 @@ class FableServiceUtility extends libFableServiceBase
24
26
  // These two functions are used extensively throughout
25
27
  this.waterfall = libAsyncWaterfall;
26
28
  this.eachLimit = libAsyncEachLimit;
29
+
30
+ this.bigNumber = libBigNumber;
27
31
  }
28
32
 
29
33
  // Underscore and lodash have a behavior, _.extend, which merges objects.
@@ -58,6 +58,30 @@ suite
58
58
  Expect(_DataFormat
59
59
  .formatterDollars(1000))
60
60
  .to.equal('$1,000.00');
61
+ Expect(_DataFormat
62
+ .formatterDollars(1000.011))
63
+ .to.equal('$1,000.01');
64
+ Expect(_DataFormat
65
+ .formatterDollars(1000.013))
66
+ .to.equal('$1,000.01');
67
+ Expect(_DataFormat
68
+ .formatterDollars(1000.014))
69
+ .to.equal('$1,000.01');
70
+ Expect(_DataFormat
71
+ .formatterDollars(1000.015))
72
+ .to.equal('$1,000.02');
73
+ Expect(_DataFormat
74
+ .formatterDollars(1000.017))
75
+ .to.equal('$1,000.02');
76
+ Expect(_DataFormat
77
+ .formatterDollars(1000.019))
78
+ .to.equal('$1,000.02');
79
+ Expect(_DataFormat
80
+ .formatterDollars(1000.021))
81
+ .to.equal('$1,000.02');
82
+ Expect(_DataFormat
83
+ .formatterDollars(1000.515))
84
+ .to.equal('$1,000.52');
61
85
  Expect(_DataFormat
62
86
  .formatterDollars('Not dollars!'))
63
87
  .to.equal('--');