An array in place of a task or workflow variable means an implicit "sequence" task
var wf = worksmith([
{ task: "set", name:"p1", value:"hello" },
{ task:"log" },
{ task:"eachSeries", item:[1,2,3], subflow: [
{ task:"log" message:"@item" },
{task:"delay", duration:"[eval]item * 250[/eval]" }
]}
]);
wf({}, function(err, res) { });
Totally revamped interpolation logic, deep tree interpolation, array interpolation
tag support to drive interpolation mode: {{hbs}} and {{eval}} are support out of the box
eachSeriesActivity and whileActivity
Terminate a workflow or sequence from code (a programmable alternative to conditional="predicate" attribute)
in execute scope this
holds workflow execution api. you do pass your done, and not invoke it yourself.
Note: in later versions you will not have to provide done
//terminate a workflow
function execute(done) {
this.workflow.terminate(/*err*/, /*result*/, done)
}
//terminate the current parent scope
function execute(done) {
this.workflow.terminateParent(/*err*/, /*result*/, done)
}
Error logging temporalily removed
Readme update
connect existing functionality into a workflow using worksmith.use + worksmith.createAdapter
worksmith.use("_", worksmith.createAdapter(require('lodash')))
var context = {items:[{field:"value"}, {field2:"value2"}]}
var workflow = worksmith({
task: "_/filter",
arguments: ["@items", { field:"value"} ],
resultTo: "myresult"
})
workflow(context, function wfresult(err, res, context) {
assert.equal(context.myresult[0], context.items[0])
done();
});