This file contains 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 await(generatorFunction) { | |
let gen = generatorFunction(); | |
/** | |
* @param {any?} err The error to throw in the generator, where yield was last called. | |
* @param {any?} result The result to pass to the genarator for the last call to yield | |
*/ | |
function next(err, result) { | |
// If the last promise that was yielded was rejected, | |
// trigger an error inside the generator where yield was last called |