Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Demystifying Async Programming in Javascript - co() simple solution
function co(generator) {
return new Promise((resolve, reject) => {
const g = generator();
function next(nextVal) {
const ret =;
if (ret.done) {
return resolve(ret.value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.