Skip to content

Instantly share code, notes, and snippets.

@linuxenko
Created April 17, 2016 18:43
Show Gist options
  • Select an option

  • Save linuxenko/cb0015823f721039e6399c9252232786 to your computer and use it in GitHub Desktop.

Select an option

Save linuxenko/cb0015823f721039e6399c9252232786 to your computer and use it in GitHub Desktop.
function run (generator) {
var data = null, yielded = false
var iterator = generator(function () {
data = arguments
check()
})
yielded = !!(iterator.next())
check()
function check () {
while (data && yielded) {
var err = data[0], item = data[1]
data = null
yielded = false
if (err) return iterator.throw(err)
yielded = !!(iterator.next(item))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment