Injecting generator helper function into the prototype to provide syntax sugar. some idea is from: yield-js underscore.js python itertools