I am trying to build a generator function from an array. The simplest example would be:
const array = [1,2,3,4]
function * createGenerator () {
array.map(function(elem){
yield elem
}
}
And I would expect:
function * createGenerator () {
yield 1
yield 2
yield 3
yield 4
}
Also if I want to add a switch statement like this:
function processServerActions (array) {
for (let elem in array) {
switch(elem) {
case 1:
yield 1111
case 2:
yield 22222
case 3:
yield 333333
yield 444444
case 4:
yield 55555
}
}
}
But is not working. What am I missing?
Thanks!