Guest User

Untitled

a guest
May 27th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.20 KB | None | 0 0
  1. 'use strict';
  2.  
  3. function* gen(cb) {
  4. while (true) {
  5. const x = yield;
  6. cb(x);
  7. }
  8. }
  9.  
  10. const g = gen((x) => {
  11. if (x === 10) {
  12. g.return();
  13. }
  14. });
  15.  
  16. let i = 0;
  17. while (true) {
  18. g.next(i);
  19. i += 1;
  20. }
Add Comment
Please, Sign In to add comment