This is a powerful tool that loops on each element of an array an produces arrays.
Inputs are the same as inputs of tool, except that the first one must be an array.
var isJS = Matis.tools.MatchRegexp('\\.js$');
var looper = Matis.tools.ForEach({ tool: isJS, output: ["yes", "no"]});
looper.exec(
{ text: ["a.js", "b.html", "c.js", "d.js"] },
function(outputs) {
console.log(outputs);
}
);
outputs will be equal to:
{
yes: ["a.js", "c.js", "d.js"],
no: ["b.html"]
}
var process = Matis.Process(function() {
this.Path = Matis.tools.Constant('mypath/subpath');
this.List = Matis.tools.ReadDir();
this.IsJavascript = Matis.tools.MatchRegexp('\\.js$');
this.IsTest = Matis.tools.MatchRegexp('spec');
this.Loop = Matis.tools.ForEach({
tool: this.IsJavascript,
output: "no"
});
this.Garbage = Matis.tools.BlackHole();
}, [
"Path > List > Loop",
"IsJavascript:yes > IsTest",
"IsJavascript:no > Garbage"
]);
Without the BlackHole, this process would filter no file because all the no outputs are outputs of the ForEach.