Guest User

Untitled

a guest
May 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. ```js
  2. function* producer() {
  3. let index = 0;
  4. while (1)
  5. yield index++;
  6. }
  7.  
  8. let consumer = () => {
  9. let data = producer();
  10.  
  11. console.log(data.next().value); // 0
  12. console.log(data.next().value); // 1
  13. console.log(data.next().value); // 2
  14. console.log(data.next().value); // 3
  15. }
Add Comment
Please, Sign In to add comment