"this" usage
promises iterator
deep.iterate([
1,2,deep.nodes("delayed").delay(10), new Error("hhh"),4
],
function(s){
return "e"+s;
}, function(e){
return "error managed"; // try to coment or not this line
})
.log(); // ==> ["e1", "e2", "edelayed", "error managed", "e4"]
through chain :
deep.nodes([1,2,deep.nodes("delayed").delay(10), new Error("hhh"),4])
.iterate(function(s){
return "e"+s;
}, function(e){
return "error managed";
})
.log(); // ==> ["e1", "e2", "edelayed", "error managed", "e4"]
Could be used to iterate through functions as :
deep.utils.iterate([
function(arg){ return deep.nodes("hello "+arg).delay(5); },
function(arg){ return deep.nodes(arg+" world").delay(8); }
], function(s){
return s("deep");
})
.log(); // ==> ["hello deep", "deep world"]
wired asynch functions
deep.wired([
function(arg){
return deep.when("arg was : "+arg).delay(5);
},
function(arg){
return new Error("plaf : "+arg);
},
function(arg){
return deep.when("arg 2 was : "+arg).delay(5);
}
],
"hello",
{
test:1
},
function(s){
return "{" + s + "}";
},
function(e){
return "{error managed "+e.message+"}";
})
.log(); // => {arg 2 was : {error managed plaf : {arg was : hello}}}
deep.nodes({
func1:function(arg1, arg2){
return ["arg11:"+arg1,"arg21:"+arg2];
},
func2:function(arg1, arg2){
return ["arg12:"+arg1,"arg22:"+arg2];
},
func3:function(arg1, arg2){
return ["arg13:"+arg1,"arg23:"+arg2];
}
})
.query("./(func.*)")
.wired(["hello","world"])
.log(); // => ["arg13:arg12:arg11:hello", "arg23:arg22:arg21:world"]