paperwm / gnome-shell-mode

Package for developing gnome-shell extensions
GNU General Public License v2.0
27 stars 7 forks source link

Defining generator functions doesn't work #23

Closed olejorgenb closed 6 years ago

olejorgenb commented 6 years ago

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.