fable 3.0.148 → 3.0.150
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.js +70 -7
- package/dist/fable.min.js +2 -2
- package/dist/fable.min.js.map +1 -1
- package/package.json +1 -1
- package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-FunctionMap.json +35 -2
- package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-SolvePostfixedExpression.js +5 -1
- package/source/services/Fable-Service-Math.js +204 -0
- package/source/services/Fable-Service-Utility.js +167 -6
- package/test/ExpressionParser_tests.js +34 -0
- package/test/Math_test.js +60 -0
- package/test/Utility_tests.js +77 -0
- package/test/data/cities.json +9002 -0
package/dist/fable.js
CHANGED
|
@@ -3012,7 +3012,7 @@ try{if(!global.localStorage)return false;}catch(_){return false;}var val=global.
|
|
|
3012
3012
|
// presumably different callback function.
|
|
3013
3013
|
// This makes sure that own properties are retained, so that
|
|
3014
3014
|
// decorations and such are not lost along the way.
|
|
3015
|
-
module.exports=wrappy;function wrappy(fn,cb){if(fn&&cb)return wrappy(fn)(cb);if(typeof fn!=='function')throw new TypeError('need wrapper function');Object.keys(fn).forEach(function(k){wrapper[k]=fn[k];});return wrapper;function wrapper(){var args=new Array(arguments.length);for(var i=0;i<args.length;i++){args[i]=arguments[i];}var ret=fn.apply(this,args);var cb=args[args.length-1];if(typeof ret==='function'&&ret!==cb){Object.keys(cb).forEach(function(k){ret[k]=cb[k];});}return ret;}}},{}],130:[function(require,module,exports){module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;}},{}],131:[function(require,module,exports){module.exports={"name":"fable","version":"3.0.
|
|
3015
|
+
module.exports=wrappy;function wrappy(fn,cb){if(fn&&cb)return wrappy(fn)(cb);if(typeof fn!=='function')throw new TypeError('need wrapper function');Object.keys(fn).forEach(function(k){wrapper[k]=fn[k];});return wrapper;function wrapper(){var args=new Array(arguments.length);for(var i=0;i<args.length;i++){args[i]=arguments[i];}var ret=fn.apply(this,args);var cb=args[args.length-1];if(typeof ret==='function'&&ret!==cb){Object.keys(cb).forEach(function(k){ret[k]=cb[k];});}return ret;}}},{}],130:[function(require,module,exports){module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;}},{}],131:[function(require,module,exports){module.exports={"name":"fable","version":"3.0.150","description":"A service dependency injection, configuration and logging library.","main":"source/Fable.js","scripts":{"start":"node source/Fable.js","coverage":"./node_modules/.bin/nyc --reporter=lcov --reporter=text-lcov ./node_modules/mocha/bin/_mocha -- -u tdd -R spec","test":"./node_modules/.bin/mocha -u tdd -R spec","build":"npx quack build","docker-dev-build":"docker build ./ -f Dockerfile_LUXURYCode -t fable-image:local","docker-dev-run":"docker run -it -d --name fable-dev -p 30001:8080 -p 38086:8086 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/fable\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" fable-image:local","docker-dev-shell":"docker exec -it fable-dev /bin/bash","tests":"./node_modules/mocha/bin/_mocha -u tdd --exit -R spec --grep"},"mocha":{"diff":true,"extension":["js"],"package":"./package.json","reporter":"spec","slow":"75","timeout":"5000","ui":"tdd","watch-files":["source/**/*.js","test/**/*.js"],"watch-ignore":["lib/vendor"]},"browser":{"./source/service/Fable-Service-EnvironmentData.js":"./source/service/Fable-Service-EnvironmentData-Web.js","./source/service/Fable-Service-FilePersistence.js":"./source/service/Fable-Service-FilePersistence-Web.js"},"repository":{"type":"git","url":"https://github.com/stevenvelozo/fable.git"},"keywords":["entity","behavior"],"author":"Steven Velozo <steven@velozo.com> (http://velozo.com/)","license":"MIT","bugs":{"url":"https://github.com/stevenvelozo/fable/issues"},"homepage":"https://github.com/stevenvelozo/fable","devDependencies":{"quackage":"^1.0.36"},"dependencies":{"async.eachlimit":"^0.5.2","async.waterfall":"^0.5.2","big.js":"^6.2.2","cachetrax":"^1.0.4","cookie":"^0.6.0","data-arithmatic":"^1.0.7","dayjs":"^1.11.13","fable-log":"^3.0.16","fable-serviceproviderbase":"^3.0.15","fable-settings":"^3.0.12","fable-uuid":"^3.0.11","manyfest":"^1.0.38","simple-get":"^4.0.1"}};},{}],132:[function(require,module,exports){/**
|
|
3016
3016
|
* Fable Application Services Support Library
|
|
3017
3017
|
* @author <steven@velozo.com>
|
|
3018
3018
|
*/ // Pre-init services
|
|
@@ -3562,7 +3562,7 @@ tmpCurrentTokenType='Value';tmpCurrentToken+=tmpCharacter;// continue;
|
|
|
3562
3562
|
// }
|
|
3563
3563
|
// tmpResults.ExpressionParserLog.push(`ExpressionParser.tokenize found an unknown character code ${tmpCharCode} character ${tmpCharacter} in the expression: ${pExpression} at index ${i}`);
|
|
3564
3564
|
// this.log.warn(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);
|
|
3565
|
-
}if(tmpCurrentTokenType&&tmpCurrentToken.length>0){tmpResults.RawTokens.push(tmpCurrentToken);}return tmpResults.RawTokens;}}module.exports=ExpressionTokenizer;},{"./Fable-Service-ExpressionParser-Base.js":141}],143:[function(require,module,exports){module.exports={"sqrt":{"Name":"Square Root","Address":"fable.Math.sqrtPrecise"},"abs":{"Name":"Absolute Value","Address":"fable.Math.absPrecise"},"rad":{"Name":"Degrees to Radians","Address":"fable.Math.radPrecise"},"pi":{"Name":"Pi","Address":"fable.Math.piPrecise"},"sin":{"Name":"Sine","Address":"fable.Math.sin"},"cos":{"Name":"Cosine","Address":"fable.Math.cos"},"tan":{"Name":"Tangent","Address":"fable.Math.tan"},"count":{"Name":"Count Set Elements","Address":"fable.Math.countSetElements"},"sortset":{"Name":"Sort Set","Address":"fable.Math.sortSetPrecise"},"bucketset":{"Name":"Bucket Set","Address":"fable.Math.bucketSetPrecise"},"sorthistogram":{"Name":"Sort Histogram","Address":"fable.Math.sortHistogramPrecise"},"max":{"Name":"Maximum","Address":"fable.Math.maxPrecise"},"min":{"Name":"Minimum","Address":"fable.Math.minPrecise"},"sum":{"Name":"Sum","Address":"fable.Math.sumPrecise"},"avg":{"Name":"Average","Address":"fable.Math.averagePrecise"},"mean":{"Name":"Mean","Address":"fable.Math.meanPrecise"},"median":{"Name":"Median","Address":"fable.Math.medianPrecise"},"mode":{"Name":"Mode","Address":"fable.Math.modePrecise"},"round":{"Name":"Round","Address":"fable.Math.roundPrecise"},"
|
|
3565
|
+
}if(tmpCurrentTokenType&&tmpCurrentToken.length>0){tmpResults.RawTokens.push(tmpCurrentToken);}return tmpResults.RawTokens;}}module.exports=ExpressionTokenizer;},{"./Fable-Service-ExpressionParser-Base.js":141}],143:[function(require,module,exports){module.exports={"sqrt":{"Name":"Square Root","Address":"fable.Math.sqrtPrecise"},"abs":{"Name":"Absolute Value","Address":"fable.Math.absPrecise"},"rad":{"Name":"Degrees to Radians","Address":"fable.Math.radPrecise"},"pi":{"Name":"Pi","Address":"fable.Math.piPrecise"},"sin":{"Name":"Sine","Address":"fable.Math.sin"},"cos":{"Name":"Cosine","Address":"fable.Math.cos"},"tan":{"Name":"Tangent","Address":"fable.Math.tan"},"count":{"Name":"Count Set Elements","Address":"fable.Math.countSetElements"},"sortset":{"Name":"Sort Set","Address":"fable.Math.sortSetPrecise"},"bucketset":{"Name":"Bucket Set","Address":"fable.Math.bucketSetPrecise"},"sorthistogram":{"Name":"Sort Histogram","Address":"fable.Math.sortHistogramPrecise"},"max":{"Name":"Maximum","Address":"fable.Math.maxPrecise"},"min":{"Name":"Minimum","Address":"fable.Math.minPrecise"},"sum":{"Name":"Sum","Address":"fable.Math.sumPrecise"},"avg":{"Name":"Average","Address":"fable.Math.averagePrecise"},"mean":{"Name":"Mean","Address":"fable.Math.meanPrecise"},"median":{"Name":"Median","Address":"fable.Math.medianPrecise"},"mode":{"Name":"Mode","Address":"fable.Math.modePrecise"},"round":{"Name":"Round","Address":"fable.Math.roundPrecise"},"cumulativesummation":{"Name":"Count Set Elements in a Histogram or Value Map","Address":"fable.Math.cumulativeSummation"},"countsetelements":{"Name":"Count Set Elements in a Histogram or Value Map","Address":"fable.Math.countSetElements"},"getvalue":{"Name":"Get Value from Application State or Services (AppData, etc.)","Address":"fable.Utility.getInternalValueByHash"},"aggregationhistogram":{"Name":"Generate a Histogram by Exact Value Aggregation","Address":"fable.Math.histogramAggregationByExactValueFromInternalState"},"distributionhistogram":{"Name":"Generate a Histogram Based on Value Distribution","Address":"fable.Math.histogramDistributionByExactValueFromInternalState"},"getvaluearray":{"Name":"Get Value Array from Application State or Services (AppData, etc.)","Address":"fable.Utility.createValueArrayByHashParametersFromInternal"},"getvalueobject":{"Name":"Get Value Object from Application State or Services (AppData, etc.)","Address":"fable.Utility.createValueObjectByHashParametersFromInternal"},"cleanvaluearray":{"Name":"Clean Value Array","Address":"fable.Math.cleanValueArray"},"cleanvalueobject":{"Name":"Clean Value Object","Address":"fable.Math.cleanValueObject"},"randominteger":{"Name":"Random Integer","Address":"fable.DataGeneration.randomInteger"},"randomintegerbetween":{"Name":"Random Integer Between Two Numbers","Address":"fable.DataGeneration.randomIntegerBetween"},"randomintegerupto":{"Name":"Random Integer","Address":"fable.DataGeneration.randomIntegerUpTo"},"randomfloat":{"Name":"Random Float","Address":"fable.DataGeneration.randomFloat"},"randomfloatbetween":{"Name":"Random Float","Address":"fable.DataGeneration.randomFloatBetween"},"randomfloatupto":{"Name":"Random Float","Address":"fable.DataGeneration.randomFloatUpTo"}};},{}],144:[function(require,module,exports){const libExpressionParserOperationBase=require('./Fable-Service-ExpressionParser-Base.js');class ExpressionParserLinter extends libExpressionParserOperationBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='ExpressionParser-Linter';}lintTokenizedExpression(pTokenizedExpression,pResultObject){let tmpResults=typeof pResultObject==='object'?pResultObject:{ExpressionParserLog:[]};tmpResults.LinterResults=[];// Guard against bad data being passed in
|
|
3566
3566
|
if(!Array.isArray(pTokenizedExpression)){tmpResults.ExpressionParserLog.push(`ERROR: ExpressionParser.lintTokenizedExpression was passed a non-array tokenized expression.`);tmpResults.LinterResults.push(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);return pTokenizedExpression;}if(pTokenizedExpression.length<1){tmpResults.ExpressionParserLog.push(`ERROR: ExpressionParser.lintTokenizedExpression was passed an empty tokenized expression.`);tmpResults.LinterResults.push(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);return pTokenizedExpression;}// 1. Check for balanced parenthesis
|
|
3567
3567
|
let tmpParenthesisDepth=0;// If it is in a state address, we don't care about the parenthesis
|
|
3568
3568
|
// State addresses are between squiggly brackets
|
|
@@ -3713,7 +3713,7 @@ tmpManifest.setValueAtAddress(tmpResults.VirtualSymbols,pPostfixedExpression[i].
|
|
|
3713
3713
|
if(pPostfixedExpression[i].Operation.Descriptor.OnlyEmpty){// If it is only on "empty" values, check if the value is empty before assigning
|
|
3714
3714
|
if(this.fable.Utility.addressIsNullOrEmpty(tmpDataDestinationObject,pPostfixedExpression[i].VirtualSymbolName)){tmpManifest.setValueByHash(tmpDataDestinationObject,pPostfixedExpression[i].VirtualSymbolName,tmpSolverResultValue);}}else{// Otherwise, just assign it.
|
|
3715
3715
|
tmpManifest.setValueByHash(tmpDataDestinationObject,pPostfixedExpression[i].VirtualSymbolName,tmpSolverResultValue);}}}tmpResults.RawResult=tmpSolverResultValue;// Clean up the fable reference if we added it to the object.
|
|
3716
|
-
if(!tmpPassedInFable){delete tmpResults.fable;}if(typeof tmpSolverResultValue!=='undefined'){return tmpSolverResultValue.toString();}else{return tmpSolverResultValue;}}}module.exports=ExpressionParserSolver;},{"./Fable-Service-ExpressionParser-Base.js":141}],148:[function(require,module,exports){module.exports={"=":{"Name":"Assign Value","Token":"=","Function":"fable.Math.assignValue","Precedence":0,"Type":"Assignment"},"?=":{"Name":"Null or Empty Coalescing Assign Value","Token":"?=","Function":"fable.Math.assignValue","OnlyEmpty":true,"Precedence":0,"Type":"Assignment"},"(":{"Name":"Left Parenthesis","Token":"(","Precedence":0,"Type":"Parenthesis"},")":{"Name":"Right Parenthesis","Token":")","Precedence":0,"Type":"Parenthesis"},",":{"Name":"Set Concatenate","Token":",","Function":"fable.Math.setConcatenate","Precedence":4,"Type":"Operator"},"*":{"Name":"Multiply","Token":"*","Function":"fable.Math.multiplyPrecise","Precedence":3,"Type":"Operator"},"/":{"Name":"Divide","Token":"/","Function":"fable.Math.dividePrecise","Precedence":3,"Type":"Operator"},"^":{"Name":"Exponent","Token":"^","Function":"fable.Math.powerPrecise","Precedence":1,"Type":"Operator"},"%":{"Name":"Modulus","Token":"%","Function":"fable.Math.modPrecise","Precedence":3,"Type":"Operator"},"+":{"Name":"Add","Token":"+","Function":"fable.Math.addPrecise","Precedence":4,"Type":"Operator"},"-":{"Name":"Subtract","Token":"-","Function":"fable.Math.subtractPrecise","Precedence":4,"Type":"Operator"}};},{}],149:[function(require,module,exports){const libExpressionParserOperationBase=require('./Fable-Service-ExpressionParser-Base.js');class ExpressionParserValueMarshal extends libExpressionParserOperationBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='ExpressionParser-ValueMarshal';}/**
|
|
3716
|
+
if(!tmpPassedInFable){delete tmpResults.fable;}if(typeof tmpSolverResultValue==='object'){return tmpSolverResultValue;}else if(typeof tmpSolverResultValue!=='undefined'){return tmpSolverResultValue.toString();}else{return tmpSolverResultValue;}}}module.exports=ExpressionParserSolver;},{"./Fable-Service-ExpressionParser-Base.js":141}],148:[function(require,module,exports){module.exports={"=":{"Name":"Assign Value","Token":"=","Function":"fable.Math.assignValue","Precedence":0,"Type":"Assignment"},"?=":{"Name":"Null or Empty Coalescing Assign Value","Token":"?=","Function":"fable.Math.assignValue","OnlyEmpty":true,"Precedence":0,"Type":"Assignment"},"(":{"Name":"Left Parenthesis","Token":"(","Precedence":0,"Type":"Parenthesis"},")":{"Name":"Right Parenthesis","Token":")","Precedence":0,"Type":"Parenthesis"},",":{"Name":"Set Concatenate","Token":",","Function":"fable.Math.setConcatenate","Precedence":4,"Type":"Operator"},"*":{"Name":"Multiply","Token":"*","Function":"fable.Math.multiplyPrecise","Precedence":3,"Type":"Operator"},"/":{"Name":"Divide","Token":"/","Function":"fable.Math.dividePrecise","Precedence":3,"Type":"Operator"},"^":{"Name":"Exponent","Token":"^","Function":"fable.Math.powerPrecise","Precedence":1,"Type":"Operator"},"%":{"Name":"Modulus","Token":"%","Function":"fable.Math.modPrecise","Precedence":3,"Type":"Operator"},"+":{"Name":"Add","Token":"+","Function":"fable.Math.addPrecise","Precedence":4,"Type":"Operator"},"-":{"Name":"Subtract","Token":"-","Function":"fable.Math.subtractPrecise","Precedence":4,"Type":"Operator"}};},{}],149:[function(require,module,exports){const libExpressionParserOperationBase=require('./Fable-Service-ExpressionParser-Base.js');class ExpressionParserValueMarshal extends libExpressionParserOperationBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='ExpressionParser-ValueMarshal';}/**
|
|
3717
3717
|
* Substitutes values in tokenized objects based on the provided data source and manifest.
|
|
3718
3718
|
*
|
|
3719
3719
|
* TODO: Move this to its own file in the "Fable-Service-ExpressionParser" directory.
|
|
@@ -3942,7 +3942,25 @@ return 1;}return 0;}/**
|
|
|
3942
3942
|
*
|
|
3943
3943
|
* @param {Object} pHistogram - The histogram object to be sorted.
|
|
3944
3944
|
* @returns {Object} - The sorted histogram object.
|
|
3945
|
-
*/sortHistogramPrecise(pHistogram){let tmpSortedHistogram={};let tmpKeys=Object.keys(pHistogram);tmpKeys.sort((pLeft,pRight)=>{return pHistogram[pLeft]-pHistogram[pRight];});for(let i=0;i<tmpKeys.length;i++){tmpSortedHistogram[tmpKeys[i]]=pHistogram[tmpKeys[i]];}return tmpSortedHistogram;}/**
|
|
3945
|
+
*/sortHistogramPrecise(pHistogram){let tmpSortedHistogram={};let tmpKeys=Object.keys(pHistogram);tmpKeys.sort((pLeft,pRight)=>{return pHistogram[pLeft]-pHistogram[pRight];});for(let i=0;i<tmpKeys.length;i++){tmpSortedHistogram[tmpKeys[i]]=pHistogram[tmpKeys[i]];}return tmpSortedHistogram;}cleanValueArray(pValueArray){if(!Array.isArray(pValueArray)){return[];}let tmpCleanedArray=[];for(let i=0;i<pValueArray.length;i++){let tmpValue=this.parsePrecise(pValueArray[i],NaN);if(!isNaN(tmpValue)){tmpCleanedArray.push(tmpValue);}}return tmpCleanedArray;}cleanValueObject(pValueObject){if(typeof pValueObject!=='object'){return{};}let tmpCleanedObject={};let tmpKeys=Object.keys(pValueObject);for(let i=0;i<tmpKeys.length;i++){let tmpValue=this.parsePrecise(pValueObject[tmpKeys[i]],NaN);if(!isNaN(tmpValue)){tmpCleanedObject[tmpKeys[i]]=tmpValue;}}return tmpCleanedObject;}/**
|
|
3946
|
+
* Make a histogram of representative counts for exact values (.tostring() is the keys to count)
|
|
3947
|
+
* @param {Array} pValueSet
|
|
3948
|
+
* @param {string} pValueAddress
|
|
3949
|
+
*/histogramDistributionByExactValue(pValueObjectSet,pValueAddress,pManifest){if(!Array.isArray(pValueObjectSet)){return pValueObjectSet;}if(!pValueAddress){return{};}let tmpHistogram={};for(let i=0;i<pValueObjectSet.length;i++){let tmpValue=this.fable.Utility.getValueByHash(pValueObjectSet[i],pValueAddress,pManifest).toString();if(!(tmpValue in tmpHistogram)){tmpHistogram[tmpValue]=0;}tmpHistogram[tmpValue]=tmpHistogram[tmpValue]+1;}return tmpHistogram;}histogramDistributionByExactValueFromInternalState(pValueObjectSetAddress,pValueAddress){if(!pValueObjectSetAddress){return{};}let tmpValueObjectSet=this.fable.Utility.getInternalValueByHash(pValueObjectSetAddress);return this.histogramDistributionByExactValue(tmpValueObjectSet,pValueAddress);}/**
|
|
3950
|
+
* Make a histogram of representative counts for exact values (.tostring() is the keys to count)
|
|
3951
|
+
* @param {Array} pValueSet
|
|
3952
|
+
* @param {string} pValueAddress
|
|
3953
|
+
*/histogramAggregationByExactValue(pValueObjectSet,pValueAddress,pValueAmountAddress,pManifest){if(!Array.isArray(pValueObjectSet)){return pValueObjectSet;}if(!pValueAddress||!pValueAmountAddress){return{};}let tmpHistogram={};for(let i=0;i<pValueObjectSet.length;i++){let tmpValue=this.fable.Utility.getValueByHash(pValueObjectSet[i],pValueAddress,pManifest).toString();let tmpAmount=this.parsePrecise(this.fable.Utility.getValueByHash(pValueObjectSet[i],pValueAmountAddress,pManifest),NaN);if(!(tmpValue in tmpHistogram)){tmpHistogram[tmpValue]=0;}if(!isNaN(tmpAmount)){tmpHistogram[tmpValue]=this.addPrecise(tmpHistogram[tmpValue],tmpAmount);}}return tmpHistogram;}histogramAggregationByExactValueFromInternalState(pValueObjectSetAddress,pValueAddress,pValueAmountAddress){if(!pValueObjectSetAddress){return{};}let tmpValueObjectSet=this.fable.Utility.getInternalValueByHash(pValueObjectSetAddress);return this.histogramAggregationByExactValue(tmpValueObjectSet,pValueAddress,pValueAmountAddress);}/**
|
|
3954
|
+
* Given a value object set (an array of objects), find a specific entry when
|
|
3955
|
+
* sorted by a specific value address. Supports -1 syntax for last entry.
|
|
3956
|
+
* @param {Array} pValueObjectSet
|
|
3957
|
+
* @param {string} pValueAddress
|
|
3958
|
+
* @param {Object} pManifest
|
|
3959
|
+
*/entryInSet(pValueObjectSet,pValueAddress,pEntryIndex){if(!Array.isArray(pValueObjectSet)){return pValueObjectSet;}if(!pValueAddress){return false;}if(isNaN(pEntryIndex)||pEntryIndex>=pValueObjectSet.length){return false;}let tmpValueArray=pValueObjectSet.toSorted((pLeft,pRight)=>{return this.comparePrecise(pLeft,pRight);});let tmpIndex=pEntryIndex===-1?tmpValueArray.length-1:pEntryIndex;return tmpValueArray[tmpIndex];}smallestInSet(pValueObjectSet,pValueAddress){return this.entryInSet(pValueObjectSet,pValueAddress,0);}largestInSet(pValueObjectSet,pValueAddress){return this.entryInSet(pValueObjectSet,pValueAddress,-1);}/**
|
|
3960
|
+
* Expects an array of objects, and an address in each object to sum. Expects
|
|
3961
|
+
* an address to put the cumulative summation as well.
|
|
3962
|
+
* @param {Array} pValueObjectSet
|
|
3963
|
+
*/cumulativeSummation(pValueObjectSet,pValueAddress,pCumulationResultAddress,pManifest){if(!Array.isArray(pValueObjectSet)){return pValueObjectSet;}if(!pValueAddress||!pCumulationResultAddress){return pValueObjectSet;}let tmpSummationValue='0.0';for(let i=0;i<pValueObjectSet.length;i++){let tmpValue=this.parsePrecise(this.fable.Utility.getValueByHash(pValueObjectSet[i],pValueAddress,pManifest));if(isNaN(tmpValue)){this.fable.Utility.setValueByHash(pValueObjectSet[i],pCumulationResultAddress,tmpSummationValue,pManifest);continue;}tmpSummationValue=this.addPrecise(tmpValue,tmpSummationValue);this.fable.Utility.setValueByHash(pValueObjectSet[i],pCumulationResultAddress,tmpSummationValue,pManifest);}return pValueObjectSet;}/**
|
|
3946
3964
|
* Finds the maximum value from a set of precise values.
|
|
3947
3965
|
*
|
|
3948
3966
|
* @param {Array|Object} pValueSet - The set of values to find the maximum from.
|
|
@@ -4217,9 +4235,54 @@ chunk(pInput,pChunkSize,pChunkCache){let tmpInputArray=[...pInput];// Note lodas
|
|
|
4217
4235
|
let tmpChunkSize=typeof pChunkSize=='number'?pChunkSize:0;let tmpChunkCache=typeof pChunkCache!='undefined'?pChunkCache:[];if(tmpChunkSize<=0){return tmpChunkCache;}while(tmpInputArray.length){tmpChunkCache.push(tmpInputArray.splice(0,tmpChunkSize));}return tmpChunkCache;}/**
|
|
4218
4236
|
* Get a value from fable/pict by hash/address
|
|
4219
4237
|
* @param {string} pValueAddress - The manyfest hash/address of the value to get
|
|
4220
|
-
*/
|
|
4221
|
-
|
|
4222
|
-
|
|
4238
|
+
*/getInternalValueByHash(pValueAddress){// Get the value from the internal manifest and return it
|
|
4239
|
+
return this.getValueByHash(this.fable,pValueAddress);}/**
|
|
4240
|
+
* Get a value from an object by hash/address
|
|
4241
|
+
* @param {object} pObject - The object to get the value from
|
|
4242
|
+
* @param {string} pValueAddress - The manyfest hash/address of the value to get
|
|
4243
|
+
* @param {object} [pManifest] - The manyfest object to use; constructs one inline if not provided
|
|
4244
|
+
* @returns {object} - The value from the object
|
|
4245
|
+
*/getValueByHash(pObject,pValueAddress,pManifest){let tmpManifest=pManifest;if(typeof tmpManifest=='undefined'){// Lazily create a manifest if it doesn't exist
|
|
4246
|
+
if(!this.manifest){this.manifest=this.fable.newManyfest();}tmpManifest=this.manifest;}// Get the value from the internal manifest and return it
|
|
4247
|
+
return tmpManifest.getValueByHash(pObject,pValueAddress);}/**
|
|
4248
|
+
* Set a value to an object by hash/address
|
|
4249
|
+
* @param {object} pObject - The object to get the value from
|
|
4250
|
+
* @param {string} pValueAddress - The manyfest hash/address of the value to get
|
|
4251
|
+
* @param {object} pValue - The value to set
|
|
4252
|
+
* @param {object} [pManifest] - The manyfest object to use; constructs one inline if not provided
|
|
4253
|
+
* @returns {object} - The value from the object
|
|
4254
|
+
*/setValueByHash(pObject,pValueAddress,pValue,pManifest){let tmpManifest=pManifest;if(typeof tmpManifest=='undefined'){// Lazily create a manifest if it doesn't exist
|
|
4255
|
+
if(!this.manifest){this.manifest=this.fable.newManyfest();}tmpManifest=this.manifest;}// Get the value from the internal manifest and return it
|
|
4256
|
+
return tmpManifest.setValueByHash(pObject,pValueAddress,pValue);}/**
|
|
4257
|
+
* Get a value array from an object by hash/address list
|
|
4258
|
+
* @param {object} pObject - The object to get the value from
|
|
4259
|
+
* @param {string} pValueAddress - The manyfest hash/address of the value to get
|
|
4260
|
+
* @param {object} [pManifest] - The manyfest object to use; constructs one inline if not provided
|
|
4261
|
+
* @returns {Array} - The value array built from the hash list
|
|
4262
|
+
*/createValueArrayByHashes(pObject,pValueHashes,pManifest){let tmpManifest=pManifest;if(typeof tmpManifest=='undefined'){// Lazily create a manifest if it doesn't exist
|
|
4263
|
+
if(!this.manifest){this.manifest=this.fable.newManyfest();}tmpManifest=this.manifest;}if(!Array.isArray(pValueHashes)){return[];}let tmpValueArray=[];for(let i=0;i<pValueHashes.length;i++){tmpValueArray.push(tmpManifest.getValueByHash(pObject,pValueHashes[i]));}// Get the value from the internal manifest and return it
|
|
4264
|
+
return tmpValueArray;}/**
|
|
4265
|
+
* Get a value array by hash/address list from the internal fable/pict state
|
|
4266
|
+
* @param {string} pValueAddress - The manyfest hash/address of the value to get
|
|
4267
|
+
* @param {object} [pManifest] - The manyfest object to use; constructs one inline if not provided
|
|
4268
|
+
* @returns {Array} - The value array built from the hash list
|
|
4269
|
+
*/createValueArrayByHashesFromInternal(pValueHashes,pManifest){return this.createValueArrayByHashes(this.fable,pValueHashes,pManifest);}createValueArrayByHashParametersFromInternal(){if(arguments.length<2){return[];}let tmpValueHashes=Array.prototype.slice.call(arguments);return this.createValueArrayByHashes(this.fable,tmpValueHashes);}/**
|
|
4270
|
+
* Get a value object from a list of hash/addressese
|
|
4271
|
+
* @param {object} pObject - The object to get the value from
|
|
4272
|
+
* @param {string} pValueAddress - The manyfest hash/address of the value to get
|
|
4273
|
+
* @param {object} [pManifest] - The manyfest object to use; constructs one inline if not provided
|
|
4274
|
+
* @returns {Array} - The value object built from the hash list
|
|
4275
|
+
*/createValueObjectByHashes(pObject,pValueHashes,pManifest){let tmpManifest=pManifest;if(typeof tmpManifest=='undefined'){// Lazily create a manifest if it doesn't exist
|
|
4276
|
+
if(!this.manifest){this.manifest=this.fable.newManyfest();}tmpManifest=this.manifest;}if(!Array.isArray(pValueHashes)){return{};}let tmpValueObject={};for(let i=0;i<pValueHashes.length;i++){tmpValueObject[pValueHashes[i]]=tmpManifest.getValueByHash(pObject,pValueHashes[i]);}// Get the value from the internal manifest and return it
|
|
4277
|
+
return tmpValueObject;}/**
|
|
4278
|
+
* Get a value object by hash/address list from the internal fable/pict state
|
|
4279
|
+
* @param {string} pValueAddress - The manyfest hash/address of the value to get
|
|
4280
|
+
* @param {object} [pManifest] - The manyfest object to use; constructs one inline if not provided
|
|
4281
|
+
* @returns {object} - The value object built from the hash list
|
|
4282
|
+
*/createValueObjectByHashesFromInternal(pValueHashes,pManifest){return this.createValueObjectByHashes(this.fable,pValueHashes,pManifest);}/**
|
|
4283
|
+
* Get a value object by hash/address list as parameters from the internal fable/pict state
|
|
4284
|
+
* @returns {Array} - The value array built from the hash list
|
|
4285
|
+
*/createValueObjectByHashParametersFromInternal(){let tmpValueHashes=Array.prototype.slice.call(arguments);return this.createValueObjectByHashes(this.fable,tmpValueHashes);}/**
|
|
4223
4286
|
* Check if a value is null or empty
|
|
4224
4287
|
* @param {object} pObject - The object to check
|
|
4225
4288
|
* @param {string} pValueAddress - The manyfest hash/address to check
|