Created
July 7, 2016 13:46
-
-
Save asvny/d76843119569c5ac799f991085eeaedd to your computer and use it in GitHub Desktop.
run
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 run(makeGenerator) { | |
return function() { | |
var generator = makeGenerator.apply(this, arguments); | |
var handle = function(p) { | |
if (p.done) return p.value; | |
return p.value.then(function(v) { | |
return handle(generator.next(v)); | |
}); | |
}; | |
return handle(generator.next()); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment