fable 3.0.148 → 3.0.149
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 +42 -6
- 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 +19 -1
- package/source/services/Fable-Service-Math.js +39 -0
- package/source/services/Fable-Service-Utility.js +136 -6
- package/test/Utility_tests.js +77 -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.149","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"},"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.
|
|
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"},"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"},"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
|
|
@@ -3942,7 +3942,7 @@ 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
3946
|
* Finds the maximum value from a set of precise values.
|
|
3947
3947
|
*
|
|
3948
3948
|
* @param {Array|Object} pValueSet - The set of values to find the maximum from.
|
|
@@ -4217,9 +4217,45 @@ chunk(pInput,pChunkSize,pChunkCache){let tmpInputArray=[...pInput];// Note lodas
|
|
|
4217
4217
|
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
4218
|
* Get a value from fable/pict by hash/address
|
|
4219
4219
|
* @param {string} pValueAddress - The manyfest hash/address of the value to get
|
|
4220
|
-
*/
|
|
4221
|
-
|
|
4222
|
-
|
|
4220
|
+
*/getInternalValueByHash(pValueAddress){// Get the value from the internal manifest and return it
|
|
4221
|
+
return this.getValueByHash(this.fable,pValueAddress);}/**
|
|
4222
|
+
* Get a value from an object by hash/address
|
|
4223
|
+
* @param {object} pObject - The object to get the value from
|
|
4224
|
+
* @param {string} pValueAddress - The manyfest hash/address of the value to get
|
|
4225
|
+
* @param {object} [pManifest] - The manyfest object to use; constructs one inline if not provided
|
|
4226
|
+
* @returns {object} - The value from the object
|
|
4227
|
+
*/getValueByHash(pObject,pValueAddress,pManifest){let tmpManifest=pManifest;if(typeof tmpManifest=='undefined'){// Lazily create a manifest if it doesn't exist
|
|
4228
|
+
if(!this.manifest){this.manifest=this.fable.newManyfest();}tmpManifest=this.manifest;}// Get the value from the internal manifest and return it
|
|
4229
|
+
return tmpManifest.getValueByHash(pObject,pValueAddress);}/**
|
|
4230
|
+
* Get a value array from an object by hash/address list
|
|
4231
|
+
* @param {object} pObject - The object to get the value from
|
|
4232
|
+
* @param {string} pValueAddress - The manyfest hash/address of the value to get
|
|
4233
|
+
* @param {object} [pManifest] - The manyfest object to use; constructs one inline if not provided
|
|
4234
|
+
* @returns {Array} - The value array built from the hash list
|
|
4235
|
+
*/createValueArrayByHashes(pObject,pValueHashes,pManifest){let tmpManifest=pManifest;if(typeof tmpManifest=='undefined'){// Lazily create a manifest if it doesn't exist
|
|
4236
|
+
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
|
|
4237
|
+
return tmpValueArray;}/**
|
|
4238
|
+
* Get a value array by hash/address list from the internal fable/pict state
|
|
4239
|
+
* @param {string} pValueAddress - The manyfest hash/address of the value to get
|
|
4240
|
+
* @param {object} [pManifest] - The manyfest object to use; constructs one inline if not provided
|
|
4241
|
+
* @returns {Array} - The value array built from the hash list
|
|
4242
|
+
*/createValueArrayByHashesFromInternal(pValueHashes,pManifest){return this.createValueArrayByHashes(this.fable,pValueHashes,pManifest);}createValueArrayByHashParametersFromInternal(){let tmpValueHashes=Array.prototype.slice.call(arguments);return this.createValueArrayByHashes(this.fable,tmpValueHashes);}/**
|
|
4243
|
+
* Get a value object from a list of hash/addressese
|
|
4244
|
+
* @param {object} pObject - The object to get the value from
|
|
4245
|
+
* @param {string} pValueAddress - The manyfest hash/address of the value to get
|
|
4246
|
+
* @param {object} [pManifest] - The manyfest object to use; constructs one inline if not provided
|
|
4247
|
+
* @returns {Array} - The value object built from the hash list
|
|
4248
|
+
*/createValueObjectByHashes(pObject,pValueHashes,pManifest){let tmpManifest=pManifest;if(typeof tmpManifest=='undefined'){// Lazily create a manifest if it doesn't exist
|
|
4249
|
+
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
|
|
4250
|
+
return tmpValueObject;}/**
|
|
4251
|
+
* Get a value object by hash/address list from the internal fable/pict state
|
|
4252
|
+
* @param {string} pValueAddress - The manyfest hash/address of the value to get
|
|
4253
|
+
* @param {object} [pManifest] - The manyfest object to use; constructs one inline if not provided
|
|
4254
|
+
* @returns {object} - The value object built from the hash list
|
|
4255
|
+
*/createValueObjectByHashesFromInternal(pValueHashes,pManifest){return this.createValueObjectByHashes(this.fable,pValueHashes,pManifest);}/**
|
|
4256
|
+
* Get a value object by hash/address list as parameters from the internal fable/pict state
|
|
4257
|
+
* @returns {Array} - The value array built from the hash list
|
|
4258
|
+
*/createValueObjectByHashParametersFromInternal(){let tmpValueHashes=Array.prototype.slice.call(arguments);return this.createValueObjectByHashes(this.fable,tmpValueHashes);}/**
|
|
4223
4259
|
* Check if a value is null or empty
|
|
4224
4260
|
* @param {object} pObject - The object to check
|
|
4225
4261
|
* @param {string} pValueAddress - The manyfest hash/address to check
|