Created
          December 20, 2017 15:10 
        
      - 
      
 - 
        
Save jooyunghan/9d6ecfb25f683e63ddf5c2b870ba818e to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function createAsyncIterator() { | |
| const promises = []; | |
| this.subscribe({ | |
| next(value) { | |
| promises.shift().resolve({ value, done: false }); | |
| } | |
| }); | |
| return { | |
| next() { | |
| return new Promise((resolve, reject) => { | |
| promises.push({ resolve, reject }); | |
| }); | |
| } | |
| }; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment