Multiple calls in eachz
Hello,
First of all, thanks a lot for this great package.
I encounter an issue with eachz loops and wonder whether this is due to a wrong way of using RosaeNLG or to a bug.
You will find below my test code, run with RosaeNLG@1.16.5:
mixin T1_main(p_items)
eachz l_item in p_items
- inc_T1++;
| #{l_item.Name}
| #[+T1_sub(l_item)]
mixin T1_sub(p_item)
- console.log('T1 _ Call #' + inc_T1 + ' with parameter ' + JSON.stringify(p_item));
| #{p_item.Value}
-
var inc_T1=0;
const items=[{Name:'A', Value:10}, {Name:'B', Value:100}, {Name:'C', Value:1000}];
console.log(JSON.stringify(items));
| #[+T1_main(items)]
Expected log output:
[{"Name":"A","Value":10},{"Name":"B","Value":100},{"Name":"C","Value":1000}]
T1 _ Call #1 with parameter {"Name":"A","Value":10}
T1 _ Call #2 with parameter {"Name":"B","Value":100}
T1 _ Call #3 with parameter {"Name":"C","Value":1000}
Actual log output:
[{"Name":"A","Value":10},{"Name":"B","Value":100},{"Name":"C","Value":1000}]
T1 _ Call #1 with parameter {"Name":"A","Value":10}
T1 _ Call #2 with parameter {"Name":"B","Value":100}
T1 _ Call #3 with parameter {"Name":"C","Value":1000}
T1 _ Call #4 with parameter {"Name":"A","Value":10}
T1 _ Call #5 with parameter {"Name":"B","Value":100}
T1 _ Call #6 with parameter {"Name":"C","Value":1000}
As you can see it above, 6 calls seem to be made to 'T1_sub' function while only 3 were expected.
Could you please help me understand why?
Thanks a lot for your help on this.
Best,
Edited by __Flood__