paperwm/gnome-shell-mode

Defining generator functions doesn't work

olejorgenb opened this issue · 0 comments

Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*

function* iter() {
  let i = 0;
  while(true) yield i;
}

let numbers = iter();
numbers.next()
// -> null

// This works:
var iter;
function defIter() {
    iter = function* () {
        let i = 0;
        while(true) yield i++;
    }
}
defIter()
let numbers = iter();
iter.next().value
// 0

Probably due to how we parse and rewrite the code.