UNPKG

js-lightning

Version:

Direct Javascript to Web interpreted server inspired by PHP

79 lines (57 loc) 1.76 kB
'use strict'; //START OF moduleFunction() ============================================================ const moduleFunction = function(args) { //this module is initialized with parameters spec'd in the main function module const completeStepActual = ({verbose=false, logErrors=false, moduleName}) => ( methodName, thisStepMessage, thisStepResult, thisStepEvalFunction ) => { const thisStepPass = thisStepEvalFunction(thisStepResult); if (logErrors && !thisStepPass) { console.log(`FAIL TEST: ${thisStepMessage} in ...${moduleName}`); } if (verbose) { console.log(`Result for: ${methodName} (${thisStepPass?'PASS':'FAIL'}):`); console.dir(thisStepResult); console.log('\n\n'); } return passingTests && thisStepPass; }; const completeStep = completeStepActual(args); let passingTests = true; let thisStepMessage; let thisStepResult; let thisStepEvalFunction; let methodName; //TESTS ============================================================ const referencedObject={ string:'hello', object:{ hello:'goodbye' }, array:[ { a:'b', c:'d' } ] } const testArray = referencedObject; //TEST ITEM ------------------------------------------------------ methodName='qtClone' thisStepMessage = "not yet implemented"; thisStepResult = testArray[methodName](); thisStepEvalFunction = item => { item.string='hola' return referencedObject.string!='hola' }; passingTests = completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) && passingTests; return passingTests; }; //END OF moduleFunction() ============================================================ module.exports = moduleFunction; //module.exports = new moduleFunction();