In the meantime I found this code: https://gist.github.com/robotlolita/ccecb9b6781ba085d142040a943e1a96
It does what I want to do. As a follow up question: Does anyone know of a tool that allows users to visually compose flows, similar to the way it is done in Azure ML Studio (http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-02-52/Azure-ML-Operationalization.png)? Thanks a lot, Phil On Friday, July 22, 2016 at 1:16:51 PM UTC+9, Phil Heltewig wrote: > > Hi all, > > I've searched the forums, yet can't find anything that describes an answer > to what I am looking for. > > In a nutshell, I would like to control flow of my application be defined > by an external flow input (file) in which the individual steps (functions) > to call, their order and conditions are described. > > Example code with hardcoded control flow: > > // Code > > function A(input){ > return input * 2; > } > > function B(input){ > return input + 2; > } > > function C(input){ > return input / 2; > } > > functionZ(input){ > if(input==3) lowResult(); > else highResult();; > } > > function lowResult(){ > console.log('Result smaller than 4'); > } > > function highResult(){ > console.log('Result equal or larger than 4') > } > > // flow 1 > Z(C(B(A(2)))); // (((2 * 2) + 2) / 2) = 3 returns 'Result smaller than 4' > // flow 2 > Z(B(C(A(2)))); // (((2 * 2) / 2) + 2) = 4 returns 'Result equal or larger > 4' > > > Now what I am looking for is a library or approach that allows me to > define flow 1 and flow 2 in a file and then have the code execute according > to the defined flow. Best would be format that allows for conditions, etc > as well. > > <!-- FLOW 1 --> > <STEP function="A" /> > <STEP function="A" /> > > <STEP function="A" /> > > <IF condition="==3"> > <STEP function="lowResult" />> > <ELSE> > <STEP function="highResult" /> > </IF> > > > > That way different control flows could be easily composed by connecting a > number of components. > > Thanks for reading, > Phil > > > -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. To post to this group, send email to nodejs@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/bd2db956-9325-445d-be77-78758f3e754c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.