fable 3.0.113 → 3.0.115
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/fable.compatible.js +12 -6
- package/dist/fable.compatible.min.js +2 -2
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +12 -6
- package/dist/fable.min.js +2 -2
- package/dist/fable.min.js.map +1 -1
- package/package.json +2 -2
- package/source/services/Fable-Service-DataFormat.js +4 -18
- package/source/services/Fable-Service-Math.js +138 -15
- package/test/Math_test.js +94 -0
package/dist/fable.compatible.js
CHANGED
|
@@ -3016,10 +3016,7 @@ return pNumber.toString().replace(this._Regex_formatterAddCommasToNumber,this.pr
|
|
|
3016
3016
|
*
|
|
3017
3017
|
* @param {*} pValue
|
|
3018
3018
|
* @returns {string}
|
|
3019
|
-
*/},{key:"formatterDollars",value:function formatterDollars(pValue){if(isNaN(pValue)){return this._Value_NaN_Currency;}if(pValue===null||pValue===undefined){return this._Value_NaN_Currency;}var tmpDollarAmountArbitrary=this.fable.
|
|
3020
|
-
if(typeof pValue=='string'){// TODO: Better rounding function? This is a hack to get rid of the currency symbol and commas.
|
|
3021
|
-
tmpDollarAmount=parseFloat(pValue.replace(this._Value_MoneySign_Currency,'').replace(this._Regex_formatterDollarsRemoveCommas,'')).toFixed(2);}// If we didn't get a number, return the "not a number" string.
|
|
3022
|
-
if(isNaN(tmpDollarAmount)){return this._Value_NaN_Currency;}}// TODO: Get locale data and use that for this stuff.
|
|
3019
|
+
*/},{key:"formatterDollars",value:function formatterDollars(pValue,pPrecision,pRoundingMethod){if(isNaN(pValue)){return this._Value_NaN_Currency;}if(pValue===null||pValue===undefined){return this._Value_NaN_Currency;}var tmpDollarAmountArbitrary=this.fable.Math.parsePrecise(pValue);var tmpPrecision=typeof pPrecision=='undefined'?2:pPrecision;var tmpDollarAmount=this.fable.Math.toFixedPrecise(tmpDollarAmountArbitrary,tmpPrecision,pRoundingMethod);// TODO: Get locale data and use that for this stuff.
|
|
3023
3020
|
return"$".concat(this.formatterAddCommasToNumber(tmpDollarAmount));}/**
|
|
3024
3021
|
* Round a number to a certain number of digits. If the number is not a number, it will return 0. If no digits are specified, it will default to 2 significant digits.
|
|
3025
3022
|
*
|
|
@@ -3131,8 +3128,17 @@ return _this25.makeFolderRecursive(tmpParameters,fCallback);}else if(pCreateErro
|
|
|
3131
3128
|
return _this25.makeFolderRecursive(tmpParameters,fCallback);}else{console.log(pCreateError.code);return fCallback(pCreateError);}});}else{return _this25.makeFolderRecursive(tmpParameters,fCallback);}});}}]);return FableServiceFilePersistence;}(libFableServiceBase);module.exports=FableServiceFilePersistence;}).call(this);}).call(this,require('_process'));},{"_process":86,"fable-serviceproviderbase":51,"fs":19,"path":82,"readline":19}],135:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');/**
|
|
3132
3129
|
* Arbitrary Precision Math Operations
|
|
3133
3130
|
* @author Steven Velozo <steven@velozo.com>
|
|
3134
|
-
* @description Simple functions that perform arbitrary precision math operations and return string resultant values.
|
|
3135
|
-
*/var FableServiceMath=/*#__PURE__*/function(_libFableServiceBase5){_inherits(FableServiceMath,_libFableServiceBase5);function FableServiceMath(pFable,pOptions,pServiceHash){var _this26;_classCallCheck2(this,FableServiceMath);_this26=_callSuper(this,FableServiceMath,[pFable,pOptions,pServiceHash]);_this26.serviceType='Math';return _this26;}
|
|
3131
|
+
* @description Simple functions that perform arbitrary precision math operations and return string resultant values. Wraps big.js
|
|
3132
|
+
*/var FableServiceMath=/*#__PURE__*/function(_libFableServiceBase5){_inherits(FableServiceMath,_libFableServiceBase5);function FableServiceMath(pFable,pOptions,pServiceHash){var _this26;_classCallCheck2(this,FableServiceMath);_this26=_callSuper(this,FableServiceMath,[pFable,pOptions,pServiceHash]);_this26.serviceType='Math';return _this26;}/*
|
|
3133
|
+
Rounding Methods:
|
|
3134
|
+
|
|
3135
|
+
Property Value BigDecimal Equiv Description
|
|
3136
|
+
---------- ----- ---------------- -----------
|
|
3137
|
+
roundDown 0 ROUND_DOWN Rounds towards zero. (_I.e. truncate, no rounding._)
|
|
3138
|
+
roundHalfUp 1 ROUND_HALF_UP Rounds towards nearest neighbour. (_If equidistant, rounds away from zero._)
|
|
3139
|
+
roundHalfEven 2 ROUND_HALF_EVEN Rounds towards nearest neighbour. (_If equidistant, rounds towards even neighbour._)
|
|
3140
|
+
roundUp 3 ROUND_UP Rounds positively away from zero. (_Always round up._)
|
|
3141
|
+
*/_createClass2(FableServiceMath,[{key:"roundDown",get:function get(){return this.fable.Utility.bigNumber.roundDown;}},{key:"roundHalfUp",get:function get(){return this.fable.Utility.bigNumber.roundHalfUp;}},{key:"roundHalfEven",get:function get(){return this.fable.Utility.bigNumber.roundHalfEven;}},{key:"roundUp",get:function get(){return this.fable.Utility.bigNumber.roundUp;}},{key:"parsePrecise",value:function parsePrecise(pValue,pNonNumberValue){var tmpNumber;try{tmpNumber=new this.fable.Utility.bigNumber(pValue);}catch(pError){this.log.warn("Error parsing number (type ".concat(_typeof(pValue),"): ").concat(pError));tmpNumber=typeof pNonNumberValue==='undefined'?"0.0":pNonNumberValue;}return tmpNumber.toString();}},{key:"percentagePrecise",value:function percentagePrecise(pIs,pOf){var tmpLeftValue=isNaN(pIs)?0:pIs;var tmpRightValue=isNaN(pOf)?0:pOf;if(tmpRightValue==0){return'0';}var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpLeftValue);var tmpResult=tmpLeftArbitraryValue.div(tmpRightValue);tmpResult=tmpResult.times(100);return tmpResult.toString();}},{key:"roundPrecise",value:function roundPrecise(pValue,pDecimals,pRoundingMethod){var tmpValue=isNaN(pValue)?0:pValue;var tmpDecimals=isNaN(pDecimals)?0:pDecimals;var tmpRoundingMethod=typeof pRoundingMethod==='undefined'?this.roundHalfUp:pRoundingMethod;var tmpArbitraryValue=new this.fable.Utility.bigNumber(tmpValue);var tmpResult=tmpArbitraryValue.round(tmpDecimals,tmpRoundingMethod);return tmpResult.toString();}},{key:"toFixedPrecise",value:function toFixedPrecise(pValue,pDecimals,pRoundingMethod){var tmpValue=isNaN(pValue)?0:pValue;var tmpDecimals=isNaN(pDecimals)?0:pDecimals;var tmpRoundingMethod=typeof pRoundingMethod==='undefined'?this.roundHalfUp:pRoundingMethod;var tmpArbitraryValue=new this.fable.Utility.bigNumber(tmpValue);var tmpResult=tmpArbitraryValue.toFixed(tmpDecimals,tmpRoundingMethod);return tmpResult.toString();}},{key:"addPrecise",value:function addPrecise(pLeftValue,pRightValue){var tmpLeftValue=isNaN(pLeftValue)?0:pLeftValue;var tmpRightValue=isNaN(pRightValue)?0:pRightValue;var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpLeftValue);var tmpResult=tmpLeftArbitraryValue.plus(tmpRightValue);return tmpResult.toString();}},{key:"subtractPrecise",value:function subtractPrecise(pLeftValue,pRightValue){var tmpLeftValue=isNaN(pLeftValue)?0:pLeftValue;var tmpRightValue=isNaN(pRightValue)?0:pRightValue;var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpLeftValue);var tmpResult=tmpLeftArbitraryValue.minus(tmpRightValue);return tmpResult.toString();}},{key:"powerPrecise",value:function powerPrecise(pLeftValue,pRightValue){var tmpLeftValue=isNaN(pLeftValue)?0:pLeftValue;var tmpRightValue=isNaN(pRightValue)?0:pRightValue;var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpLeftValue);var tmpResult=tmpLeftArbitraryValue.pow(tmpRightValue);return tmpResult.toString();}},{key:"multiplyPrecise",value:function multiplyPrecise(pLeftValue,pRightValue){var tmpLeftValue=isNaN(pLeftValue)?0:pLeftValue;var tmpRightValue=isNaN(pRightValue)?0:pRightValue;var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpLeftValue);var tmpResult=tmpLeftArbitraryValue.times(tmpRightValue);return tmpResult.toString();}},{key:"dividePrecise",value:function dividePrecise(pLeftValue,pRightValue){var tmpLeftValue=isNaN(pLeftValue)?0:pLeftValue;var tmpRightValue=isNaN(pRightValue)?0:pRightValue;var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpLeftValue);var tmpResult=tmpLeftArbitraryValue.div(tmpRightValue);return tmpResult.toString();}},{key:"modPrecise",value:function modPrecise(pLeftValue,pRightValue){var tmpLeftValue=isNaN(pLeftValue)?0:pLeftValue;var tmpRightValue=isNaN(pRightValue)?0:pRightValue;var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpLeftValue);var tmpResult=tmpLeftArbitraryValue.mod(tmpRightValue);return tmpResult.toString();}},{key:"sqrtPrecise",value:function sqrtPrecise(pValue){var tmpValue=isNaN(pValue)?0:pValue;var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpValue);var tmpResult=tmpLeftArbitraryValue.sqrt();return tmpResult.toString();}},{key:"absPrecise",value:function absPrecise(pValue){var tmpValue=isNaN(pValue)?0:pValue;var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpValue);var tmpResult=tmpLeftArbitraryValue.abs();return tmpResult.toString();}},{key:"comparePrecise",value:function comparePrecise(pLeftValue,pRightValue){var tmpLeftValue=isNaN(pLeftValue)?0:pLeftValue;var tmpRightValue=isNaN(pRightValue)?0:pRightValue;var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpLeftValue);return tmpLeftArbitraryValue.cmp(tmpRightValue);}},{key:"gtPrecise",value:function gtPrecise(pLeftValue,pRightValue){var tmpLeftValue=isNaN(pLeftValue)?0:pLeftValue;var tmpRightValue=isNaN(pRightValue)?0:pRightValue;var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpLeftValue);return tmpLeftArbitraryValue.gt(tmpRightValue);}},{key:"gtePrecise",value:function gtePrecise(pLeftValue,pRightValue){var tmpLeftValue=isNaN(pLeftValue)?0:pLeftValue;var tmpRightValue=isNaN(pRightValue)?0:pRightValue;var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpLeftValue);return tmpLeftArbitraryValue.gte(tmpRightValue);}},{key:"ltPrecise",value:function ltPrecise(pLeftValue,pRightValue){var tmpLeftValue=isNaN(pLeftValue)?0:pLeftValue;var tmpRightValue=isNaN(pRightValue)?0:pRightValue;var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpLeftValue);return tmpLeftArbitraryValue.lt(tmpRightValue);}},{key:"ltePrecise",value:function ltePrecise(pLeftValue,pRightValue){var tmpLeftValue=isNaN(pLeftValue)?0:pLeftValue;var tmpRightValue=isNaN(pRightValue)?0:pRightValue;var tmpLeftArbitraryValue=new this.fable.Utility.bigNumber(tmpLeftValue);return tmpLeftArbitraryValue.lt(tmpRightValue);}}]);return FableServiceMath;}(libFableServiceBase);module.exports=FableServiceMath;},{"fable-serviceproviderbase":51}],136:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');/**
|
|
3136
3142
|
* Precedent Meta-Templating
|
|
3137
3143
|
* @author Steven Velozo <steven@velozo.com>
|
|
3138
3144
|
* @description Process text stream trie and postfix tree, parsing out meta-template expression functions.
|